-
Stage.resize
Hi coders
I have a simple animation, which I can't get it right and would need help.
I have a movieclip (circle) which has to go from left to write like a ping-pong ball - when hitting the margin of flash window, than it changes direction. All this has to work when stage resized, for example if I go to fullscreen, than the ball has to act the same way - going from edge to edge.
I messed with Stage.width, Stage.align but coding doesn't like me :-(
The first who help me will got a beer via PayPal.
Thanks in advance.
-
.
Hi,
if you can't open the fla, then:
With a movieclip on stage called "circle" try this
PHP Code:
Stage.scaleMode = "noScale";
Stage.align = "TL";
var minX:Number = 0;
var maxX:Number = Stage.width;
var moveX:String = "right";
var motionX:Number = 20;
trace(minX);
trace(maxX);
sizeListener = new Object();
sizeListener.onResize = function()
{
minX = 0;
maxX = Stage.width;
trace(maxX);
};
Stage.addListener(sizeListener);
onEnterFrame = function ()
{
if (moveX == "right")
{
circle._x += motionX;
if (circle._x >= maxX)
{
moveX = "left";
}
}
if (moveX == "left")
{
circle._x -= motionX;
if (circle._x <= minX)
{
moveX = "right";
}
}
};
-
Thanks
This is perfect!
I just had to add a small detail: var maxX:Number = Stage.width-circle._width;
Will send the beers now :-)
-
.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|