[問題] 如何在影片中將參數傳到主影格
如題
在主影格1中 我加了一段影片 影片的最後有2個按鈕
會根據按不同的按鈕 在影格2 會有不同的問答題目
但現在問題是 我在主影格2宣告一個變數 qu_type=int(隨便設的)
然後在影片分別偵聽2個按鈕
btn_1.addEventListener(MouseEvent.CLICK, fun1);
btn_2.addEventListener(MouseEvent.CLICK, fun2);
在fun1把qu_type=1
fun2把qu_type=2
但在主影格2去trace(qu_type) 答案是0 表示我根本沒傳到主影格
請問一下 我到底要怎樣宣告或是怎麼傳值
才能在主影格抓到子影片的變數
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.250.14.92
※ 編輯: toyhsu 來自: 111.250.14.92 (05/21 17:25)
→
05/22 01:03, , 1F
05/22 01:03, 1F
→
05/22 01:54, , 2F
05/22 01:54, 2F
→
05/22 10:12, , 3F
05/22 10:12, 3F
→
05/22 10:12, , 4F
05/22 10:12, 4F
目前的作法 在主影格1的其中1圖層的影片中加上下面語法
function driver (event:MouseEvent):void
{
dispatchEvent(new Event("qu_type=1"));
parent.gotoAndStop(2)
}
btn_1.addEventListener(MouseEvent.CLICK, driver);
function walker (event:MouseEvent):void
{
dispatchEvent(new Event("qu_type=2"));
parent.gotoAndStop(2);
}
btn_2.addEventListener(MouseEvent.CLICK, walker);
在主影格2加上下面語法接影片中的自定義事件 (dr_start是影片名稱)
dr_start.addEventListener("qu_type=1", fun_1);
dr_start.addEventListener("qu_type=2", fun_2);
function fun_1(event:Event):void
{
qu_type=1;
}
function fun_2(event:Event):void
{
qu_type=2;
}
但會出現TypeError: Error #1009: 無法存取 Null 物件參考的屬性或方法。
不知道是哪裡有問題? 有人可以解惑嗎? 感謝
※ 編輯: toyhsu 來自: 111.250.14.92 (05/22 11:03)
※ 編輯: toyhsu 來自: 111.250.14.92 (05/22 11:16)
→
05/22 13:09, , 5F
05/22 13:09, 5F
→
05/22 13:10, , 6F
05/22 13:10, 6F
→
05/22 13:11, , 7F
05/22 13:11, 7F
→
05/22 13:16, , 8F
05/22 13:16, 8F
→
05/22 13:17, , 9F
05/22 13:17, 9F
推
05/22 13:52, , 10F
05/22 13:52, 10F
→
05/22 13:57, , 11F
05/22 13:57, 11F
討論串 (同標題文章)
完整討論串 (本文為第 1 之 2 篇):
1
11
Flash 近期熱門文章
PTT數位生活區 即時熱門文章