gpt4 book ai didi

flash - AS3:类型强制失败:无法转换 flash.display::MovieClip

转载 作者:行者123 更新时间:2023-12-04 06:14:11 25 4
gpt4 key购买 nike

更新:

现在我收到此错误:

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");
}

}

}

和这个脚本:
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 所在的位置。

最佳答案

要么this.wheelthis.car不是 MovieClip .您还可以在"file">“发布设置”中打开调试吗?然后,您将获得更好的错误消息,因为如果没有更多信息,您的错误可能会出现在任何地方。

编辑:

尝试重命名 var wheel到别的东西,因为 Flash 似乎与你的两个轮子对象混淆了。例如,尝试:

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

关于flash - AS3:类型强制失败:无法转换 flash.display::MovieClip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7470707/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com