Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language.

Similar presentations


Presentation on theme: "1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language."— Presentation transcript:

1 1 Flash Programming Introduction Script Assist

2 2 Course Description This course concentrates on the teaching of Actionscript, the programming language used primarily for the development of websites and software using the Adobe Flash Player platform. Lecturer: Nina Bresnihan Room 3.4, 8 Wsq Nina. Bresnihan@cs.tcd.ieBresnihan@cs.tcd.ie http://www.cs.tcd.ie/Nina.Bresnihan

3 3 Course Aim & Learning Outcome Students will be introduced to the fundamentals of Actionscript programming. They will become familiar with its structure and syntax and how it interfaces with the Flash software.

4 4 Topics Covered 1. Script Assist 2. Variables 3. Objects Properties Methods Events and Event handling 4. Control Structures Sequence Selection Iteration

5 5 Topics Covered 6. Arrays 7. Animation 8. Organising your Code 9. Writing Class Files 10. Working with MovieClips Controlling Playback Creating Dynamically 11. Flash and the Web

6 6 What is Actionscript? ActionScript lets you add interactivity to a movie. ActionScript provides elements, such as actions, operators, and objects, that you put together in scripts that tell your movie what to do; You set up your movie so that events, such as button clicks and key presses, trigger these scripts. E.g., you can use ActionScript to create navigation buttons for your movie.

7 7 Writing ActionScript with Script Assist For users who are new to ActionScript, or for those who want to add simple interactivity without having to learn the ActionScript language and its syntax, you can opt to use Script Assist to help you more easily add ActionScript to your Flash documents.

8 8 About Script Assist Script Assist lets you build scripts by selecting items from the Actions toolbox, the list on the left side of the Actions panel. When you click an item once, its description appears at the upper right of the panel. When you double-click an item, it adds the item to the Actions panel Script pane.

9 9 About Script Assist You can add, delete, or change the order of statements in the Script pane; You can enter parameters for actions in text boxes above the Script pane. Script Assist also lets you find and replace text, and view script line numbers.

10 10 Using Script Assist to Add Interactivity To follow along with this lab, you will need the following file: Sample file (ZIP, 0.3 MB)

11 11 Using Script Assist to Add Interactivity 1. In Flash, choose File > Open and open the scriptAssist.fla file. Select the content layer in the Timeline. This layer contains a movie clip with the instance name Bottle. 2. Click the padlock icon at the top of the Timeline to unlock all of the layers. 3. Double-click the Stage to open the movie clip in document-editing mode.

12 12 Using Script Assist to Add Interactivity 4. Notice the Timeline contains an FLV file, or Flash video file, that's been imported into the movie clip. Click and drag the playhead over the Timeline to preview the video.

13 13 Using Script Assist to Add Interactivity 5. Click the Scene 1 link in the edit bar to return to the main Stage. 6. Choose Control > Test Movie or press Ctrl/Cmd and Enter to export a test version of the movie. 7. Notice the animation begins as soon as the movie starts. You'll add a button the user has to click to see the animation. 8. Close the Movie window.

14 14 Using Script Assist to Add Interactivity 9. Choose Window > Library to open the Library panel. A simple button has already been created, called startButton. 10. Drag an instance of the symbol onto the Stage, and position it in the bottom right corner. Now you need to give the button an instance name so that it can be called out in ActionScript.

15 15 Using Script Assist to Add Interactivity 11. Choose the Property inspector and type startButton for the Instance Name. You're ready to write the ActionScript. Don't worry; you're not actually going to be writing code. That's where the Script Assist feature comes in… 12. Go to the Timeline and lock the Content layer. Select the first keyframe in the Actions layer. 13. Choose Window > Actions to open the Actions panel

16 16 Using Script Assist to Add Interactivity

17 17 Using Script Assist to Add Interactivity 14. Examine the Actions panel. The left pane is referred to as the Actions toolbox, and contains all the class libraries. You navigate through each library to access the individual classes, and their associated methods and properties. You can add them to your ActionScript by dragging them into the code pane. The Actions toolbox is designed to work with the Script Assist feature. You'll use these two features together to build the ActionScript for this movie.

18 18 Using Script Assist to Add Interactivity 15. Click the Script Assist button. The first thing you want to add is code to stop the animation the movie clip named Bottle from playing automatically when the movie starts. Knowing that the animation is a movie clip is important when you're determining and finding the class in the Actions toolbox. Script Assist assumes some basic knowledge of ActionScript for you to be able to create these scripts. In this case, you need to know that movie clips reside in the flash.display package.

19 19 Using Script Assist to Add Interactivity 16. Double-click flash.display to open this library. 17. In the Actions toolbox, navigate down to Movie Clip/Methods. Several methods are listed, including a method called stop. 18. Double-click stop to insert the stop command into the panel. It includes the phrase " not_yet_set " to indicate that you have not yet supplied the command a reference to a movie clip.

20 20 Using Script Assist to Add Interactivity Meanwhile, an input field opens in the Script Assist pane, labelled Object. Remember, the movie clip you want to stop is called Bottle.

21 21 Using Script Assist to Add Interactivity 19. For Object, type bottle. You've just written your first piece of ActionScript code. The next thing you need to do is set the Mouse Down event for the button, a transition event that calls another line of code when the button is clicked. Once that event is triggered, the movie will start. To set mouse events in ActionScript 3.0, you must use the event listener method.

22 22 Using Script Assist to Add Interactivity 20. Find this method in the flash.events package, under the IEventDispatcher class. Navigate down to the Methods list and double- click addEventListener. The addEventListener is automatically added to the Actions panel. Several different input fields open in the Script Assist pane to let you set up the addEventListener method.

23 23 Using Script Assist to Add Interactivity

24 24 Using Script Assist to Add Interactivity 21. For Object, type startButton. This is the object that listens for the Mouse Down event. Next, you'll specify the kind of event that the listener listens for using the Type input field. 22. To find a mouse event, go to the Actions toolbox and navigate down to flash.events > Mouse Events > Properties.

25 25 Using Script Assist to Add Interactivity 23. Select the Actions panel to re-open Script Assist, and insert your pointer in the Type text box. Double-click MOUSE_DOWN to select it and add the necessary code to the Actions panel. The next input field for the addEventListener is listener. This is the function you want the listener to call when triggered.

26 26 Using Script Assist to Add Interactivity 24. Type startClip. You'll create a function under this name in the next few steps. 25. Notice the brackets around the field names, indicating that the rest of the parameters in the Script Assist pane are optional. Now it's time to create the startClip function.

27 27 Using Script Assist to Add Interactivity 26. Go to the Actions toolbox and navigate down to Language Elements > Statements, Keywords and Directives > Definition Keyword. Double-click function to insert the code in the Actions panel. This opens a new set of input fields in the Script Assist pane.

28 28 Using Script Assist to Add Interactivity

29 29 Using Script Assist to Add Interactivity 27. For Name, type startClip. This is the function name you listed in the event listener. When you use the addEventListener with mouse events, it sends an event object to the function. You need to add this event object to the parameters for the function. 28. For Paramerters, type e:MouseEvent. 29. Now you need to add the code to start the bottle movie playing.

30 30 Using Script Assist to Add Interactivity 30. Click the Script Assist button again to return to the regular editing mode.Insert your cursor on Line 4 before the closing function brackets- }. 31. Go to the Actions toolbox and choose flash.display > MovieClip > Methods. Double-click play to insert the code in the Actions panel. 32. Replace not_yet_set with bottle. Insert a semi- colon after the closing parentheses - ). You have finished the code.

31 31 Using Script Assist to Add Interactivity

32 32 Using Script Assist to Add Interactivity To recap, the first piece of your code stops the movie from playing automatically. The second creates the mouse down event for the start button, which, when triggered, calls the next piece, the startClip function which plays the movie clip. 33. Choose Control > Test Movie to check your work. Script Assist is really helpful when you're familiar with object names and classes, but you are not so sure about the syntax and required parameters for methods and classes.


Download ppt "1 Flash Programming Introduction Script Assist. 2 Course Description This course concentrates on the teaching of Actionscript, the programming language."

Similar presentations


Ads by Google