TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Slide1_fla::MainTimeline/frame1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Slide2_fla::MainTimeline/frame1()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Side3_fla::MainTimeline/frame1()
我已经尝试了所有来源,仍然无法找到解决此问题的任何答案。
我正在运行Adobe Flash CS6 AS3
每当我运行脚本时,我得到此输出并且文件无法正常运行。在发布的文件中,swf文件未完全显示,这意味着外部.swf文件未安装在contentContainer中。
我的代码是这样的:
var _swfLoader:Loader;
var _swfRequest:URLRequest;
var _swfPathArr:Array = new Array("Slide1.swf", "Slide2.swf", "Slide3.swf");
var _swfClipsArr:Array = new Array();
var _swfTempClip:MovieClip;
var _loadedSWFs:int;
var contact_btn:SimpleButton;
var news_btn:SimpleButton;
var portfolio_btn:SimpleButton;
startLoading(_swfPathArr);
function startLoading(pathArr:Array):void {
_swfLoader = new Loader();
_swfRequest = new URLRequest();
loadSWF(pathArr[0]);
}
function loadSWF(path:String):void {
setupListeners(_swfLoader.contentLoaderInfo);
_swfRequest.url = path;
_swfLoader.load(_swfRequest);
}
function setupListeners(dispatcher:IEventDispatcher):void {
dispatcher.addEventListener(Event.COMPLETE, onSwfComplete);
dispatcher.addEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
}
function currentSwfProgress(event:ProgressEvent):void {
var _perc:int = (event.bytesLoaded / event.bytesTotal) * 5;
// swfPreloader.percentTF.text = _perc + "10%";
}
function onSwfComplete(event:Event):void {
event.target.removeEventListener(Event.COMPLETE, onSwfComplete);
event.target.removeEventListener(ProgressEvent.PROGRESS, currentSwfProgress);
_swfTempClip = event.target.content;
_swfTempClip.customID = _loadedSWFs;
_swfClipsArr.push(_swfTempClip);
if(_loadedSWFs <_swfPathArr.length - 1) {
_loadedSWFs++;
loadSWF(_swfPathArr[_loadedSWFs]);
} else {
_swfLoader.unloadAndStop();
_swfLoader = null;
onCompletePreloading();
}
}
function onCompletePreloading():void {
contentContainer.addChild(_swfClipsArr[0]);
news_btn.enabled = true;
contact_btn.enabled = true;
portfolio_btn.enabled = true;
news_btn.addEventListener(MouseEvent.CLICK, setContent);
portfolio_btn.addEventListener(MouseEvent.CLICK, setContent);
contact_btn.addEventListener(MouseEvent.CLICK, setContent);
}
function setContent(event:MouseEvent):void {
var _swfToAdd:MovieClip;
switch(event.target.name) {
case "news_btn":
_swfToAdd = _swfClipsArr[0];
break;
case "portfolio_btn":
_swfToAdd = _swfClipsArr[1];
break;
case "contact_btn":
_swfToAdd = _swfClipsArr[2];
break;
}
contentContainer.removeChildAt(contentContainer.numChildren-1);
contentContainer.addChild(_swfToAdd);
trace(_swfToAdd.customID);
}
答案 0 :(得分:1)
当加载的SWF包含“TLF Text”时,我常常遇到此问题。 那么修复?在加载的SWF“经典文本”中创建“全部”文本字段,希望您的问题能够得到解决。
PS。从FLA文件中清除所有TLF文本的简便方法是将文档脚本从ActionScript 3.0更改为2.0。由于TLF Text仅支持3.0,因此它们将立即更改回经典文本,然后再将脚本更改回3.0。 :)