2011-09-19 99 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是小写字母,导致它失败,但有新的错误,你可以看一下吗? –

相关问题