?
Solved

Flash: Full Screen Button ?

Posted on 2007-08-06
3
Medium Priority
?
3,048 Views
Last Modified: 2008-01-09
this should be simple...but im not very familiar with Flash development.

I have the Full Screen functionality working for my SWF.. but I can't get a Button to control the Full Screen functionality.

Actions layer:
===============

// functions to enter and leave full screen mode
function goFullScreen()
{
   Stage["displayState"] = "fullScreen";
}

function exitFullScreen()
{
   Stage["displayState"] = "normal";
}

// function to enable, disable context menu items, based on which mode we are in.
function menuHandler(obj, menuObj)
{
   if (Stage["displayState"] == "normal")
   {
      // if we're in normal mode, enable the 'go full screen' item, disable the 'exit' item
      menuObj.customItems[0].enabled = true;
      menuObj.customItems[1].enabled = false;
   }
   else
   {
      // if we're in full screen mode, disable the 'go full screen' item, enable the 'exit' item
      menuObj.customItems[0].enabled = false;
      menuObj.customItems[1].enabled = true;
   }
}

// create a new context menu
var fullscreenCM:ContextMenu = new ContextMenu(menuHandler);

// hide the regular built-in items
fullscreenCM.hideBuiltInItems();

// now, add the items to enter and leave full screen mode
var fs:ContextMenuItem = new ContextMenuItem("Go Full Screen", goFullScreen);
fullscreenCM.customItems.push( fs );

var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen", exitFullScreen);
fullscreenCM.customItems.push( xfs );


// now, attach the context menu to any movieclip in your movie.
// here we attach it to _root, (even though using _root is generally a bad idea,)
// so it will appear if you right click anywhere on the movie.
_root.menu = fullscreenCM;
0
Comment
Question by:n8dog
  • 2
3 Comments
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 19643198
in your code, fullScreen and exitfullscreen are working through contextMenu..
your code add two buttons in contextMenu to handle this fucntionality

if you want to do it using buttons, you can do it as follwoing:

1.
create two buttons in same movieClip where this code is written,

2.
assign instance names to the buttons as;   fullscreen_btn , exitfullscreen_btn

3.
Now add following code in same frame where above code is written.

------------
fullscreen_btn.onPress = function()
{
  goFullScreen();
}
exitfullscreen_btn.onPress = function()
{
 exitFullScreen();
}
-------------


4.
and if you want to remove context menu items for full screen functionality..
just remove following code:

/////////////////////
// now, add the items to enter and leave full screen mode
var fs:ContextMenuItem = new ContextMenuItem("Go Full Screen", goFullScreen);
fullscreenCM.customItems.push( fs );

var xfs:ContextMenuItem = new ContextMenuItem("Exit Full Screen", exitFullScreen);
fullscreenCM.customItems.push( xfs );


// now, attach the context menu to any movieclip in your movie.
// here we attach it to _root, (even though using _root is generally a bad idea,)
// so it will appear if you right click anywhere on the movie.
_root.menu = fullscreenCM;
//////////////


-------------------
Aneesh Chopra
-------------------






0
 

Author Comment

by:n8dog
ID: 19643701
very cool.. for some reason my syntax wasn't working when i tried it..

thanks dude! i have some flash to learn :)

0
 

Author Comment

by:n8dog
ID: 19643765
is there some way to make it smaller? the SWF i mean - because its 103K !! and a player is only 3K
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question