[問題] as3的movie clip
昨天在練習寫as3 (剛入門 囧)
在flash中寫的時候沒有問題
但寫在外部的時候就出錯了
請各位高手幫我解答一下 > 3<
以下是程式碼
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import org.flashdevelop.utils.FlashConnect;
public class test extends MovieClip {
public function trace(str:*):void {
FlashConnect.trace(str.toString())
}
public function test() {
var empty:Sprite = new Sprite();
addChild(empty);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseTest);
function mouseTest(e:MouseEvent):void {
var test_mc:MovieClip = new MovieClip();
test_mc.graphics.beginFill(0x000000);
test_mc.graphics.drawEllipse(0, 0, 20, 20);
test_mc.graphics.endFill();
test_mc.x = stage.mouseX;
test_mc.y = stage.mouseY;
test_mc.scaleX = test_mc.scaleY = 0.1;
test_mc.alpha = 0.1;
test_mc.cacheAsBitmap = true;
empty.addChild(test_mc);
trace(empty.numChildren);
}
root.addEventListener(Event.ENTER_FRAME, upMouse);
function upMouse(e:Event):void {
for (var i:int; i < empty.numChildren; i++) {
var mc:MovieClip = empty.getChildAt(i);
mc.scaleX = mc.scaleY += 0.2;
if (mc.scaleX < 1.5) {
mc.alpha += 0.1;
}else {
mc.alpha -= 0.1;
}
if (mc.alpha < 0) {
empty.removeChild(mc);
}
}
}
}
}
}
用fd輸出的時候會有錯誤訊息
test.as(38): col: 31 Error:
Implicit coercion of a value with static type flash.display:DisplayObject to
a possibly unrelated type flash.display:MovieClip.
改用displayObject就正常了
但是想加上瀘鏡卻沒有作用
可以麻煩幫我解答一下嗎~~謝謝 ><
--
→
10/14 10:06,
10/14 10:06
→
10/14 10:07,
10/14 10:07
→
10/14 10:07,
10/14 10:07
→
10/14 10:07,
10/14 10:07
→
10/14 10:07,
10/14 10:07
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 122.116.92.103
→
11/27 13:37, , 1F
11/27 13:37, 1F
→
11/27 13:38, , 2F
11/27 13:38, 2F
→
11/27 13:39, , 3F
11/27 13:39, 3F