actionscript3的问题,flash高手进!!!!1 20
package{importflash.display.Sprite;publicclassLibraryextendsSprite{publicvarcircleCla...
package {
import flash.display.Sprite;
public class Library extends Sprite {
public var circleClass:Class = Circle;
public function Library() {
}
}
}
import flash.display.Shape;
class Circle extends Shape {
public function Circle(color:uint = 0xFFCC00, radius:Number = 10) {
graphics.beginFill(color);
graphics.drawCircle(radius, radius, radius);
}
}
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
public class LibaryLoader extends Sprite {
public function LibaryLoader() {
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("Library.swf");
ldr.load(urlReq);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
}
private function loaded(event:Event):void {
var library:Object = event.target.content;
var circle:Shape = new library.circleClass();
addChild(circle);
}
}
}
TypeError: Error #1007: 尝试实例化的函数不是构造函数。
at LibaryLoader/::loaded()
FLASH帮助里的代码,错误应该在这行
var circle:Shape = new library.circleClass();
为什么会出现这个错误,要如何更改? 展开
import flash.display.Sprite;
public class Library extends Sprite {
public var circleClass:Class = Circle;
public function Library() {
}
}
}
import flash.display.Shape;
class Circle extends Shape {
public function Circle(color:uint = 0xFFCC00, radius:Number = 10) {
graphics.beginFill(color);
graphics.drawCircle(radius, radius, radius);
}
}
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
public class LibaryLoader extends Sprite {
public function LibaryLoader() {
var ldr:Loader = new Loader();
var urlReq:URLRequest = new URLRequest("Library.swf");
ldr.load(urlReq);
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loaded);
}
private function loaded(event:Event):void {
var library:Object = event.target.content;
var circle:Shape = new library.circleClass();
addChild(circle);
}
}
}
TypeError: Error #1007: 尝试实例化的函数不是构造函数。
at LibaryLoader/::loaded()
FLASH帮助里的代码,错误应该在这行
var circle:Shape = new library.circleClass();
为什么会出现这个错误,要如何更改? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询