flash on resize

  • Started
  • Last post
  • 8 Responses
  • hotroddy

    I've been noticing more flash sites expand to the edges of the browser and maintain their dimensions when the browser is resized.
    These values are set but I don't know how they work: Stage.scaleMode = "noScale";

    and HTML width and height to 100%

    How do you get your stage to always align in the middle?

    Anyone know what I'm talking about?

  • Mick0

    Use Stage.width and Stage.height and align your MCs to half that.

    Then use _root.onResize to make sure it all aligns when someone changes the size of their browser.

  • PonyBoy0

    Enter response:

    that's all in the flash - by default - your swf will center itself if you go full browser flash and DON'T mess w/the alignment in flash... (Stage.align = "TL, T, TR"; etc... Top Left, Top, Top Right (search your Flash help for Stage.align)....

    ... I usually align all my junk to the top left...

    ... and for the stage resize action... you need to add a listener for the stage...

    ... look up Stage.onResize (I think that's it)... or look up Stage Listener - because that's what you use is a listener...

    it's purty simple once you get the hang of it... all you have to do is come up w/simple equations to place your swf's at exact coordinates...

    ... for instance, if you wanted the instancee 'my_mc' to be 30 px in on the X axis and 30 px FROM THE BOTTOM and you aligned your Stage.align = "TL"... your variables would be:

    my_mcX = 30;
    my_mcY = Stage.height -30;

    if you wanted to center your instance of 'my_mc' (this will depend on the movieClip's alignment itself - if the 'my_mc' instance is aligned to it's top left - then your variables would be:

    my_mcX = (Stage.width/2) + (my_mc._width/2);

    my_mcY = (Stage.height/2) + (my_mc._height/2);

    what both variables do is first find the center of the stage... but because the mc isn't centered but is justified to the top left of itself - you need to compensate for that by finding it's center... which is where you divide the mc in half and add that to your position on stage.

    hope that makes some sense - I can toss you an .fla or two or what I use... w/the stage listener in place etc...

    ... you may want to have someone 'good' at actionscript check it though as I'm sure it can be made much more efficient.

    lemme know if you want it.

    happy flashing!

  • aXion0

    try something like this:

    Stage.scaleMode = false;
    Stage.align = "TL";
    this.onResize = function ()
    {
    --> align your content here!!
    --> the middle will be:
    --> x: Stage,width/2
    --> y: Stage.height/2
    }
    Stage.addlistener (this);

    ...hope this helps..

  • hotroddy0

    Does this mean you'd have one movie clip on the _root stage and load everything inside it? Or do you place evrything relative to it?

    PonyBoy I would love to see an fla example. I'm not sure how you create and attach a listener with the onResize function.

    You can email it to Thanks for the help. Much appreciated

  • hotroddy0

    "try something like this:

    Stage.scaleMode = false;
    Stage.align = "TL";
    this.onResize = function ()
    {
    --> align your content here!!
    --> the middle will be:
    --> x: Stage,width/2
    --> y: Stage.height/2
    }
    Stage.addlistener (this);"

    -------------

    aXion where do you place the code inside a movie clip?

  • aXion0

    the clips don't need any code to be aligned...

    this.onResize = function ()
    {
    contentMC._x = Stage.width/2;
    }

    --> aligns a clip "contentMC" which is on _root to the middle of the stage...

  • PonyBoy0

    Enter response:

    http://www.arcademedia.net/nt/fl…

    I use this easing tool in my flash:

    http://laco.wz.cz/tween/

    the fla is bit un-optimized though... all the movieclips stay onthe stage and just adjust alpha channels... which is pretty bulky... sooo.. yeah - don't pay any attention to the graphics etc as this file isn't complete but has all the full broswer stuff you need...

    enjoy!

  • hotroddy0

    thanks Pony!