SWF Adaptive Layout

Source: Internet
Author: User
When we develop a full-site Flash application, we want to present a Flash that is full of browser screens. flash with full browser screen can be implemented by setting the width and height in the reference Flash parameter to 100%. however, this is not enough because the internal interface Department of Flash is not so intelligent (it refers to non-FLEXPROJECT, such as ActionScr

When we develop a full-site Flash application, we want to present a Flash that is full of browser screens. flash with full browser screen can be implemented by setting the width and height in the reference Flash parameter to 100%. however, this is not enough because the internal interface Department of Flash is not so intelligent (it refers to non-FLEX projects, such as ActionScr

When we develop a full-site Flash application, we want to present a Flash that is full of browser screens.

Flash with full browser screen can be implemented by setting the width and height in the reference Flash parameter to 100%. however, this is not enough because the internal interface Department of Flash is not so intelligent (it refers to a non-flex project, (For example, the Project that is compiled with Flash IDE ). today, users' browser resolutions are mainly 1024*768 and 1280*1024, and some foreigners use very large browsers:

If you want your Flash application to have a good page display in front of many users, you need some code to help.

Note that there is an Event. RESIZE Event in AS3, which is triggered when the Flash size changes... AHA, and the answer is found ;)

Let's take a look at the implementation code. The following code is written in the main class:

// 4. init screen size adjust
Private function initScreenAdjust (): void
{
// Set Scale Mode, Set the zoom Mode to No zoom
Stage. scaleMode = StageScaleMode. NO_SCALE;

// Set Screen adjust event to Set Screen Scaling
Stage. addEventListener (Event. RESIZE, screenAdjust );

// Call the interface adjustment at the beginning of the program

ScreenAdjust (null );
}

// 4.1 Adjust Sample instance
Private function screenAdjust (evt: Event): void
{

// UIData. SCREEN_WIDTH and UIData. SCREEN_HEIGHT indicate the compiled Flash width and height.

// You can set it in the format of [SWF (width = "1024", height = "768"] (FLEX), or directly set it in FLASH IDE
Var offX: int = Math. floor (UIData. SCREEN_WIDTH-stage. stageWidth)/2 );
Var offY: int = Math. floor (UIData. SCREEN_HEIGHT-stage.stageHeight)/2 );

// This refers to the main class. For the reason for this, see
This. x = offX;
This. y = offY;

// Internal UI adjustment. Here the adjustment is a Y value in the lower toolbar.
MDownToolBar. y = stage. stageHeight-UIData.DOWN_BAR_OFF_Y;

}

The relationship between the coordinate value of the Flash main class and the height of the stage width is displayed. The adjustment here is to always paste the upper left corner of the Flash main class to the upper left corner of the current Flash Player, regardless of the size change.

In fact, I only provide a scheme to adjust the interface. Sometimes, you may want the main class Bureau to make everything look at your needs.

A simple example program address can be used to adjust the browser size to observe the Layout Change of the interface: Video is always centered; the top and bottom toolbar are located on both the top and bottom sides, respectively (the code is very easy, the main content above has been pasted, so no code is attached)

Http://www.xia108.com/labs/rapidFlashDev/chp2.solution/2.2.1FullScreen/index.htm

Paste a practical application. The performance of my six-degree topology in different browsers and advertisement ;)

1024*768

1280*1024

Article from: Flash client (www.flashas.net) Detailed reference: http://www.flashas.net/asbc/20090115/3900.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.