• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

► SWF File Elements Shift Upon Resizing Window

New Here ,
May 17, 2012 May 17, 2012

Copy link to clipboard

Copied

Hi,

I've created a Flash website. 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?

Here is what I mean:

http://i1124.photobucket.com/albums/l567/niksavtchenko/2.jpg

http://i1124.photobucket.com/albums/l567/niksavtchenko/1.jpg

Thanks,

Nik

TOPICS
ActionScript

Views

2.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 19, 2012 May 19, 2012

Copy link to clipboard

Copied

you can specify your layout in an onResize listener:

var stageListener:Object={};

stageListener.onResize=function(){

// position header

// position content

// etc

}

Stage.addListener(stageListener);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2012 May 20, 2012

Copy link to clipboard

Copied

thank you so much! can you give me an example of what I would enter for position header, content, etc? My document size is 1024 x 768. sorry, I'm new to flash.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2012 May 20, 2012

Copy link to clipboard

Copied

your exact code depends on what you want.  but, for example, if you wanted your header to be centered horizontally and your content to be centered horizontally and vertically, you could use:

var stageListener:Object={};

stageListener.onResize=function(){

// position header

header._x = (Stage.width-header._width)/2;

// position content

content._x = (Stage.width-content._width)/2;

content._y = (Stage.height-content._height)/2;

}

Stage.addListener(stageListener);

// and you will probably want to check the stage scaleMode properties.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 20, 2012 May 20, 2012

Copy link to clipboard

Copied

for some reason when I copy and paste this code my swf gets stuck loading and blinks uncontrollably. what should I do? also, how do I check the stage scaleMode properties? I'm so sorry I don't know Flash well at all!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 20, 2012 May 20, 2012

Copy link to clipboard

Copied

what error message do you see?

check the flash help files, the Stage class.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

How would I do that? I tried using this code:

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.RESIZE, onResize);

function onResize(e:Event=null):void
{
    trace( stage.stageWidth );
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

are you publishing for as3 or as2?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

as3, flash player 9

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

you're posting in the wrong forum.  the previously suggested code was for as2.

for as3, your code will work.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

nothing happens when I use my code. I pasted it at the end of the main AS. what am I doing wrong?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

what do you expect to happen?  you only have a trace() statement in your listener function and it's not clear you know how to find trace output when you open that html file in your browser

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

nope. my website is 1024px x 768px

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 21, 2012 May 21, 2012

Copy link to clipboard

Copied

LATEST

?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines