246
Classes
To use the Picture and PictureClass classes in a FLA file:
1.
Select File > New and then select ActionScript File. Save the document as
Picture.as
and
then click OK.
You write your custom Picture class in this document.
2.
Type the following ActionScript code into the Script window:
/**
Picture class
author: John Doe
version: 0.53
modified: 6/24/2005
copyright: Macromedia, Inc.
The Picture class is used as a container for an image and its URL.
*/
class Picture {
private var __infoObj:Object;
public function Picture(src:String) {
this.__infoObj = new Object();
this.__infoObj.src = src;
}
public function showInfo():Void {
trace(this.toString());
}
private function toString():String {
return "[Picture src=" + this.__infoObj.src + "]";
}
public function get src():String {
return this.__infoObj.src;
}
public function set src(value:String):Void {
this.__infoObj.src = value;
}
}
3.
Save the ActionScript file.
4.
Select File > New and then select Flash Document to create a new FLA file. Save it as
picture_test.fla
in the same directory as you saved the Picture class file.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...