logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
Painting
Heart Disease
Horror Literature
Dating
Hiking & Backpacking
SF/Fantasy Books
Healthy Foods


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g Flash and Animation Site

BellaOnline's Flash and Animation Editor

g

ActionScript Visible Property to Toggle Menu


In the past few Flash tutorials, we have created the toggle button and the if statement for the Flash Storybook Menu Overlay. As we discussed, the PositionSetMenu function uses the if statement to determine where FlashR will place the Menu Overlay when the toggle button is clicked, depending on the value of the showMenu variable.

function PositionSetMenu(event:MouseEvent):void {

if(showMenu)
{
moveSetMenuDown();
}
else
{
moveSetMenuUp();

}
// Toggle whether you want to load or unload the menu
showMenu = !showMenu;

}

Now we will examine the code for the moveSetMenuDown and moveSetMenuUp functions. Our first step is to discuss the visible property for a movie clip. This property is a Boolean, which means that it has only two values - true and false. As the name indicates, this property determines if the movie clip is visible on the stage. Also, if a movie clip is invisible on the stage, it is disabled and cannot be clicked. We will manipulate this property for each element on the Menu Overlay, which are the background (setMenuBg), button link to the credits page (creditsBtn), toggle button for the background music (musicBtn), button link to the index page (indexBtn), hyperlink to the app's supporting website (websiteBtn) and button link to "our other apps" page (moreAppsBtn).

When we run the moveSetMenuDown function to display the Menu Overlay over the existing page, we will set the visible property for each element to true. Of course, when we run the moveSetMenuUp function, we will set the visible property to false.

You might ask: If we are setting the visibility of the Menu Overlay to false, why do we bother to remove it from the stage. Although it may be invisible on the stage, Flash will still "draw" the Menu Overlay for each frame that it is on the stage. To save on processing during those times when we don't need the menu, we can remove the menu from the stage.

When the app first loads, the Menu Overlay is off the stage. So let's initially set the visible property for each element in the menu to false.

setMenuBg.visible = false;
creditsBtn.visible = false;
musicBtn.visible = false;
indexBtn.visible = false;
websiteBtn.visible = false;
moreAppsBtn.visible = false;

Our next step is to code the moveSetMenuUp function. As you can see from the code below, when this function is called, we will set the X and Y positions and the visible property for each element. We will discuss the removeListeners function in a future tutorial.

function moveSetMenuUp():void {
setMenuBg.x = 0;
setMenuBg.y = -785;
setMenuBg.visible = false;
creditsBtn.x = 486;
creditsBtn.y = -606;
creditsBtn.visible = false;
musicBtn.x = 285;
musicBtn.y = -606;
musicBtn.visible = false;
indexBtn.x = 88;
indexBtn.y = -611;
indexBtn.visible = false;
websiteBtn.x = 340;
websiteBtn.y = -316;
websiteBtn.visible = false;
moreAppsBtn.x = 709;
moreAppsBtn.y = -603;
moreAppsBtn.visible = false;

removeListeners();
}

function moveSetMenuDown():void {
setMenuBg.x = 0;
setMenuBg.y = 0;
setMenuBg.visible = true;
creditsBtn.x = 486;
creditsBtn.y = 178;
creditsBtn.visible = true;
musicBtn.x = 285;
musicBtn.y = 178;
musicBtn.visible = true;
indexBtn.x = 88;
indexBtn.y = 173;
indexBtn.visible = true;
websiteBtn.x = 340;
websiteBtn.y = 468;
websiteBtn.visible = true;
moreAppsBtn.x = 709;
moreAppsBtn.y = 181;
moreAppsBtn.visible = true;

loadListeners();

}

Next →


Join us in the Flash forum. | Join us in the Digital Art and Design forum.

|


Add ActionScript+Visible+Property+to+Toggle+Menu to Twitter Add ActionScript+Visible+Property+to+Toggle+Menu to Facebook Add ActionScript+Visible+Property+to+Toggle+Menu to MySpace Add ActionScript+Visible+Property+to+Toggle+Menu to Del.icio.us Digg ActionScript+Visible+Property+to+Toggle+Menu Add ActionScript+Visible+Property+to+Toggle+Menu to Yahoo My Web Add ActionScript+Visible+Property+to+Toggle+Menu to Google Bookmarks Add ActionScript+Visible+Property+to+Toggle+Menu to Stumbleupon Add ActionScript+Visible+Property+to+Toggle+Menu to Reddit



 



RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the Flash and Animation Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2013 by Diane Cipollo. All rights reserved.
This content was written by Diane Cipollo. If you wish to use this content in any manner, you need written permission. Contact Diane Cipollo for details.

g


g features
Ken Burns Effect In Motion - Record Keyframes

Ken Burns Effect In Motion 5 - Set Up

Animated Title in Motion

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2013 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor