1

I am incredibly new to Actionscript 3. I have Thanksgiving off and I thought I would try making a game in flash.

My problem is that I have a bitmap image that is being added to the scene dynamically and it is covering up a button. I initialized and loaded the image like this:

var myBitmapDataObject:bedroomCellPhoneD = new bedroomCellPhoneD(100, 100);
var myImage:Bitmap = new Bitmap(myBitmapDataObject);
addChild(myImage);

Then a few frames after this image is loaded I have a button on the scene, but the button is covered. How do I bring the button to the front?

user3044394
  • 138
  • 3
  • 15

1 Answers1

1

Use addChildAt(index) instead of addChild to control the index position of the child in the DisplayObjectContainer.
For exemple in your case if you have nothing else on your display list, just your image and your button you can do this:

var myBitmapDataObject:bedroomCellPhoneD = new bedroomCellPhoneD( 100, 100 );
var myImage:Bitmap = new Bitmap( myBitmapDataObject );
// add the image on the back
addChildAt( myImage, 0 );

Or you can just re-add your button just after your image so your button wiill be on the front:

var myBitmapDataObject:bedroomCellPhoneD = new bedroomCellPhoneD( 100, 100 );
var myImage:Bitmap = new Bitmap( myBitmapDataObject );
// add the image
addChild( myImage );
// re-add the button on top of the image
addChild( myButton );

I hope that could help you :)

Benjamin BOUFFIER
  • 946
  • 1
  • 5
  • 7
  • Thank you so much Binou! I used addChildAt( myImage, 0 ) instead of addChild(myimage) and it worked perfectly! The button is on top. Thank you my good sir – user3044394 Nov 28 '13 at 06:10