简体   繁体   English

单击Flash中的按钮时如何在舞台上添加更多动画

[英]how to add more animations to the stage when clicking a button in flash

i want to add more fish to my flash fish tank by clicking a button..i tried this code but my fish animation is not getting animated after i click the button..and i'm using action script 3 .. 我想通过单击一个按钮向我的闪光鱼缸添加更多鱼..我尝试了此代码,但是单击按钮后我的鱼动画没有动画..并且我正在使用动作脚本3 ..

    function fl_MouseClickHandler_2(event:MouseEvent):void
{
    // Start your custom code
    // This example code displays the words "Mouse clicked" in the Output panel.
    trace("Mouse clicked");

    addChild(f3);
    addChild(eat)   ;
    addChild(hello) ;
    addChild(f2)    ;
    addChild(f1)    ;
    // End your custom code



}

f1,f2,f3,eat,hello are my fishes.. f1,f2,f3,吃,你好是我的鱼。

This is my infinite scrolling code..all the fishes are in separate layers ..so for each layer i have put this code..by just changing the instance name and the function. 这是我的无限滚动代码。所有的鱼都位于单独的层中,所以对于每一层,我只需更改实例名称和函数就可以放置此代码。

    f3.addEventListener(Event.ENTER_FRAME, fnewm);
function fnewm(evt:Event)
{   
    if(f3.x + f3.width <= 0) //movieclip is outside left side of stage
    {
        //set new position
        f3.x = stage.stageWidth;
    }
    else
        f3.x -= 5;

}

As you "Mouse clicked" message don't show in console I can assume either of two options: 当您在控制台中不显示“鼠标单击”消息时,我可以采用以下两个选项之一:

  1. Somehow you didn't setup event listener to the button; 不知何故,您没有将事件监听器设置为按钮;
  2. Your button is not on the top layer so the click is not registered because it is hidden by something. 您的按钮不在顶层,因此单击未注册,因为它被某些东西隐藏了。

I can't tell you exactly, but you can try manually set button's depth. 我无法确切告诉您,但是您可以尝试手动设置按钮的深度。 More info on how to do it can be found here 有关如何执行此操作的更多信息,请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM