所以我正在阅读Keith Peters撰写的“ActionScript 3.0 Animation〜Making Things Move”一书,其中一个例子就是教授Parent Boxs ......我写了这些代码,执行后,它运行,但没有提供错误,没有任何反应,没有任何Sprite被绘制,它是一个空白的画布..?使用Flash Pro CS 6,12.0.2.529。我还没有任何其他例子的问题,并且.as“ParentBox”运行良好,当我尝试运行ParentBox2时是当我遇到此问题....思考? (对不起,很新的OOP,努力学习,就像我可以,而且这个网站特别有惊人的奔迄今为止对知识的巨大财富....培训代码不能正常工作
ParentBox.as
package {
import flash.display.Sprite;
public class ParentBox extends Sprite {
public function ParentBox()
{
init();
}
private function init():void{
graphics.lineStyle(1, 0);
graphics.drawRect(-50, -50, 100, 100);
}
}}
ParentBox2.as代码....
package {
import flash.display.Sprite;
import flash.events.MouseEvent;
public class ParentBox2 extends Sprite {
private var parent1:ParentBox;
private var parent2:ParentBox;
private var ball:Sprite;
public function Reparenting2(){
init();
}
private function init():void{
parent1 = new ParentBox();
addChild(parent1);
parent1.x = 60;
parent1.y = 60;
parent2 = new ParentBox();
addChild(parent2);
parent2.x = 170;
parent2.y = 60;
ball = new Sprite();
parent1.addChild(ball);
ball.graphics.beginFill(0xff0000);
ball.graphics.drawCircle(0, 0, 40);
ball.graphics.endFill();
ball.addEventListener(MouseEvent.CLICK, onBallClick);
}
public function onBallClick(event:MouseEvent):void{
parent2.addChild(ball);
}
}}