A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: ► SWF File Components Shift Upon Resizing Window!

  1. #1
    nik.savtchenko
    Guest

    ► SWF File Components Shift Upon Resizing Window!

    Hi,

    I've created a Flash website in ActionScript 2.0. However, when I resize the published SWF (or the preview window within Flash) some of the elements get displaced. How can I create a "wrapper" like in Dreamweaver so that the window can be dragged out to any size and all of the components stay together as they were intended? Sorry, I'm very new to Flash.

    Attached are screenshots of the problem.

    Thank you!

    Nik
    Attached Images Attached Images
    • File Type: jpg 1.jpg (112.7 KB, 35 views)
    • File Type: jpg 2.jpg (110.4 KB, 34 views)

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    EASY WAY: Use this on your first Frame Actions:

    Actionscript Code:
    Stage.scaleMode = "exactFit";

    This will however scale everything, so that everything is in place, but it will look rather weird

    HARD WAY: You can use a resize listener (self-created codes that are executed when something occurs, in this case, when the window resizes), and then make each movieclip move and/or scale proportionally, here's a sample code to use in first Frame (with a movieclip with an instance name of, mc):

    Actionscript Code:
    Stage.align = "TL";
    Stage.scaleMode = "noScale";

    resizeScreen();

    resizeListener = new Object();
    resizeListener.onResize = function(){
        resizeScreen();
    }
    Stage.addListener(resizeListener);

    function resizeScreen(){
        mc._x = Stage.width/2;
        mc._y = Stage.height/2;
    }

    Explanation:

    Actionscript Code:
    // set the base alignment to TOP-LEFT. Try and see what happens if you omit this
    Stage.align = "TL";
    // make the Stage NOT scale upon resizing, as it normally does, to make our own resizing codes
    Stage.scaleMode = "noScale";

    // call the function where everything is resized, because at the start of the Flash movie,
    // the Stage isn't resized, so the Resize Listener won't execute until the window has resized,
    // hence we call the function with all the codes to resize, once, at the start of movie,
    // try omiting this and see what happens
    resizeScreen();

    // create a new object (a new listener)
    resizeListener = new Object();
    // assign onResize handler to the listener
    resizeListener.onResize = function(){
        // codes in here will be executed once the screen resizes
        // in this case, we call the resizing function when the
        // screen is resizing
        resizeScreen();
    }
    // initiate the resize listener
    Stage.addListener(resizeListener);

    // this is the function with all the codes for resizing
    function resizeScreen(){
        // in this example, I have a Movieclip on stage with an instance name of, mc,
        // and on resize, I'm making its X equals to the Width of the Stage divided
        // by 2, which is the same as the Middle of the screen. I do the same with
        // the Y coordinate for the movieclip. This will make it stick to the center
        // of the screen whenever you resize it
        mc._x = Stage.width/2;
        mc._y = Stage.height/2;
    }

    Hope this helps
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    nik.savtchenko
    Guest
    I tried that however the site flashes uncontrollably. Also it appears that somewhere along the line I switched to ActionScript 3.0 and can't switch back. Sorry, I'm new.

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    File->Publish Settings... (or press CTRL+SHIFT+F12)
    Flash Tab
    Change from Actionscript 3.0 to Actionscript 2.0

    Also, could you post your FLA file?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

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