AS3: Type Coercion failed: cannot convert flash.display::MovieClip
Updated:
Now I am recieving this error:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::MovieClip
From this class:
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");
}
}
}
and this script:
import com.George.MegaAmazingApp.Components.*;
var wheel:Wheel = new Wheel(this.wheel,this.car);
Debug gives:
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 doesn't exist in that directory but I don't know why it is looking there anyway, it is not where the fla is located.
Either this.wheel
or this.car
is not a MovieClip
. Also could you turn on debugging in File > Publish Settings? You'll then get better error messages because, without more information, your error could be just about anywhere.
Edit:
Try renaming var wheel
to something else because it seems that Flash is confused with your two wheel objects. For example, try:
var wheelObject:Wheel = new Wheel(this.wheel,this.car);
Is Wheel.as in the directory com/George/MegaAmazingApp/Components? (case-sensitive) Is that 'com' directory in a source path directory?
精彩评论