EasyManua.ls Logo

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH - Page 127

MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
830 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
About language punctuators 127
In the following example, you create both an event listener object and a MovieClipLoader
instance.
var imgUrl:String = "http://www.helpexamples.com/flash/images/image1.jpg";
this.createEmptyMovieClip("img_mc", 100);
var mclListener:Object = new Object();
mclListener.onLoadStart = function() {
trace("starting");
};
mclListener.onLoadInit = function(target_mc:MovieClip):Void {
trace("success");
};
mclListener.onLoadError = function(target_mc:MovieClip):Void {
trace("failure");
};
var myClipl:MovieClipLoader = new MovieClipLoader();
myClipl.addListener(mclListener);
myClipl.loadClip(imgUrl, img_mc);
The next example displays a simple class file that could be used to create a Student object. You
learn more about class files in Chapter 7, “Classes,” on page 225.
To use curly braces in an ActionScript file:
1. Select File > New and then select ActionScript File.
2. Select File > Save As and save the new document as Student.as.
3. Add the following ActionScript to the AS file.
// Student.as
class Student {
private var _id:String;
private var _firstName:String;
private var _middleName:String;
private var _lastName:String;
public function Student(id:String, firstName:String,
middleName:String, lastName:String) {
this._id = id;
this._firstName = firstName;
this._middleName = middleName;
this._lastName = lastName;
}
public function get firstName():String {
return this._firstName;
}
public function set firstName(value:String):Void {
this._firstName = value;
}
// ...
}

Table of Contents

Related product manuals