{code type=codetype}
<param name="allowFullScreen" value="true" />
{/code}
The first thing to do is create a button and add the following code to it:
{code type=codetype}
- on(press){
- toggleFullScreen();
- }
{/code}
The code for the function toggleFullScreen and a resize listener are placed on the main stage.
{code type=codetype}
- //Don't scale the movie when the stage size changes
- Stage.scaleMode="noScale";
- //Align the stage to the top left
- Stage.align = "TL";
- //Function to toggle between fullscreen and normal size
- //the toggle fullscreen button calls this function when pressed
- function toggleFullScreen(){
- //if normal size, go to fullscreen, else go to normal size
- if(Stage["displayState"]=="normal"){
- Stage["displayState"]="fullScreen";
- }else{
- Stage["displayState"]="normal";
- }
- }
- //Create a listener for each time the Stage is resized
- var resizeListener:Object = new Object();
- //Called each time the stage is resized
- resizeListener.onResize = function () {
- //Move the button to the center of the screen
- toggleFullScreenButton._x=Stage.width/2;
- toggleFullScreenButton._y=Stage.height/2;
- }
- //Add the listener to Stage
- Stage.addListener(resizeListener);
{/code}
Example XHTML used for this applet:
{code type=codetype}
<object data="http://www.tutorialspalace.com/wp-content/uploads/tuts-flash/flash-fullscreen/flash-fullscreen.swf" type="application/x-shockwave-flash" width="400" height="200" >
<param name="movie" value="http://www.tutorialspalace.com/wp-content/uploads/tuts-flash/flash-fullscreen/flash-fullscreen.swf" />
<param name="allowFullScreen" value="true" />
</object>
{/code}
The balls were added in to show that the stage extends to the borders of the screen, even when resized.
Thanks for sharing code
ReplyDeleteuseful tips and tricks.
ReplyDeletethis is awesome man
ReplyDelete