Copy link to clipboard
Copied
Hello. Is there an ActionScript 3.0 command that forces an object/symbol to the front?
1 Correct answer
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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 >
Copy link to clipboard
Copied
Yeah. It will work.
You can use one of these methods to bring the child generated in the Animate IDE to the front.
Copy link to clipboard
Copied
It worked perfectly. Thank you JC.
I do have one other (hopefully simple) problem to overcome if you don't mind me asking?
Copy link to clipboard
Copied
You're welcome!
Sure. What do you need to know?
Copy link to clipboard
Copied
I have a Dynamic textbox within my MovieClip which is supposed to change everytime the user presses the space bar. It worked fine before I made the textbox part of a MovieClip using this line of code:
scoretxt.text = String(score);
Where score is a variable that gets incremented. How do I refer to it now it is within my 'ShotsCount' MovieClip which also has 'ShotsCount' as its linkage within my Library?
Copy link to clipboard
Copied
If you have an instance of this ShotsCounts Movie Clip that is called shots, for example, than it should be pretty straightforward to reference the text field inside of if. Like this:
shots.scoretxt.text = String(score);
Is this what you want?
Copy link to clipboard
Copied
I get this error message. I've also attached a shot of the code within the .fla file.
Copy link to clipboard
Copied
This is the MovieClip with 'Shots:' as static text and '6' as Dynamic text called shotstxt. Should they be on separate layers and would that make a difference?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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?

