作者sploo (sploo)
看板Flash
標題[問題] Button連結出現錯誤 錯誤碼#1009
時間Thu Jun 23 09:17:08 2011
我用button載入另外一個SWF檔出現以下文字
"TypeError: Error #1009: 無法存取 Null 物件參考的屬性或方法。
at portfolio_fla::MainTimeline/a()"
語法:
import flash.display.Loader;
import flash.net.URLRequest;
var myLoader:Loader=new Loader();
b1.addEventListener(MouseEvent.CLICK,show_pix6);
function show_pix6(event:MouseEvent):void
{
gotoAndPlay(20);
}
b2.addEventListener(MouseEvent.CLICK,show_pix1);
function show_pix1(event:MouseEvent):void
{
gotoAndPlay(36);
}
b3.addEventListener(MouseEvent.CLICK,show_pix2);
function show_pix2(event:MouseEvent):void
{
gotoAndPlay(52);
}
b4.addEventListener(MouseEvent.CLICK,show_pix3);
function show_pix3(event:MouseEvent):void
{
gotoAndPlay(68);
}
b5.addEventListener(MouseEvent.CLICK,show_pix4);
function show_pix4(event:MouseEvent):void
{
gotoAndPlay(84);
}
b6.addEventListener(MouseEvent.CLICK,show_pix5);
function show_pix5(event:MouseEvent):void
{
gotoAndPlay(100);
}
h.addEventListener(MouseEvent.CLICK,a);
function a(event:MouseEvent):void
{
var myURL:URLRequest = new URLRequest("home.swf");
loader.addChild(myLoader);
myLoader.load(myURL);
}
b1~b6,h為button的名稱
我在另一個檔案執行
h.addEventListener(MouseEvent.CLICK,a);
function a(event:MouseEvent):void
{
var myURL:URLRequest = new URLRequest("home.swf");
loader.addChild(myLoader);
myLoader.load(myURL);
}
不會有這個問題
有上網查些資料
是說stage沒有載入資料所以為null會有錯
請問哪裡有寫錯 是不是跟b1~b6的button有衝到
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.9.209
→ scars:你的"另一個檔案"找的到loader跟myLoader嗎..? 06/23 09:22
→ sploo:有 寫在AS裡 var myLoader ; load_mc.addChild(myLoader); 06/23 09:29
→ sploo:var myLoader:Loader=new Loader(); 06/23 09:30