flash programming01
TRANSCRIPT
-
7/30/2019 Flash Programming01
1/31
1
Flash Programming
IntroductionScript Assist
-
7/30/2019 Flash Programming01
2/31
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 Playerplatform.
Lecturer: Nina Bresnihan
Room 3.4, 8 Wsq Nina. [email protected]
http://www.cs.tcd.ie/Nina.Bresnihan
mailto:[email protected]:[email protected] -
7/30/2019 Flash Programming01
3/31
3
Course Aim & Learning Outcome
Students will be introduced to the fundamentalsof Actionscript programming. They will becomefamiliar with its structure and syntax and how itinterfaces with the Flash software.
-
7/30/2019 Flash Programming01
4/31
4
Course Assessment
End of year Examination 75%; Assignment One5%; Assignment Two 20%.
Marked coursework will consist of twoassignments. The first will be a simpleassignment using the built-in actions in thelibrary. The second, more complex, project willtest the students knowledge of Actionscript.
The remainder of the course will be assessedby end-of-year examination
-
7/30/2019 Flash Programming01
5/31
5
Topics Covered
Include:
Script Assist
The Actions Panel
Actions and Events Variables
Control Scructures
Arrays
Animation
Functions and Methods
Working with Movie Clips
Multiple Levels and Timelines
-
7/30/2019 Flash Programming01
6/31
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 inscripts that tell your movie what to do;
You set up your movie so that events, such as
button clicks and key presses, trigger thesescripts.
E.g., you can use ActionScript to createnavigation buttons for your movie.
-
7/30/2019 Flash Programming01
7/31
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 useScript Assist to help you more easily add
ActionScript to your Flash documents.
-
7/30/2019 Flash Programming01
8/31
8
About Script Assist
Script Assist lets you build scripts by selecting itemsfrom the Actions toolbox, the list on the left side of the
Actions panel.
The Actions toolbox separates items into categoriessuch as actions, properties, and objects, and providesan index category that lists all items alphabetically.
When you click an item once, its description appearsat the upper right of the panel. When you double-clickan item, it adds the item to the scrolling list on the rightside of the panel in the Script pane.
-
7/30/2019 Flash Programming01
9/31
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 boxesabove the Script pane.
Script Assist also lets you find and replace text, and
view script line numbers,
-
7/30/2019 Flash Programming01
10/31
10
Using Script Assist to write
ActionScript
To add an action to a Flash document, you
must attach it to a button or movie clip, or to a
frame in the Timeline.
The Actions panel lets you select, drag and
drop, rearrange, and delete actions.
-
7/30/2019 Flash Programming01
11/31
11
Using Script Assist to write
ActionScript
SelectWindow > Actions. The Actions panel
appears.
Click the Script Assist button, The Actions panelenters Script Assist mode.
-
7/30/2019 Flash Programming01
12/31
12
Viewing a Description of an
Action
Do one of the following:
Click a category in the Actions toolbox to
display the actions in that category, and click
an action.
Select a line of code in the Script pane.
The description appears at the upper left ofthe Actions panel, beginning with the
Property or Event name.
-
7/30/2019 Flash Programming01
13/31
13
Adding an Action to the
Script Pane
Do one of the following:
Click a category in the Actions toolbox to
display the actions in that category, and then
do one of the following: double-click an
action, drag it to the Script pane, or right-
click and select Add to Script.
Click the Add (+) button and select an action
from the pop-up menu.
-
7/30/2019 Flash Programming01
14/31
14
Deleting an Action
Select a statement in the Script pane.
Click the Delete (-) button or press the Delete
key.
-
7/30/2019 Flash Programming01
15/31
15
Creating a startDrag/stopDrag
event using Script Assist
The following example walks you through
the process of creating a simple
startDrag/stopDrag event using Script
Assist.
When you complete this procedure, you will
have a movie clip that you can drag aroundwithin a constrained rectangle using your
computer's mouse in a published SWF file.
-
7/30/2019 Flash Programming01
16/31
16
Creating a startDrag/stopDrag
event using Script Assist
1. Create a new Flash document, and save it ascircle.fla.
2. Draw a circle on the Stage.
3. Select the circle on the Stage, and convert itinto a movie clip symbol (SelectModify >
Convert to Symbol).
-
7/30/2019 Flash Programming01
17/31
17
Creating a startDrag/stopDrag
event using Script Assist
4. In the Convert to Symbol dialog box, entercircle_mc for the name of the symbol andselect the Movie Clip behavior.
5. Click OK. Flash adds the symbol to the library,and the selection on the Stage becomesan instance of the symbol.
6. With the circle_mc movie clip still selected,enter the instance name myCircle in theInstance Name text box of the Propertyinspector.
-
7/30/2019 Flash Programming01
18/31
18
Creating a startDrag/stopDrag
event using Script Assist
7. Place the circle_mc move clip on theTimeline. To do this:
a. Select the circle_mc movie clip on the
Stage.b. Select Modify > Timeline > Distribute to
Layers. This automatically adds a layer tothe Timeline and places the circle_mcmovie clip instance on the Timeline. Itnames the new layer according to thesymbol name and places it beneath thealready existing Layer 1.
-
7/30/2019 Flash Programming01
19/31
19
Creating a startDrag/stopDrag
event using Script Assist
8. Rename Layer 1 by double-clicking its name in
the Timeline and typing the name "Actions" in
its place.
9. Select the first frame of the Actions layers.
10. SelectWindow > Actions to display the
Actions panel, and click Script Assist. The
Actions panel enters Script Assist mode.
-
7/30/2019 Flash Programming01
20/31
20
Creating a startDrag/stopDrag
event using Script Assist
11. In the Actions Toolbox, navigate toActionScript 2.0 Classes > Movie >
MovieClip > Event Handlers >
onPress, and double-click onPress. TheonPress method is added to the Actions
panel.
-
7/30/2019 Flash Programming01
21/31
21
Creating a startDrag/stopDrag
event using Script Assist
12. Click in the Object text box, and click the
Target Path button.
13. Click the Target path button. The Target
Path dialog box is displayed.
-
7/30/2019 Flash Programming01
22/31
22
Creating a startDrag/stopDrag
event using Script Assist
14. In the Target Path dialog box, select the
MyCircle movie clip instance, and ensure that
the Relative path option is selected. Click OK.
-
7/30/2019 Flash Programming01
23/31
23
Creating a startDrag/stopDrag
event using Script Assist
15. Click the Add (+) button, and select GlobalFunctions > MovieClip Control >startDrag.
16. Enterthis into the Target text box.
17. Select the Expression and Constrain to
Rectangle check boxes.
-
7/30/2019 Flash Programming01
24/31
24
Creating a startDrag/stopDrag
event using Script Assist
18. Enter the following values in the L, T, R, and B
text boxes: L:0, T:0, R:300, B:300. These
values constrain the movement of the movie clip.
-
7/30/2019 Flash Programming01
25/31
25
Creating a startDrag/stopDrag
event using Script Assist
19. Click beneath the last line of the code
currently inserted in the Actions panel.
20. In the Actions Toolbox, navigate toActionScript 2.0 Classes > Movie >
MovieClip > Event Handlers >
onRelease, and double-click onRelease.
The onRelease method is added to theActions panel.
-
7/30/2019 Flash Programming01
26/31
26
Creating a startDrag/stopDrag
event using Script Assist
-
7/30/2019 Flash Programming01
27/31
27
Creating a startDrag/stopDrag
event using Script Assist
21. Click in the Object text box, and click the
Target Path button. The Target Path dialog
box is displayed.
22. In the Target Path dialog box, select the
MyCircle movie clip instance, and ensure that
the Relative path radio button is selected.
Click OK.
-
7/30/2019 Flash Programming01
28/31
28
Creating a startDrag/stopDrag
event using Script Assist
23. Click the Add (+) button, and select GlobalFunctions > MovieClip Control >
stopDrag.
The finished code looks like this:
this.my_mc.onPress = function() {
startDrag(this, false, 0, 0, 300, 300);
};
this.my_mc.onRelease = function() {
stopDrag();
};
-
7/30/2019 Flash Programming01
29/31
29
Creating a startDrag/stopDrag
event using Script Assist
24. Test your completed code by selectingControl > Test Movie.
25. In the Test Movie window, move the pointer
over the circle you created, and drag it around
the Text Movie window.
-
7/30/2019 Flash Programming01
30/31
30
Assignment
Due Date: Friday, 10th February 2006
Marks: 5%
Create a button in Flash and place it in Scene
1, Frame 1.
Attach an action to the button sending the userto Scene 2, Frame 1. (goto Action)
Create another button with added sound and
place it in Scene 2, Frame 1.
Add the getURL action to this button.
-
7/30/2019 Flash Programming01
31/31
31
Assignment
Due: 12pm Wednesday, 13th February
2008
Marks:5%
Submission: Publish on your websites.
Send me a mail with the URL and the .fla
file