2011-09-19 102 views
2

更新時間:AS3:類型強制失敗:無法轉換flash.display使用::影片剪輯

現在我recieving此錯誤:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip

從這節課:

package com.George.MegaAmazingApp.Components 
{ 
    import flash.display.MovieClip; 
    import flash.display.Stage; 
    import flash.events.MouseEvent; 

    public class Wheel extends MovieClip 
    { 

     public function Wheel(area:MovieClip, diagram:MovieClip) 
     { 
      area.addEventListener(MouseEvent.CLICK, clickHandler); 
     } 
     private function clickHandler(event:MouseEvent):void 
     { 
      trace("wheel clicked"); 
      trace("this is diagram"); 
     } 

    } 

} 

這script:

import com.George.MegaAmazingApp.Components.*; 

var wheel:Wheel = new Wheel(this.wheel,this.car); 

De錯誤得出:

Attempting to launch and connect to Player using URL C:/Documents and Settings/reithg/My Documents/Classes/com/GeorgesMegaAmazingApp-app.xml 
[SWF] GeorgesMegaAmazingApp.swf - 51681 bytes after decompression 
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[email protected] to com.George.MegaAmazingApp.Components.Wheel. 
    at flash.display::Sprite/constructChildren() 
    at flash.display::Sprite() 
    at flash.display::MovieClip() 
    at GeorgesMegaAmazingApp_fla::MainTimeline() 
    at runtime::ContentPlayer/loadInitialContent() 
    at runtime::ContentPlayer/playRawContent() 
    at runtime::ContentPlayer/playContent() 
    at runtime::AppRunner/run() 
    at ADLAppEntry/run() 
    at global/runtime::ADLEntry() 

GeorgesMegaAmazingApp-app.xml的並不在該目錄中存在,但我不知道爲什麼它反正看那裏,它不是在FLA所在。

+0

你想對我說'進口com.George.MegaAmazingApp.Components.Wheel',而不是'com.George.MegaAmazingApp.Components *'? – Eugeny89

+0

@ Eugeny89問題在於大寫的第一個字母,因爲我已經將文件保存爲全部小寫...但是現在我有一個新的錯誤,更新第一篇文章。 –

+0

什麼行會引發錯誤? – Eugeny89

回答

2

this.wheelthis.car不是MovieClip。你也可以在文件>發佈設置中打開調試嗎?然後你會得到更好的錯誤信息,因爲沒有更多的信息,你的錯誤可能在任何地方。

編輯:

嘗試重命名var wheel到別的東西,因爲它似乎閃光燈混淆你的兩個輪子的物體。例如,嘗試:

var wheelObject:Wheel = new Wheel(this.wheel,this.car); 
+0

'[object MovieClip] [object MovieClip]'是trace(this.wheel)的結果; trace(this.car);' –

+0

好吧,但到目前爲止,我們所知道的只是某處,在一條未知的線路上,某些東西不是一個MovieClip。如果你打開調試程序,你將會得到行號,並且確切地知道你的錯誤在哪裏(並且可能不需要這麼做)。 –

+0

這些是整部電影中唯一的一行...更新第一篇文章,並進行調試 –

1

在com/George/MegaAmazingApp/Components目錄中是Wheel.as? (區分大小寫) 源路徑目錄中的'com'目錄是什麼?

+0

yes code hintin g在我的其他文件中工作,所以當我輸入wheel時,它告訴我我需要一個區域和代碼提示中的圖表。 –

+0

不要說w是小寫字母,導致它失敗,但有新的錯誤,你可以看一下嗎? –

相關問題