1,mxml据说是程序的入口,其实质与java及c的main函数一致,形式上和实质上的调用端
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init02()">
<mx:Script>
<![CDATA[
import mx.containers.Canvas;
public function init02():void
var b:Boy=new Boy();
//b.car.drawLine();
addChild(b.canvas);
]]>
</mx:Script>
</mx:Application>
2,Boy类,按ActionScript写出来的程序虽然与一般的java语言存在差异,但是就实质来说是一致的。Boy类引用另一个car类
package
import mx.containers.Canvas;
public class Boy
var car:Car;
var canvas:Canvas;
public function Boy()
canvas=new Canvas();
canvas.graphics.lineStyle(1);
canvas.graphics.moveTo(0,0);
canvas.graphics.lineTo(500,500);
car=new Car();
car.publicName="H";
car.publicId="K2";
car.publicSpeed=50;
var str:String="boy"+car.publicId+car.publicName+car.publicSpeed;
car.output(str);
}
}
}
3,这是典型的类似java的Bean的一个类,看它的get和set方法,就知道了
package
import mx.containers.Canvas;
import mx.controls.Alert;
public class Car
private var name:String;
private var id:String;
private var speed:int;
public function Car()
}
public function drawLine():void
var canvas:Canvas=new Canvas();
canvas.graphics.lineStyle(1);
canvas.graphics.moveTo(0,0);
canvas.graphics.lineTo(500,500);
}
public function output(str:String):void
Alert.show("boy..."+str);
public function set publicName(name:String):void
this.name=name;
public function get publicName():String
return name;
public function set publicId(id:String):void
this.id=id;
public function get publicId():String
return id;
public function set publicSpeed(speed:int):void
this.speed=speed;
public function get publicSpeed():int
return speed;
}
}
}
鉴于本侠才接触ActionScript,就其中的玄妙也不是很清楚,就写到这里了