Full screen Flash control for AS2 and AS3

Source: Internet
Author: User

How to implement full screen control of Flash Player 9 Update 2, I will provide 2 versions, the first version is AS2, and the second version is AS3. Interestingly, many of my friends who can write the AS2 file have difficulty writing The AS3 file, which may be difficult to adapt to changes in syntax and production methods.
AS2 full screen playback control:
The AS section on the buttons in the scenario:

On (press ){
ToggleFullScreen ();
}


The first frame of the timeline:

// Button on Press triggers the toggleFullScreen function
Function toggleFullScreen (){
If (Stage ["displayState"] = "normal "){
Stage ["displayState"] = "fullScreen ";
} Else {
Stage ["displayState"] = "normal ";
  }
}


After Shift + F12 is released, change the value of all allowFullScreen parameters in html to true. Remember.
Download source files and effect packages
AS3 version:
Create an Empty Fla and AS3 file mode. save the file name AS3FullScreen. fla
Create a FSButton. as file with the following code:

Package {
Import flash. display. Sprite;
Import flash. display. Stage;
Import flash. events. MouseEvent;
Public class FSButton extends Sprite {
Public function FSButton (){
Var navBtn1: AS3FullScreen = new AS3FullScreen ();
This. addChild (navBtn1 );
NavBtn1.x = 200;
NavBtn1.y = 200;
NavBtn1.addEventListener (MouseEvent. CLICK, goFullScreen );
    }
Function goFullScreen (event: MouseEvent): void {
Switch (stage. displayState ){
Case "normal ":
Stage. displayState = "fullScreen ";
Break;
Case "fullScreen ":
Default:
Stage. displayState = "normal ";
Break;
      }
    }
  }
}


In the Document attributes of the AS3FullScreen. fla scenario, enter FSButton in the Document Class column.
Shift + F12 output, change the value of all allowFullScreen parameters in html to true. Remember.
AS3FullScreen.rar

I was surprised that the AS2 version only has 10 K, and the Fla file of AS3 has 350 k. Why is it that I was lazy and created an AS3FullScreen class, in FSButton, a better way is to write a Sprite object. During initialization, set the buttonMode attribute of this sprite object to true. But there are more code, which is not suitable for AS2's friends. Although my Fla has 350 k, my SWF is only about 2 k. It turns out that, the SWF compilation optimization of AS3 is still very powerful. The code can be reused, and the component can be reused.

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.