Error #1034 while running flash application

好久不见. 提交于 2020-01-06 05:39:30

问题


Alright, I know that this error is occurring because of something to do with addchild() function. On frame 2. How do I know? Because when I remove the snippets of code that dynamically place an object onto the stage it works fine. The error is below and the source code for frame 2 is below the error messages. Error Code

TypeError: Error #1034: Type Coercion failed: cannot convert 0 to flash.display.DisplayObject.
    at fl.motion::AnimatorBase/play()
    at fl.motion::AnimatorBase$/processCurrentFrame()
    at fl.motion::AnimatorBase/handleEnterFrame()
    at flash.display::MovieClip/nextFrame()
    at Lemonade_fla::MainTimeline/begin()[Lemonade_fla.MainTimeline::frame1:27]
TypeError: Error #1034: Type Coercion failed: cannot convert 0 to 

FRAME 2 CODE

flash.display.DisplayObject.
    stop();
var guide_tut:guide = new guide();
addChild(guide_tut);
//stand.addEventListener(MouseEvent.CLICK, check);
addEventListener(Event.ENTER_FRAME, check);
function check(ev : Event) : void {
    cash.text.text = cash1;
    lemons_count.text.text = lemons1;
    cups_count.text.text = cups;
    straws_count.text.text = straws;
    ice_count.text.text = ice;


}


shop_mc.addEventListener(MouseEvent.CLICK, shopnow);
function shopnow(event:MouseEvent):void{
    nextFrame();
}

回答1:


1) I ran your code it works fine, the only place the error could be generated is: flash.display.DisplayObject. should be: flash.display.DisplayObject; but you don't need it.

and

var guide_tut:guide = new guide(); addChild(guide_tut);

I ran it with just an empty mc, it works fine.

2) no reason to have (i know its commented out) but there never a reason to have stand.addEventListener(MouseEvent.CLICK, check) ever since check is EnterFrame

basically you're error is within either display, most likely you're not extending the class from MovieClip

public class guide extends MovieClip

instead of movieclip it can be sprite or other displayobject...



来源:https://stackoverflow.com/questions/5434954/error-1034-while-running-flash-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!