A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Stage.resize

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    2

    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.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    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";
            }
        }
    }; 

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    2

    resolved Thanks

    This is perfect!
    I just had to add a small detail: var maxX:Number = Stage.width-circle._width;
    Will send the beers now :-)

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Salute

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center