Bring to front Object flash actionscript 3 - actionscript-3

I have a button and four stacked movieclips. What action should I put in my button if I want to bring the movieclip in the bottom to the front?

setChildIndex(myChild,numChildren);
this code moves your display object to the front of others.
I  H☻ P E  this helps.

Related

Actionscript 3, how do I make a menu appear by clicking a button, on the same frame?

So I have a button called manpb. When I click manpb, I want a menu to appear. The menu is a picture, but I can convert it into an object if this helps.
The best I can do is: Make a second frame with the menu, and insert the code inside the man_pb function:
gotoAndStop(2);
My problem is that I want the menu to appear on the same frame; then the menu will have buttons of his own. Any idea what to type inside the function below?
manpb.addEventListener(MouseEvent.CLICK, man_pb);
function man_pb(event:MouseEvent):void{
}
A big thank you!
The most intuitive solution might be to have your menu inside a MovieClip on the same frame. The menu buttons can also be placed within that menu MovieClip.
Simply convert your menu picture to a MovieClip (right-click, convert to MovieClip). Make sure that you select the MovieClip, and in the Properties panel give it an Instance Name, like menuMC or anything you want.
There are then a couple ways that you could handle making the menu appear only when you click the button.
1- Set the MovieClip's opacity to 0 by default, and then include this in your button function:
menuMC.alpha = 1;
thereby changing the MovieClip to fully opaque.
2- Make the MovieClip comprised of two frames, one empty frame that has a stop(); action, and one frame that contains your menu image and buttons. Then the button code would be:
menuMC.gotoAndStop(2);
3- Load the MovieClip dynamically from your library. See this for more information. edit: This is the approach that #DodgerThud is referring too, and is the more advanced but more comprehensive approach.
Use your Menu as an Object and add it to the MovieClip you want.
var menu:Menu = new Menu();//This is your Menu Symbol in your Library, you need to create one before you can use it
var manpb;//you could do the same thing for button, so you only need one symbol that has uses different labels
manpb.addEventListener(MouseEvent.CLICK, man_pb);
function man_pb(event:MouseEvent):void{
if(contains(menu)){//checking if "menu" already exists
removeChild(menu);//remove it from the displaylist
}else{
addChild(menu);//add it to the displaylist
}
}
In the Listener function you check if your current MovieClip (this should NOT be Button) already has a child that is menu. If it does, it removes the menu, otherwise, it will add the menu.
Don't forget to export your Menu for ActionScript.

ActionScript 3 goto and play event not working

I have a navigation and inside the navigation movie clip, I have buttons and I put this code in my of my button frames
aboutbtn.addEventListener(MouseEvent.CLICK,goAbout);
function goAbout(e:MouseEvent){
this.gotoAndPlay('245');
}
But this didnt work and when I click my button it does nothing, is there something wrong with my code?
this.gotoAndPlay('245');
'245' is a string and gotoAndPlay interprets as a frame label. Remove the quotes, passing an integer, to go to the frame 245.
aboutbtn.addEventListener(MouseEvent.CLICK,goAbout);
function goAbout(e:MouseEvent){
this.gotoAndPlay(245);
}
If that still doesn't work, make sure this refers to the movieclip you want to change the frame. For example, if this code is in the document class, referring to the root instance, this will change the stage's frame.
If you want to change the button frame (only makes sense if it's a SimpleButton instance), change this to aboutbtn, for example.
If it's anything else, you'll to give us more context, it could be a load of other things (different stage? is there a frame 245? is the button mouse enabled? is there any invisible buttons on top of the object?).
Edit:
After clarification: if you want to change the frame of the object above nav, its parent, use:
aboutbtn.addEventListener(MouseEvent.CLICK,goAbout);
function goAbout(e:MouseEvent){
MovieClip(parent).gotoAndPlay(245);
}

How do I bring 1 of 3 movie clips to the front and make it stay there? (Flash CS5, AS 3.0)

I have three movie clips that I want to bring to front when I click on the associated tag. Flash cs5 and actionscript 3.0. The coding for each looks like this:
status_mc.status_btn.addEventListener(MouseEvent.CLICK, callFunction_stat);
function callFunction_stat(e:MouseEvent): void {
if (getChildIndex(status_mc) == 0) {setChildIndex(status_mc, 1) } else {setChildIndex(status_mc, 0)} ;
}
This sends the movie clip /back/ instead of forwards though it does allow me to view each clip on top. My question is, how do I bring each of the 3 movie clips to the front when I click on it, and if it /is/ in the front, make it remain so/no change when clicked?
To bring a display object to the front (IE:on top of all other display objects) you simply need to addChild(status_mc)

I want to have a JPanel with both a Java 2d Graphics Section and a JComponent Section at the bottom

This is for a tower defense game and i want the top section to be the map and objects drawn in 300x200 panel and the bottom be a 300x100 panel with multiple JButtons and JLabels. How would I do this. I have used swing for a long time I just don't know exactly how to separate the Graphics part from the other components.
I would suggest putting 2 JPanels inside your main JPanel. The top one would be for the map and objects, and the bottom one would contain your JButtons and JLabels.
Just remember to set an appropriate LayoutManager for the main JPanel.

bring object to front flash actionscript 3

I have a menu set up that has about 20 menu items in a circle. When you mouse over each item, a title comes up. The only problem is that because of the depth order, it's hidden behind the other menu items. Is there a way to bring this item to the front when moused over? I'm pretty actionscript illiterate so any help would be awesome.
If you don't want your object being removed and then added to the display list using addChild you can use setChildIndex
var parent:DisplayObjectContainer = myElement.parent;
parent.setChildIndex(myElement, parent.numChildren-1);
You can move an item to the top by re-adding it to the display list, using addChild(item), even if it is already added as a child. Something in the lines of this:
function onMouseOver(e:MouseEvent) {
e.target.parent.addChild(e.target);
}
It may feel a bit odd to use this approach, instead of other possible methods to move stuff around in a display list, but since addChild(object) first removes the object from a display list, before adding it, it will work just fine.