Published on July 15, 2008
in AS3.
I have made a small class that you can use if you would like to do something when your flash player is scaled to a maximum or minimumĀ size. I have seen this used before where if the user scaled the browser to less then 1024×768 the user was warned to scales their browser to the correct size.
I have also added the ability to ignore all out of bound events with a simple method call.
Download Zip here
http://gfxcomplex.com/blog/wp-content/uploads/2008/07/screensizenotification.zip
Source comes with completed example file.
Heres some example useage
import com.gfxcomplex.screen_management.ScreenSizeNotification;
var testing:ScreenSizeNotification = new ScreenSizeNotification();
testing.manageStage(stage, {minSizeW:550, minSizeH:400, maxSizeW:1000, maxSizeH:850});
testing.addEventListener(ScreenSizeNotification.SCREEN_LESS_THEN_MIN, tooSmall);
testing.addEventListener(ScreenSizeNotification.SCREEN_GREATER_THEN_MAX, tooBig);
function tooSmall(e:Event):void{
trace("Too small");
}
function tooBig(e:Event):void{
trace("Too Big");
}
//if needed to stop event dispatches use testing.ignoreEvents(true);
Published on April 23, 2008
in AS3.
I have seen a few posts on the internet about people saying that the hole custom event class is just not there thing or some thing alone that line. In short most of the blog posts focussed on providing different ways to pass a var with an event. I have a simple way to do this as well and it has not been discussed by any one yet so I thought I would put my 2 cents out there.
The idea is that you use the dictionary class to assign vars to an object and then access the var by passing the object to which the var is assigned to as an array index key in the dictionary.
Example:
I this example you would need three movieClips on the stage each with a instance name of someClip1_mc, someClip2_mc and someClip3_mc.
var dictionary:Dictionary = new Dictionary();
dictionary[someClip1_mc] = "sting1";
dictionary[someClip2_mc] = "sting2";
dictionary[someClip3_mc] = "sting3";
someClip1_mc.addEventListener(MouseEvent.CLICK, traceOut);
someClip2_mc.addEventListener(MouseEvent.CLICK, traceOut);
someClip3_mc.addEventListener(MouseEvent.CLICK, traceOut);
function traceOut(e:Event):void {
trace(dictionary[e.target]);
}
Now the pit fall to this solution is that the scope of the dictionary instance needs to be accessible to the event method. Other then that you could use an Object, Array, ect… in the dictionary.
Published on March 26, 2008
in AS3 and Flash.
Here’s the image of a strange pop up I got today when publishing a swf using flashdevlop. the command I mistakenly made was “ctl+enter+shift” As you can see it’s a language chooser for blaze but it appears to be coming from flash CS3. What is this, why does it come up as Flash cs3?? very strange!

Published on March 5, 2008
in AS3.
[flashvideo filename=”http://www.gfxcomplex.com/video/main.flv” /]
heres the class you will need to make this work.
package com.gfxcomplex.button{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class GenericButton extends MovieClip{
private var hitTest:Boolean = false;
public function GenericButton(){
initListener();
stop();
}
private function initListener():void{
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
}
private function onEnterFrame(e:Event):void{
if(hitTest){
nextFrame();
}else{
prevFrame();
}
}
private function onMouseOver(e:MouseEvent):void{
hitTest = true;
}
private function onMouseOut(e:MouseEvent):void{
hitTest = false;
}
}
}
Published on January 29, 2008
in AS3 and Flash.
I believe I found a bug that only shows up in Firefox and only when using the using the FLVPlayer’s FullScreen button in the Flash. I would like to get confirmation before I submit a bug report.
heres a demo flvplayer: Demo
If you click on the fullscreen button you will get the bug as seen in this photo.

If you click any were on the stage it will look like it should.
This is an example of what it should look like

As you can see the player scales nicly to the bottom of the stage.
The other problem I found is that if you try to bypass this by useing DisplayState.FULL_SCREEN you may be also bypassing hardware acceleration support which is some thing you probably want to use.
I found this in the help files under the FLVPlayback.enterFullScreenDisplayState method which states
Because a call to this method sets the displayState property of the Stage class to StageDisplayState.FULL_SCREEN, it has the same restrictions as the displayState property. If, instead of calling this method, you implement full screen mode by directly setting the stage.displayState property to StageDisplayState.FULL_SCREEN, hardware acceleration is not used
So I wonder is hardware acceleration all way omitted if you use DisplayState.FULL_SCREEN?
FYI: heres my browser info with the bug.
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11
From what I can tell it’s only FireFox.
Published on January 22, 2008
in AS3.
Here is a mini cheat sheet to better and faster coding.
By naming your Object types with the corresponding Variable suffix you will add code hinting when you have not strong typed your Object types as well making your code more readable.
Use escape shortcuts for redundant typing of the same code. (”it’s kinda like snip-its of premade code”)
================
AS3 code hint triggers
Object type:
Variable suffix:
Array
_array
Button
_btn
Camera
_cam
Color
_color
ContextMenu
_cm
ContextMenuItem
_cmi
Date
_date
Error
_err
LoadVars
_lv
LocalConnection
_lc
Microphone
_mic
MovieClip
_mc
MovieClipLoader
_mcl
PrintJob
_pj
NetConnection
_nc
NetStream
_ns
SharedObject
_so
Sound
_sound
String
_str
TextField
_txt
TextFormat
_fmt
Video
_video
XML
_xml
XMLNode
_xmlnode
XMLSocket
_xmlsocket
======================
Escape shortcuts for AS3
with (Escape + wt)
while (Escape + wh)
var (Escape + vr)
throw (Escape + th)
switch (Escape + sw)
return (Escape + rt)
if (Escape + if)
function (Escape + fn)
for..in (Escape + fi)
for (Escape + fr)
else (Escape + el)
do (Escape + do)
default (Escape + dt)
continue (Escape + co)
class (Escape + cl)
case (Escape + ce)
break (Escape + br)
// ( Escape + //)
Published on January 20, 2008
in AS3.
What are the excuses for not allowing all that flex can do in flash or vice versa? I think AS3 should be AS3 not Flash’s AS3 or Flex’s AS3. I believe Adobe needs to address this big problem. We need a discrepancy free program language. The web community has become more bias to Flex over the last year with out concern for the developers working in Flash. Example Yahoo’s map API which works just fine in flash’s AS2 now is limited to flex in AS3 though with out any real under standing why.
From an IDE stand point what is the use of providing a IDE the power of AS3 only to limit it’s use? I want to know why Flex can do more then flash. From what I under stand the hole flex API is built off of the components built in flash. I think this bias for one IDE over the other with in the context of AS3 is setting the stage for failure and leaves a negative precedences in our community. I believe adobe needs to merge the two programs in to a single IDE or make a better attempt to bridge their discrepancy.