【发布时间】:2011-09-19 12:10:31
【问题描述】:
更新:
现在我收到此错误:
TypeError:错误 #1034:类型强制失败:无法转换 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");
}
}
}
还有这个脚本:
import com.George.MegaAmazingApp.Components.*;
var wheel:Wheel = new Wheel(this.wheel,this.car);
调试给出:
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::MovieClip@2968e51 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 所在的位置。
【问题讨论】:
-
您是否尝试说
import com.George.MegaAmazingApp.Components.Wheel而不是com.George.MegaAmazingApp.Components.*? -
@Eugeny89 问题在于第一个字母的大写,因为我将文件保存为全小写...但现在我有一个新错误,正在更新第一篇文章。
-
它没有说出现这样的弹出窗口:TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip@2963e51 to com.George.MegaAmazingApp.Components.Wheel。在 flash.display::Sprite/constructChildren() 在 flash.display::Sprite() 在 flash.display::MovieClip() 在 GeorgesMegaAmazingApp_fla::MainTimeline() 在运行时::ContentPlayer/loadInitialContent() 在运行时::ContentPlayer /playRawContent() at runtime::ContentPlayer/playContent() at runtime::AppRunner/run() at ADLAppEntry/run() at global/runtime::ADLEntry()
标签: flash actionscript-3 actionscript