Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Bring to Front using Actionscript

Explorer ,
Apr 07, 2020 Apr 07, 2020

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

1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Apr 08, 2020 Apr 08, 2020

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?Untitled-1.jpgexpand imageUntitled-2.jpgexpand imageUntitled-3.jpgexpand image

Translate
Community Expert ,
Apr 07, 2020 Apr 07, 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2020 Apr 07, 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 >

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2020 Apr 07, 2020

Yeah. It will work.

 

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2020 Apr 07, 2020

It worked perfectly. Thank you JC.

 

I do have one other (hopefully simple) problem to overcome if you don't mind me asking?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2020 Apr 07, 2020

You're welcome!

 

Sure. What do you need to know?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2020 Apr 07, 2020

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2020 Apr 07, 2020

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2020 Apr 07, 2020

I get this error message.  I've also attached a shot of the code within the .fla file.Untitled-1.jpgexpand imageUntitled-2.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 07, 2020 Apr 07, 2020

Untitled-3.jpgexpand imageThis 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 07, 2020 Apr 07, 2020

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 08, 2020 Apr 08, 2020
LATEST

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?Untitled-1.jpgexpand imageUntitled-2.jpgexpand imageUntitled-3.jpgexpand image

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines