Skip to main content
Inspiring
January 29, 2016
Answered

addChildAt for top layer confusion

  • January 29, 2016
  • 1 reply
  • 702 views
//Level 2

if (score==10 && score<30 ){

var myMovieClipbg:winbg = new winbg();

myMovieClipbg.x = 0;

myMovieClipbg.y = 5;

addChildAt(myMovieClipbg,1);

}

//level 3

else if (score>30 && score<60){

var lastmc:tired = new tired();

lastmc.x = 0;

lastmc.y = 0;

addChildAt(lastmc, 1);

}

"lastmc" should be top layer background when score is greater than 30 . but its not working . moreover if i use addChild(lastmc) . it becomes top of all layer . so My hero and enemies everything go down. i can not play . but  need lastmc just top of myMovieClipbg background layer .

i assume the confusion coming from addChildAt


note addChildAt(myMovieClipbg,1); is working fine for second level. it brings the background top of first background .

but addChildAt(lastmc, 1); is failing to bring the background of of second background

This topic has been closed for replies.
Correct answer kglad

try:

tanvira5454192 wrote:

//Level 2

if (score==10 && score<30 ){

var myMovieClipbg:winbg = new winbg();

myMovieClipbg.x = 0;

myMovieClipbg.y = 5;

addChildAt(myMovieClipbg,1);

}

//level 3

else if (score>30 && score<60){

var lastmc:tired = new tired();

lastmc.x = 0;

lastmc.y = 0;

myMovieClipbg.addChild(lastmc);

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 29, 2016

try:

tanvira5454192 wrote:

//Level 2

if (score==10 && score<30 ){

var myMovieClipbg:winbg = new winbg();

myMovieClipbg.x = 0;

myMovieClipbg.y = 5;

addChildAt(myMovieClipbg,1);

}

//level 3

else if (score>30 && score<60){

var lastmc:tired = new tired();

lastmc.x = 0;

lastmc.y = 0;

myMovieClipbg.addChild(lastmc);

}

Inspiring
January 29, 2016

kglad sir ,

it still does not working

kglad
Community Expert
Community Expert
January 29, 2016

what do you see that makes you think it's not working?