Creating Layers, Comments, Functions, and XML Display in Flash Animation - Prof. Francois , Study notes of Computer Science

Instructions on creating layers, frame jumping, and tweening in flash using actionscript. It also covers comments, functions, variables, data types, operators, and event handlers. Additionally, it explains how to display xml documents in flash. Examples and codes for each concept.

Typology: Study notes

Pre 2010

Uploaded on 07/30/2009

koofers-user-boh-1
koofers-user-boh-1 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Frame jumping
-
Change the
name of
current layer as
Action
- Add 2 layers and name them as Ball and Control
- Select the Ball layer and tweening up to 30 frames with a circle
- Select the Control layer and add a button ( play_btn )
- Insert keyframes for the layer Action and Control at 30
th
frame
- Go to the Action layer s first frame in your timeline and open the actions panel
-
Enter this code
stop
()
;
- Go to the Control layer s first frame in your timelin
e and select the button
-
Enter this code to the action panel of the button
on (
release
) {
this._parent
.
gotoAndPlay
(2)
;
}
- Run your movie
2. Action script
-
Comments: // or /* ~ */
-
Function:
Anatomy
name
= function () {
actions
} ;
Example
acc = function (){ trace("umd, duck, unc") ; }
acc();
Passing data
name
= function (
data
) {
actions involving
data
};
name
(
data_to_pass
)
Example
addition = function (a, b) { total = a + b ;
return total ; }
trace(addition(3,4));
-
Variables
declaration
:
Anatomy
var
variable_name
:
Data Type
;
Data types : String, Number, Boolean, Object, MovieClip, Null, Void,
Refer Flash AS pdf file chaper 2, pp. 34 ~ 39
Examples
var x: Number = 7 ; var today: Date = new Date()
;
var y = 3 ;
// Automatic data typing
-
Local and global variables
_global.myVar=5;
-
Operators: Almost same as Java (Mathematical, Logical, Bit operators)
pf3

Partial preview of the text

Download Creating Layers, Comments, Functions, and XML Display in Flash Animation - Prof. Francois and more Study notes Computer Science in PDF only on Docsity!

1. Frame jumping

  • Change the name of current layer as Action
  • Add 2 layers and name them as Ball and Control
  • Select the Ball layer and tweening up to 30 frames with a circle
  • Select the Control layer and add a button ( play_btn )
  • Insert keyframes for the layer Action and Control at 30 th^ frame
  • Go to the Action layer s first frame in your timeline and open the actions panel
  • Enter this code stop();
  • Go to the Control layer s first frame in your timeline and select the button
  • Enter this code to the action panel of the button on (release) { this._parent.gotoAndPlay(2); }
  • Run your movie

2. Action script

  • Comments: // or /* ~ */
  • Function: Anatomy name = function () { actions } ; Example acc = function (){ trace("umd, duck, unc") ; } acc(); Passing data name = function (data) { actions involving data }; name(data_to_pass) Example addition = function (a, b) { total = a + b ; return total ; } trace(addition(3,4));
  • Variables declaration: Anatomy var variable_name : Data Type ;

Data types : String, Number, Boolean, Object, MovieClip, Null, Void, Refer Flash AS pdf file chaper 2, pp. 34 ~ 39

Examples var x: Number = 7 ; var today: Date = new Date() ; var y = 3 ; // Automatic data typing

  • Local and global variables

_global.myVar=5;

  • Operators: Almost same as Java (Mathematical, Logical, Bit operators)
  • Some examples of event handler: onClipEvent(...) and on(...) handlers are frequently used

myClip.onEnterFrame=function() { if (this._x<300) this._x+=5; else delete this.onEnterFrame; // to erase it, but you can simply empty it // else this.onEnterFrame=null; }

onData onDragOut onDragOver onEnterFrame onKeyDown onKeyUp onKillFocus onLoad onMouseDown onMouseMove onMouseUp onPress onRelease onReleaseOutside onRollOut onRollOver onSetFocus onUnload

  • Switch/case num = Math.round(Math.random()10);* switch (num) { case 0: trace ("ZERO"); break ; case 2: trace ("TWO"); break ; case 4: trace ("FOUR"); break ; case 8: trace ("HEIGHT"); break ; default: trace ("The number is not equal to 0, 2, 4 or 8") ; }

3. Display XML Document in Flash

  • Download xmlExamle.fla and movie.xml
  • Add 2 textfields (names are title_txt and story_txt)
  • For your story text field, you should set the line-type to Multiline. That allows longer pieces of text to wrap around and display on several lines
  • Add the code below and run

function loadXML(loaded) { if (loaded) { _root.titlen = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue; _root.story = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue; title_txt.text = _root.titlen; story_txt.text = _root.story; } else { trace("file not loaded!");} }

xmlData = new XML(); xmlData.ignoreWhite = true; xmlData.onLoad = loadXML; xmlData.load("movie.xml");