Presentation is loading. Please wait.

Presentation is loading. Please wait.

XP Tutorial 8 Adding Interactivity with ActionScript.

Similar presentations


Presentation on theme: "XP Tutorial 8 Adding Interactivity with ActionScript."— Presentation transcript:

1 XP Tutorial 8 Adding Interactivity with ActionScript

2 XP New Perspectives on Macromedia Flash MX 2004 2 Programming with ActionScript ActionScript is a robust programming language that gives the Flash developer an almost unlimited number of ways to make a Flash document interactive. ActionScript can also be used to write complete programming applications such as a shopping card application in which the user can enter data, make selections, and then make a purchase.

3 XP New Perspectives on Macromedia Flash MX 2004 3 Programming with ActionScript Input fields Make selections here

4 XP New Perspectives on Macromedia Flash MX 2004 4 Working with Objects and Properties ActionScript is used to control and modify objects. An object is an element in Flash that has properties or characteristics that can be examined or changed with ActionScript. Working with objects in ActionScript often requires that you assign names to them.

5 XP New Perspectives on Macromedia Flash MX 2004 5 Working with Objects and Properties

6 XP New Perspectives on Macromedia Flash MX 2004 6 Using Actions, Methods, and Functions An action is a statement that instructs a SWF file to do something. Functions are blocks of statements that process information and return a value or perform some action. The values you send to a function are called parameters or arguments and are enclosed in parentheses. Methods are functions specific to a particular object.

7 XP New Perspectives on Macromedia Flash MX 2004 7 Writing ActionScript Using Variables, Expressions, Operators, and Comments A variable is a container that holds information while the SWF file s playing. A keyword is a word or phrase that already has a specified use or meaning in ActionScript and cannot be reused in another context in a statement. An expression is a statement that is used to assign a value to a variable. String data is a series of characters, such as letters, numbers, and punctuation, and is always enclosed in quotation marks.

8 XP New Perspectives on Macromedia Flash MX 2004 8 Writing ActionScript Using Variables, Expressions, Operators, and Comments Numeric data is a number or numbers that are not enclosed in quotes. Operators are used in expressions to tell Flash how to manipulate the values in the expression. –The equal sign is an example of an assignment operator –ActionScript also has arithmetic operators, such as +, -, *, and / –A comparison operator is used in conditional statements –A conditional statement is one in which one value is compared to another. Comments are notes within the ActionScript code that explain what is happening.

9 XP New Perspectives on Macromedia Flash MX 2004 9 Comments Comment in Script Pane

10 XP New Perspectives on Macromedia Flash MX 2004 10 Writing ActionScript Code When writing ActionScript code, you need to follow certain rules, known as the syntax of the language.

11 XP New Perspectives on Macromedia Flash MX 2004 11 Linking to Web Sites Using the getURL() Function The getURL() function loads a document such as a Web page into a browser window. The format is getURL(url, window) –url is the address of the Web site you want to open in the browser window –The argument window can be one of several options

12 XP New Perspectives on Macromedia Flash MX 2004 12 The window Argument _ self —Specifies that the Web site document be opened in the current browser window; this replaces the currently displayed document _ blank —Specifies that the Web site document be opened in a new browser window; the currently displayed document remains opened in its own browser window _ parent —Specifies that the Web site document be opened in the parent of the current frame; this applies when you are using frames to display your Web site; frames split the browser window into more than one window and allow you to display several Web documents at one time _ top —Specifies that the Web site document be opened in the top- level frame in the current window; this applies when you are using frames to display your Web site

13 XP New Perspectives on Macromedia Flash MX 2004 13 getURL() Function get URL ( ) function arguments

14 XP New Perspectives on Macromedia Flash MX 2004 14 Creating an Input Form An input form is a common element found on many Web sites on the Internet. An input form allows the user to enter data into input fields. A page developed with Flash can allow the user to enter data, have the data processed, and return a result directly from the Flash Player on the user’s computer.

15 XP New Perspectives on Macromedia Flash MX 2004 15 Using Dynamic and Input Text Static text cannot be changed after the document plays in the Flash Player. Dynamic text can receive text in the form of characters or numbers from a Web server or from an expression in ActionScript and display the text on a Web page in the Flash Player.

16 XP New Perspectives on Macromedia Flash MX 2004 16 Using Dynamic and Input Text

17 XP New Perspectives on Macromedia Flash MX 2004 17 Dynamic Text Options Refer to figure 8-16 in your text for a summary of Dynamic Text Options including:  Instance Name text box  Line type list box  Selectable button  Render text as HTML button  Show border around text button  Variable text box  Edit characters options button

18 XP New Perspectives on Macromedia Flash MX 2004 18 Input Text Input text is used to allow the user to enter text into the text block. This text can then be stored in a variable and used in an ActionScript script. To create an input text block, use the Text tool and select Input Text from the Text type list box in the Property inspector.

19 XP New Perspectives on Macromedia Flash MX 2004 19 Options for Input Text Text type list box Maximum Characters Allowed text box

20 XP New Perspectives on Macromedia Flash MX 2004 20 Using a Flash Preloader A SWF file is downloaded over the Internet from a Web server to the user’s computer, known as the client computer. A major factor that affects the amount of time it takes a file to download is the size of the file, measured in kilobytes. –A kilobyte is approximately 1000 bytes. –A byte is equivalent to one character of information.

21 XP New Perspectives on Macromedia Flash MX 2004 21 Using a Flash Preloader Flash files are streaming, which means that as the file is downloading, the initial content can start playing while to rest of the content continues to be downloaded. Flash developers usually add a preloader, which is a short animation or message located in the first few frames of the Flash file. The preloader typically contains a short animation and the word “Loading” to indicate to the site visitor that the Web site is still loading.

22 XP New Perspectives on Macromedia Flash MX 2004 22 Sample Preloaders

23 XP New Perspectives on Macromedia Flash MX 2004 23 Preloader Logic The pseudocode for the preloader logic is as follows: –Get the total number of bytes –Get the number of bytes loaded –If the number of bytes loaded equals the total number of bytes Play the rest of the SWF file else continue playing the preloader animation

24 XP New Perspectives on Macromedia Flash MX 2004 24 Preloaders


Download ppt "XP Tutorial 8 Adding Interactivity with ActionScript."

Similar presentations


Ads by Google