MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 127

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

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
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;
}
// ...
}
Chapter 7, "Classes," on page
225.
About language punctuators
127

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents