I’m having a problem with AS3…I want to have a movie clip that spans the width of the browser window which is centered so if the browser is scaled the content in the center remains the same size but the left and right expands.
In css it would be a little like adding margin:auto to a div tag.
Ideally it would be great to load in various external swf files for different sections that images txt etc are able to move in from the edge of the screen.
In the HTML tags of the embed/object you put width and height 100%, then control the final size with an external div.
Inside flash:
//that will set the registration point (0,0) in the top left corner, and will tell flash to not scale the contents if you resize the stage
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
//to adjust the size of the movieclip to the width of the stage.
my_mc.width = my_mc.stage.stageWidth;
I think you first need to addChild or have something in the stage in order to be able to get stageWidth or stageHeight.
If you want to have a liquid layout (things move when you resize the stage) you need to put an on resize listener to the stage and call some sort of changeLayout function
I tried your idea and i got the movieclip to stretch but then of course all the content inside the movieclip did as well.
Can you set noscale to a movieclip nested inside the main one?[/QUOTE]
What I do in this case is the same that Pensamente suggests: to have a background inside the holder movieclip. Change the backgorund size, and then move the other elements as you need to. Like for example put the close button in the bottom right corner at 10 pixels from the border.
margin = 10;
holder.x = 0;
holder.y = 0;
holder.background.width = holder.stage.stageWidth;
holder.background.height = holder.stage.stageHeight;
//considering the 0,0 point of close_btn is at the upper left corner...
holder.close_btn.x = holder.background.width - holder.close_btn.width - margin;
holder.close_btn.y = holder.background.height - holder.close_btn.height - margin;
(I’m writing this directly so maybe there are some mistakes…)
Hope that helps
It’s a bit of a pain to do this manually everytime for every object on every project. If you’re into liquid layouts you should really consider building a class to manage positions and sizes.
This seems to be working however i had to take the height attribute out as loading an external swf caused the height to jump.
I’m know trying to get make a separate movie clip fly in from off screen! Having difficultly when i postion it right now!! Good fun this AS3 isnt it :h:
I’m trying to get the background gradient (myHolder_mc) to stretch full width of the browser window and keep the external swf thats loaded into (myLoad_mc) centered.
Ideally id like it if i could animate the myLoad_mc to enter the screen from the right edge and stop bang in the middle.