|
|
Fairly standard I was about 95% complete just adding some minor delete functionality when the server crashed. |
First, the ActionScript language dictates that you can only use certain characters in your variable name. These are any alpha-numeric characters (letters and numbers), the underscore and the dollar sign. Any other character (hyphens, the space, the period, etc) is not allowed. Usually this is because many other characters have special significance in ActionScript.
|
|
Creating a variable is called a declaration. Variables can be set, accessed and updated anywhere in a Flash movie. They can be set any place a user can attach code on a frame, a button, or a movie clip using the action Set Variable or by values entered in a text field. Once set, the variable and its value exist in the timeline that they were set in. In other words, if a variable is set inside the main timeline, its name and value do not exist as such in other timelines, including movie clips and loaded movies. Variables set inside one timeline are not directly accessible to the scripts on other timelines, yet they are indirectly accessible. To create, retrieve, or assign a variable on a separate timeline we address the path where the variable located using dot syntax. Dot syntax is a standard notation common to object-oriented programming languages such as JavaScript. This path addressing is similar to using the With or Tell Target action for targeting objects in a Flash movie. Variables inside instances of movie clips are specified with the dot syntax instanceName.variableName, as explained on page 38 of the Flash 5 ActionScript Reference Guide. |
|
Start making 2 keyframes and place “stop();” into both of them. Then make 3 textboxes and one button, 2 text boxes is input, and one is dynamic, set one of the input text to password, and set the var. to “pw” , then set the username field var. to “usern”, and the dynamictext var. to “output”. then insert this code into the button: |
|
You should now be able to type in the in the input text field and click the button os it will pars the text into the movie clip.
|
|
|
|
Flash on the beach 2009 - Day 1 |
|
Now let's make a plus button and a minus button which will change the variables. If you need help with buttons, try our first buttons tutorial.
|
|
|
|
|
This won't work, unfortunately. The problem is with how we reference the variable. someVar is referencing only the SWF file it is inside - even though the SWF is a symbol from A point of view! |
One should not underestimate the benefits of strict data types, they do not only prevent you from assigning an incompatible data type and make error correction much easier, but they also make your code much easier to read because as the intended purposes of the variables that you create become clearer and easier to follow. A great other benefit of using Strict Data Typing is that variables to which this feature is enabled activate ActionScript quick reference code hints that pop-up when the variable name is written in ActionScript. |
After you click the Submit button above, then form.html will be opened. The Address/URL bar will look like below: This Flash movie contains two textboxes. The top one will print the value of _root.UserName, the bottom one will print the value of _root.CompanyName. These variables are retrieved from the query string. You can see how the query string is passed later in this tutorial.
|
|
|
|
|
|
2. Next, draw a text object in the top-left corner of your movie. Open the Text panel and set this next text object to 'Dynamic' (if 'Static' or 'Input' is displayed on the text panel underneath the Font Type, click it and select 'Dynamic' instead). Be sure to embed all characters of your chosen font by clicking on the "ABC|123" icon and choosing "Embed Font Outlines for: All Characters". In the Name field on the Text panel, give this text object the name "myButton" and set it to be used as a target. You can add text to decide what font you'd like to use; however, be sure to delete all text on the Text panel and leave this text object empty (as shown in the image below).
|
There are several methods of passing variables to a flash program. The first method that I used, passed the variables via the HTML tag value. |
7. Draw another input text field to the right of the "Hello" text field with the same variable name "your name". |
But why? Why would you want to use variables in a flash animation? Well, let's say you want to make a game. And the point of the game is to get out of a room. The only problem is that the door is locked. But the key is somewhere in the room. |
There are several methods of passing variables to a flash program. The first method that I used, passed the variables via the HTML tag value. |
In my case, I have named my working .fla file "passvariables", so my .swf file and my html file both share this name. Yours will be dependant on what you named your file originally. |
|