Skip to main content
Inspiring
April 7, 2020
Answered

Bring to Front using Actionscript

  • April 7, 2020
  • 11 replies
  • 1456 views

Hello. Is there an ActionScript 3.0 command that forces an object/symbol to the front?

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer jamesro@cymoedd.ac.uk

    Thanks for the references.

     

    The error happens because you're referencing the class itself and not an instance of the class.

     

    For example: you have a Movie Clip on stage called player. You change the alpha of this instance writing player.alpha = 0.5; and not MovieClip.alpha = 0.5;.

     

    You have to create an instance of your ShotsCount symbol and then access the text field inside of it through the instance name. For example:

    var shots:ShotsCount = new ShotsCount();
    
    shots.shotstxt = String(score);
    
    addChild(shots);

     

    Please let me know if you have any further questions.

     

     

    Regards,

    JC


    I'm really to be a pain.  I now get this compiler error message.

     

    I added your script to the function as shown in the attached.

     

    I also included the varaiables I already have set if that helps?

    11 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 7, 2020

    Hi.

     

    Yeah, there is.

     

    You can use setChildIndex and pass as the second argument theNameOfYourContainer.numChildren - 1 or you can even  use addChild because this method always adds an instance to the top of all other children in the same DisplayObjectContainer instance.

     

    Regards,

    JC

    Inspiring
    April 7, 2020

    Thanks JC.

    I have an addChild command in my script within the .fla file and another in an external action script file (.as). The child in the .as file appears in front of the child in the .fla file but I want it to appear behind.

    Will these solutions work?

    < Content edited by a moderator >

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 7, 2020

    Yeah. It will work.

     

    You can use one of these methods to bring the child generated in the Animate IDE to the front.