04new keyword and call the object's constructor function.
new Thingy();some object constructors expect parameters.
new Thingy(3, "fred");calling a constructor with the
new keyword will generate a custom instance just for you, so you'll
want to store it in a variable (of the appropriate type) for later.
var he:Thingy = new Thingy(2, "fred"); var she:Thingy = new Thingy(3, "frieda");
var B:Boolean = new Boolean(true);
var B:Boolean = true;
var B:Boolean = new Boolean(6 > 4);
var B:Boolean = (6 > 4);
var N:Number = new Number(5);
var N:Number = 5;
var S:String = new String("abcdefg");
var S:String = "abcdefg";
var A:Array = new Array();
var A:Array = [];
var A:Array = new Array("a", "b", "c");
var A:Array = ["a", "b", "c"];
var O:Object = new Object();non-native objects can only be instantiated via a constructor function—there are no means of literal declaration.
var O:Object = {};
var D:Date = new Date(); var S:Sprite = new Sprite();
var week:Array = new Array("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); var D:Date = new Date(); var dayIndex:Number = D.day; var day:String = week[dayIndex]; // see http://livedocs.adobe.com/flex/3/langref/Date.html#day for day indices trace("today is"); trace(day);
Math and Number are examples.
you just access their properties and methods through their name without instantiating anything.
the designers of actionscript did not intend for the objects native to flash to be the only objects a flash programmer might ever need. programmers can create their own custom objects (called classes) to implement functionality and data structures that suit their specific needs.
classes are defined in actionscript files (plain text files) that exist outside of any flash file. as long as a flash file can find the class file, you are free to create instances of the new class in code in the flash movie. for highly specific classes that will only be used within a single project, putting the class file in the same folder as the flash movie is enough—flash will magically find it. for more general purpose classes that may be usable in many different projects, it's easier to manage them as a package, or library of classes than can be located in one location and imported by any flash movie that needs access to a custom class.
Z:\HTML folder. start with a pca folder, then put your assignment
folders inside that, e.g. Z:\HTML\pca\task03. then name the main html file for the assignment
with the same name as the folder and .html, e.g. Z:\HTML\pca\task03\task03.html.
your homework assignment will be linked to from the student work page.
you are responsible for checking that your homework link works before the beginning of class when it's due.
if you save this HTML template to
C:\Documents and Settings\<you>\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\HTML,
you'll have a new entry in the Template drop-down on the Publish Settings panel in flash (CTRL-SHFT-F12).
Select PCA Homework Template and publish.
you'll also need to save this script in the same directory as your .swf