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

时间:2011-09-19 12:10:31

标签: flash actionscript-3 actionscript

更新:

现在我收到了这个错误:

  

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所在的位置。

2 个答案:

答案 0 :(得分:2)

this.wheelthis.car不是MovieClip。你也可以在File>中打开调试吗?发布设置?然后,您将获得更好的错误消息,因为如果没有更多信息,您的错误可能就在任何地方。

修改

尝试将var wheel重命名为其他内容,因为Flash似乎与您的两个轮对象混淆。例如,尝试:

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

答案 1 :(得分:1)

Wheel.as是否在目录com / George / MegaAmazingApp / Components中? (区分大小写) 这是源路径目录中的'com'目录吗?