Re: [問題] 1046: 找不到 Type,或它不是編譯時期넠…

看板Flash作者 (那個冬天..是永恆)時間15年前 (2010/09/22 16:01), 編輯推噓1(104)
留言5則, 2人參與, 最新討論串2/2 (看更多)
1046錯誤,在推文中我已明寫,就是import flash.events.MouseEvent;你寫錯, 雖然你說已經修正,但events仍少個s,不知道是你筆誤還怎樣。 這個錯誤修正後,尚有其他問題,下面是修正後的程式碼,給你參考看看。 package { import flash.display.Sprite; import flash.display.MovieClip; import flash.geom.Rectangle; import flash.events.MouseEvent; public class main1 extends Sprite { private var barWidth:Number; private var conWidth:Number; private var barx:Number; private var bary:Number; private var trueWidth:Number; private var rect:Rectangle; public function main1() { init(); } private function init():void { barWidth = bar_mc.width; conWidth = control_mc.width; barx = bar_mc.x; bary = bar_mc.y; trueWidth = barWidth - conWidth; rect = new Rectangle(barx,bary,trueWidth,0); bar_mc.buttonMode=true; control_mc.buttonMode=true; control_mc.addEventListener(MouseEvent.CLICK,Drag1); } private function Drag1(event:MouseEvent):void { control_mc.startDrag(false, rect); } } } -- 世界上最遙遠的距離,不是生與死 而是家住在公司隔壁,而我回不去 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 111.251.164.221

09/22 22:17, , 1F
解決了 感謝 !! 但還是想知道那錯誤是代表??
09/22 22:17, 1F

09/23 11:59, , 2F
你的rect定義在Main1裡 Drag1不會知道rect是什麼
09/23 11:59, 2F

09/23 12:04, , 3F
所以應該把它定義在class下面 這樣2個function才都知道
09/23 12:04, 3F

09/23 12:09, , 4F
而且rect需要用到另外3個變數 所以要一起定義在class下
09/23 12:09, 4F

09/23 12:16, , 5F
其實rect會用到你其他全部的變數 所以都要一起定義
09/23 12:16, 5F
文章代碼(AID): #1CcRVFLc (Flash)
文章代碼(AID): #1CcRVFLc (Flash)