Copy link to clipboard
Copied
//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
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);
}
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
kglad sir ,
it still does not working
Copy link to clipboard
Copied
what do you see that makes you think it's not working?
Copy link to clipboard
Copied
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at csdone_fla::MainTimeline/FRAME()
yes. this error does not come if i write addChild(lastmc);
but it comes if i write your code myMovieClipbg.addChild(lastmc);
Copy link to clipboard
Copied
then either myMovieClipbg doesn't exist, or you made it local to a function or some other timeline.
Copy link to clipboard
Copied
yes. now its working . its my bad. i fixed the bug . and now myMovieClipbg.addChild(lastmc); working fine
thanks sir for helping
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now