Study Guides (390,000)
CA (150,000)
SFU (5,000)
IAT (80)
IAT 167 (20)
Final

IAT167-Arrays2 Example.docx


Department
Interactive Arts & Tech
Course Code
IAT 167
Professor
Jack Stockholm
Study Guide
Final

This preview shows half of the first page. to view the full 1 pages of the document.
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var myNumbers:Array = new Array ();
myNumbers = ["a", "b", "c"];
trace(myNumbers);
trace("the length of my array is" + myNumbers.length);
var lastitem:String = myNumbers.pop();
trace(myNumbers);
myNumbers.push("word");
trace(myNumbers);
//Event
//1) Import "Event class" package
//2) Add event listener to an object with addEventListener() args inside
//3) Event handler on MouseClick(); occurs with even happens; accpets event
object-continuous info (x, y)
stage.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(event:MouseEvent):void
{
trace("You clicked on the stage");
trace(event);
}
}
}
You're Reading a Preview

Unlock to view full version