imgLoader
在此 Flash AS3 应用程序上工作,当我尝试制作可点击时,我不断收到此错误。
imgLoader 是一个动态加载器,它将从 XML 文件加载图像并使用 ActionScript 创建。
这是我得到的完整错误:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at apptest_fla::MainTimeline/frame1()[apptest_fla.MainTimeline::frame1:65]
at runtime::ContentPlayer/loadInitialContent()
at runtime::ContentPlayer/playRawContent()
at runtime::ContentPlayer/playContent()
at runtime::AppRunner/run()
at ADLAppEntry/run()
at global/runtime::ADLEntry()
这是使imgLoader
可点击的代码:
imgLoader.addEventListener(MouseEvent.CLICK, doSomething);
function doSomething(event:MouseEvent){
nextFrame()
有谁知道为什么会这样?
编辑
这是我的全部代码:
stop();
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
var xmlLoader11:URLLoader;
var xml11:XML;
var uRequest11 = new URLRequest("my.xml");
xmlLoader11 = new URLLoader(uRequest11);
xmlLoader11.addEventListener(Event.COMPLETE, onXMLLoad11);
var imgLoader11:Loader;
var nameLoader11:Loader;
var myString11:String = 'loading';
function onXMLLoad11(e:Event) {
xml11 = new XML(e.target.data);
imgLoader11 = new Loader();
imgLoader11.contentLoaderInfo.addEventListener(Event.COMPLETE, onImgLoaded11);
imgLoader11.load(new URLRequest(xml11.Data.Image.text()[0]));
Nametxt11.text = "" + xml11.Data.Name.text()[0];
}
function onImgLoaded11(e:Event) {
addChild(imgLoader11);
imgLoader11.height = 300;
imgLoader11.width = 300;
var bitmapContent11:Bitmap = Bitmap( e.target.content );
bitmapContent11.smoothing = true;
addChild( bitmapContent11 );
bitmapContent11.height = 150;
bitmapContent11.width = 150;
bitmapContent11.y = 65;
bitmapContent11.x = 85;
}
imgLoader11.addEventListener(MouseEvent.CLICK, doSomething);
function doSomething(event:MouseEvent){
nextFrame()