PDA

View Full Version : Reacting to Stage Resize?


whatifhesgotapointedstick
02-27-2008, 07:25 PM
Is it possible for me to execute events once the stage is resized to below a certain width and/or height when my flash movie fills the browser 100%?

I know its possible. I've seen it done. Resize the browser smaller here and watch what happens:

http://ff0000.com/

Granted, these are the geniuses at Red Interactive, but I figure that part can't be too difficult can it?

I took Lee Brimelow's tutorial here:

http://www.gotoandlearn.com/player.php?id=31

and tried to adapt it a bit, improvising my own code but its not working, obviously (with apologies to Mr. Brimelow...).

function ahem() {
if (Stage.width<=300 || Stage.height<=200) {
setProperty(this.ahem, _visible, true);
} else {
setProperty(this.ahem, _visible, false);
}
}
ahem();
var stageL:Object = new Object();
stageL.onResize = function() {
ahem();
picture._x = Stage.width/2;
picture._y = Stage.height/2;
};
Stage.addListener(stageL);

Is this the right way to go about this? I completely new to listeners, so maybe its just something that I'm unaware of?