Groups | Blog | Home
all groups > flash actionscript > april 2004 >

flash actionscript : Using Stage.onResize event


meeesta
4/10/2004 4:05:42 PM
Hello.

I'm trying to create a movie that adapts to fit any size screen, well width
wise anyway. At the moment I can't seem to get the Resize event to fire. It
does it once when the movie first loads in and thats it. Once the move has
loaded you can resize the browser window and nothing happens. Before I got
carried away my aim was simply move a movie clip (instance called 'rightEnd' on
the _root) left or right depending on the screen width.

At first I tried this (as in the help files), on the first frame of the movie:

Stage.align = "L";
var SWFwidth = Stage.width;
var SWFheight = Stage.height;

myListener = new Object();
myListener.onResize = function() {_root.SWFwidth = Stage.width;
_root.rightEnd._x = _root.SWFwidth-80;}
Stage.scaleMode = "noScale";
Stage.addListener(myListener);

But nothing happened, even on the first load, so I thought that perhaps I
should refer to a seperate function so I tried...

Stage.align = "L";
var SWFwidth = Stage.width;
var SWFheight = Stage.height;

function reFit(){
_root.SWFwidth = Stage.width;
_root.rightEnd._x = _root.SWFwidth-80;
}

myListener = new Object();
myListener.onResize = reFit();
Stage.addListener(myListener);

Now this got some response in the fact the movie clip (rightEnd) moved once.

Anybody any ideas as where I'm tripping up? Any help would be greatly
appreciated.

Many thanks for your time.
Meeesta.
johnnyofeck
4/10/2004 4:32:14 PM
meeesta
4/10/2004 6:06:12 PM
If the browser window was set to full screen, and the swf movie adapts to it
all fine and well. But if the user shrinks the browser window, the movie
doesn't re-adapt it's self to fit the window. I thought it acted like the
resize event in Javascript, where change the browser window size and the event
fires... not just acting like an onload event.
meeesta
4/10/2004 6:19:29 PM
johnnyofeck
4/10/2004 6:21:35 PM
sneakyimp
4/10/2004 8:56:51 PM
Can your _root level swf also resize itself? For instance, if my SWF is sized
550 x 400 pixels, can I have the user clicka button and have it be 800 x 550
pixels? what would your HTML tags say about the height/width?
urami_
4/11/2004 2:47:25 AM

[quoted text, click to view]

simple example ,
http://www.flashfugitive.com/fd/OnResize.htm

window scale , MC menu stays in the middle all the way while scaling window .

Menu movie clip instance name MCa and frame action :

Stage.scaleMode = "noScale";
Stage.align = "tl";
this.onResize = function () {
repositionStuff();
};
Stage.addListener(this);
_global.repositionStuff = function () {
mca._x=Stage.width*(50/100);
mca._y=Stage.height*(50/100);
};


NOTE !
the publish should be set to 100% not fixed pixels .




--

Regards


urami_*



<no>
http://flashfugitive.com/
</no>

boognische
4/11/2004 6:05:29 AM
Meeesta, meeesta, Try adding an onResize event to the body tag in your html to
call a javascript function that gets the window's innerWidth and innerHeight
properties and passes them into the swf as global vars. I have had success
with this method. A good article here:
[L=http://www.macromedia.com/support/flash/ts/documents/java_script_comm.htm]htt
p://http://www.macromedia.com/support/flash/ts/documents/java_script_comm.htm[/L
].

Hope this helps
urami_
4/11/2004 3:00:18 PM


[quoted text, click to view]

Why go around if flash has it's on build in onresize ?

--

Regards


urami_*



<no>
http://flashfugitive.com/
</no>

AddThis Social Bookmark Button