Flash Independent Study with Shawn Towne: Assignment I (build interactive map)
Posted February 13th, 2008 in Flash Actionscripting, How To, Independent Study, Web Development
In the attached Fla you will see three shapes on the stage. Each shape has been defined as a simple button (using a movie clip would also work) and given both an over state within the button and an instance name in the properties window (Select the object to see the instance name in the properties window). Each of these buttons would represent a US state within your map.
Here is one example as to how you might author the AS for these buttons (see attached, AS is located in frame 1 of the main timeline). I understand that you are just starting out so what I am about to say might not make sense so do your best and ask as many questions as you wish… also please excuse any grammar etc.. as I wanted to get this out asap.
First we would assign a function for each button. The function goes in the timeline. Based on your problem, I have decided that upon a mouse release I will call forth a function and pass a variable of either MA, VT or NH to a function called callURL. callURL will evaluate the variable name USstate. The variable USstate has a data type of string meaning that it will only accept a string of text. Defining variables as a string, number, etc.. prevents any possible mishaps. Within the callURL function I am using a switch statement, which is similar to an if statement. I am using a switch statement for a few reasons, 1. the coding is less, 2. the statement is resolved upon match vs. having various if statements all attempting resolution and 3 easier to read. Once the switch statement has matched up the variable and outcome we then trigger the getURL(”www.website.com”); I have currently commented out the getURL code, to activate delete the //. The trace command is being used to output info to the output window so that I can debug by seeing a response from my button.

1 Comment
February 13th, 2008 at 11:09 pm
Testing the comment section
Leave a Reply