开发者

AS2 Stage Size Detection / MC reposition upon resize & framechange?

Creating a website which is staged as fullscreen, had no dramas there.

The only problem I'm facing is if you resize the window, then click to a new menu, the programmatic positioning of items: ie:

    contactheader._x = Stage.width / 2 - 252;
    contactheader._y = Stage.height / 2 - 2开发者_高级运维64;

does not kick in, until you 'bump' it into place by resizing the window again. See here for live example with steps to see the problem:

http://flash.pcfuse.com/

Project files here: http://flash.pcfuse.com/mySite.zip

What can I do to stop the items from ignoring their own programmatic positioning??

Thankyou kindly


function setStage ()
{
    var sw:Number = Stage.width;
    var sh:Number = Stage.height;

    tabbar._x = Stage.width / 2;
    tabbar._y = Stage.height - 98;

    google._x = Stage.width / 2 - 183;
    google._y = Stage.height / 2 + 28;

    about_txt._x = Stage.width / 2 - 376;
    about_txt._y = Stage.height / 2 - 263;

}

// Add a listener
var stageListener:Object = new Object ();
Stage.addListener (stageListener);

// When the Stage dimensions change...
stageListener.onResize = setStage;

// Call our function to set it all up right!
setStage ();


Got it ;)


I think the issue you might be running into is that when you are going to the different sections of your flash application, you are adding an event listener so that your display objects are positioned correctly on resize. However you are not doing any dynamic positioning of these objects upon actually going to that section.

To clarify, when the flash piece first loads, it grabs the stage height and width, does it's object placement on those calculations and then sits there. When you click on the tabs, it's not reloading those objects and repositioning them because it did so when the application first started. It will pop them into place once you start to resize the swf, because that is what the onresize event is supposed to do.

I'd suggest writing a function that does the positioning of the objects in each section, then have it called whenever you hit that specific section you want opened from clicking on a tab, then also call that function from inside the onresize event.


Try this:

onEnterFrame = function(){
   contactheader._x = Stage.width / 2 - 252;
   contactheader._y = Stage.height / 2 - 264;
}

If at any point you want to stop it from updating its position use:

onEnterFrame = null;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜