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

Creating A File That Resizes With The Browser

Explorer ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

I've been asked to create an effect similar to this: http://www.scottmorganstudio.com.

Note how the image in the background always fills the browser window and always stays in proper aspect ratio with cropping as necessary, but the text on top of it floats over the image depending on how big the window is and the size of the text does not change.

I've been able to manage most of this. I can get my image to resize in the browser window to always fill it completely and crop as necessary. But the type that I want to place over the image also resizes, which I don't want it to do. I've done this by creating a custom class, which I've attached, and then setting the size of the swf file on the page at 100%.

Any advice, help or suggestions as to how I can create a .swf file where ONLY the background expands but the rest of the content stays the same size would be greatly appreciated. Thank you very much.
TOPICS
ActionScript

Views

468

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 ,
Nov 03, 2008 Nov 03, 2008

Copy link to clipboard

Copied

I do it by getting the starting stage dimension in the constructor, and then dividing the new dimension by the starting dimension to get a percentage. Something like this where tf is your text object:

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
Explorer ,
Nov 04, 2008 Nov 04, 2008

Copy link to clipboard

Copied

Thanks, Rob. I'll give this a try and let you know how it works.

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
Explorer ,
Nov 05, 2008 Nov 05, 2008

Copy link to clipboard

Copied

Rob, thanks again for the help. When I try to run this code I'm getting the following error (repeated for times, one for each use of the tf):

My StageTwo.as, Line 37
1120: Access of undefined property tf.

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 ,
Nov 05, 2008 Nov 05, 2008

Copy link to clipboard

Copied

LATEST
You have a parameter for the _mc sprite, which I assume references a sprite on the stage so that you can scale it. If you want to reference other objects on the stage to move or scale, you'll need to add parameters for those objects (my tf is just an invented object). If you are trying to move around lots of objects you could reference them via getChildAt() rather than adding parameters for each object.

For example if _mc is the only thing on the stage, you could eliminate the parameter and refer to it as: this._mc=getChildAt(0);

If there's another sprite above it, then add a variable something like:
private var tf:Sprite;

and in the constructor:
tf=Sprite(getChildAt(1));

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