[問題] as3的movie clip

看板Flash作者 (任夭堂VVii)時間16年前 (2009/11/27 12:26), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/1
昨天在練習寫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,
我不相信Son Vegas可以把臉上的痘痘Zoom大還很清楚!!
10/14 10:06

10/14 10:07,
y
10/14 10:07

10/14 10:07,
y
10/14 10:07

10/14 10:07,
y
10/14 10:07

10/14 10:07,
y
10/14 10:07
-- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.92.103

11/27 13:37, , 1F
var mc:MovieClip = empty.getChildAt(i) as MovieClip;
11/27 13:37, 1F

11/27 13:38, , 2F
type cast↑
11/27 13:38, 2F

11/27 13:39, , 3F
喔喔喔 感謝cj大!
11/27 13:39, 3F
文章代碼(AID): #1B3rKJPp (Flash)