作者skylight68 (空虛)
看板Flash
標題[問題] mouseover
時間Wed Jul 15 11:29:40 2009
又來煩大家啦 這個範例照理說不是在滑鼠移到shape2的時候會讓shape1消失嗎?
可是程式碼也對,也有顯示圖片,就是移到shape2的時候shape1不會消失。
請問有知道原因嗎?謝謝。
var shape1:Shape = new Shape();
var shape2:Shape = new Shape();
shape1.graphics.beginFill(0xff0000);
shape1.graphics.drawRect(0,0,200,100);
shape1.graphics.endFill();
shape2.graphics.beginFill(0x00ff00);
shape2.graphics.drawRect(100,100,200,100);
shape2.graphics.endFill();
addChild(shape1);
addChild(shape2);
shape2.addEventListener(MouseEvent.MOUSE_OVER,over);
shape2.addEventListener(MouseEvent.MOUSE_OVER,out);
function over(e:MouseEvent)
{
removeChild(shape1);
}
function out (e:MouseEvent)
{
addChild(shape1);
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.131.162
推 aquarianboy:因為Shape並不是InteractiveObject的小孩啊 :) 07/15 12:07
→ skylight68:那請問我該怎做呢?因為我是照書做的xd 07/15 12:10
→ skylight68:現在還在努力搞懂中 07/15 12:10
→ aquarianboy:建立一個container,例如sprite或movieclip,把shape 07/15 12:11
→ aquarianboy:丟進去(addChild) 07/15 12:11
→ aquarianboy:listener加在container上,應該就會動了 07/15 12:23
→ skylight68:@@ 好高深 07/15 12:25
→ skylight68:我現在只能做些簡單的東西 07/15 12:27
→ skylight68:那個套件跟類別還在努力中xd 07/15 12:27
→ skylight68:可以教一下怎加嗎@@ 07/15 12:28
※ 編輯: skylight68 來自: 61.228.131.162 (07/15 12:28)