A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11337 Flash Movies | 1 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Bugra Ozden
» Title: Skatalog v9 - product catalog
» Description: Create your product catalog easly and publish on your website or Create your image gallery, documents list, portfolio. Fully XML Driven
» More by Bugra Ozden


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5828 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Creative DW Image Show PRO
» Description: Creative DW Image Show PRO is a Dreamweaver extension which enables the user to create multimedia presentations. It combines the features of the popular Creative DW Image Show with the ability to add professional text effects to slides (similar to After Effects). The product is very customizable: the user can choose the duration of the transition effects, the slide motion start and end position, zoom and panning type for both images and texts.


Random Links | Add your own Flash Related Links
Flash Tutorials 1280 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make a Flash Slide Show Screen Saver
» Simple flash making tutorial for thanksgiving
» Create flash banner for website
» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Interactivity

Categories Accessing Multiple Buttons in UI Components #2 Message Box
Author: Thomas Watson | Website: http://hikercentral.net |

 
Page 2
«prev 1 2

Accessing Multiple Buttons in UI Components #2 Message Box

Next, just for fun, drag a "Push Button" onto the stage from the "Components" Panel. Open it's "Properties" Panel and give it an instance name, and make up a "Click Handler" name. I named my instance "myButton", labeled it "Try Again", and called the "Click Handler" "tryButton."

Now unlock the message box, and un-hide it. The images on your stage should look something like this.

Our dynamic text field is underneath the message box, but will become visible when the box closes. The box will close as soon as a button is clicked as part of it's "Close Handler" function.

By default, the message box starts off with a _visible property of true meaning the box is visible on the screen. This makes it easy to get rid of the box and bring it back just by changing it's _visible property-- no shuffling it off and on the screen, no switching back and forth between frames. In most cases in a "real" application you will probably start with the box hidden-- that is with it's property set to false.

Everything else we need to take care of to make this work is in the "Close Handler" function, so let's go take a look at that. First we want to "close" the box by changing it's _visible property to false.

Now the tricky part. I won't go into everything I went through or everything I did or didn't discover along the way, but will pretty much stick to the basics here. From what notes there are on this component and from digging through the debugger, I did discover that the buttons are all stored in an array, and each entry in this array gets a corresponding movie clip of the button component. Flash names the movie clips "buttons_mc" plus the array index of the button. Flash actually stacks these components together to make a single unit. Reading through the debugger also told me that these buttons had a "state" that could be read. The "state" indicates if the button as been clicked or not, and is expressed as either true or false.

So the first if block has the condition of checking the first button-- button "0" (remember this is an array that starts numbering with "0")-- to see if it's state is true -- meaning "has it been clicked or not?" If it has been clicked, we set the text of our dynamic text box to "Yes", corresponding to the first button in our set. The second statement in that if block sets the state of the button back to it's unclicked state-- false. You must be sure and reset the button state-- it does not automatically reset.

The other two if blocks simply repeat these actions, testing the other two buttons.

I did say I wouldn't go into everything I discovered about this but one piece of information that could be useful in some cases, is that Flash will return two parameters to the "Close Handler" function like so: myCloseHandler(messageBox, buttonIndex). However, for this particular situation, I didn't find that helpful. I only have one message box, so I don't need the instance name, which you might need if you have more than one box and wish to write a generic handler for them. Also, unless you only call the box once, you still have to reset the state of the buttons, which you have to do using the method show here. I could not find a method that would reset the button using only the button index. Not resetting the buttons after each use could lead to unpredictable results, since the state of more than one button would be true. However, there are some situations where this could be useful information.

One last piece of business is to add a function that is out "Click Handler" for the "Try Again" button. Pretty simple stuff here-- just make the window visible again and clear the text in the dynamic box.

Use Control->Test Movie to run this. Click a button and the message box closes, showing the name of the button you clicked on the screen, demonstrating that we actually captured the button click correctly. Enjoy!

«prev 1 2

» Level Intermediate

Added: : 2002-05-17
Rating: 7.32 Votes: 12
Hits: 2072
» Author
Tom Watson is a Flash developer currently residing in Nashville, Tennessee. He's been an independant contractor in the computer business since 1989, working on web projects since the web was introduced to the Internet in 1994.
» Download
Download the files used in this tutorial.
Download (106 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs