Difference between revisions of "Actionscript"

From Wikicliki
Jump to: navigation, search
Line 48: Line 48:
 
103
 
103
 
104
 
104
105</pre>
+
105</pre></td></tr></table>
  
 
== functions ==
 
== functions ==
Line 60: Line 60:
 
area2 = area(10,20);
 
area2 = area(10,20);
 
area3 = area(10,20);
 
area3 = area(10,20);
 +
</pre>
 +
 +
== event based execution ==
 +
 +
<pre>someObject.onSomeEvent = someFunction;</pre>
 +
 +
for example:
 +
<pre>skaGirl.onRelease = dirtyskanking;            // the object named skaGirl will dirtyskank when mouse is released
 +
 +
function dirtyskanking () {
 +
  this._parent._rotation = 360;                    // defines the rotation of the dirtyskanking.
 +
}
 
</pre>
 
</pre>

Revision as of 12:11, 16 June 2008

actionscript, that infuriatingly intractable marshmellow fluff...

trace

var message = "Hi there";
trace (message);                                    // prints "Hi there"
var message = "yellow";
trace ("big " + message + " truck");                // prints "big yellow truck"

conditionals

var message = "yellow";
trace ("big " + message + " truck");                // prints "big yellow truck"
if (message == "yellow") {
trace ("yes, i did say big yellow truck.");        // prints "yes, i did say big yellow truck"
}

loops

this sequence...
trace (101);
trace (102);
trace (103);
trace (104);
trace (105);
is equal to:
var x = 101;
trace (x);
x = x + 1;
trace (x);
x = x + 1;
trace (x);
x = x + 1;
trace (x);
x = x + 1;
trace (x);
is also equal to:
var x = 101;
while (x <= 105) {     // as long as x is less than 105...
trace (x);
x = x + 1;           // ...continue to trace x but add one each time
}
they all print:
101
102
103
104
105

functions

sample:

function area(height, width){
return height * width;
}
area1 = area(10,15);
area2 = area(10,20);
area3 = area(10,20);

event based execution

someObject.onSomeEvent = someFunction;

for example:

skaGirl.onRelease = dirtyskanking;             // the object named skaGirl will dirtyskank when mouse is released

function dirtyskanking () {
  this._parent._rotation = 360;                     // defines the rotation of the dirtyskanking.
}