Copy link to clipboard
Copied
Anyone want to take a stab at what I'm sure is a simple "1120" error?
1120: Access to undefined property circle_inst.
It's in the final function: "removeChild(circle_inst);"
If I remove the offending line, everything runs fine. The "circle_inst" appears, runs through its tween, but it is not removed.
//add box
var box_inst: box = new box();
addChild(box_inst);
box_inst.x = 200
box_inst.y = 200
//fade box in and out
TweenMax.fromTo(box_inst, 1, {alpha: 0}, {alpha:1,repeat: 1,repeatDelay: 5,yoyo: true,onComplete: removeBox});
//remove box and add circle
function removeBox(): void {
removeChild(box_inst);
var circle_inst: circle = new circle();
addChild(circle_inst);
circle_inst.x = 200;
circle_inst.y = 200;
//fade circle in and out
TweenMax.fromTo(circle_inst, 1, {alpha: 0}, {alpha:1,repeat: 1,repeatDelay: 5,yoyo: true,onComplete: removeCircle});
}
//remove circle and add star
function removeCircle(): void {
removeChild(circle_inst);
var star_inst: star = new star();
addChild(star_inst);
star_inst.x = 200;
star_inst.y = 200;
TweenMax.fromTo(star_inst, 1, {alpha: 0}, {alpha:1,repeat: 1,repeatDelay: 5,yoyo: true});
}
Thanks
The object is not in scope for the function trying to target it because you declare it inside another function. You should declare it outside and then you can instantiate it inside the function.
var circle_inst: circle;
//remove box and add circle
function removeBox(): void {
removeChild(box_inst);
circle_inst = new circle();
addChild(circle_inst);
circle_inst.x = 200;
circle_inst.y = 200;
//fade circle in and out
TweenMax.fromTo(circle_inst, 1, {alpha: 0}, {alpha:1,repeat: 1,repeatDelay: 5,yoyo:
Copy link to clipboard
Copied
The object is not in scope for the function trying to target it because you declare it inside another function. You should declare it outside and then you can instantiate it inside the function.
var circle_inst: circle;
//remove box and add circle
function removeBox(): void {
removeChild(box_inst);
circle_inst = new circle();
addChild(circle_inst);
circle_inst.x = 200;
circle_inst.y = 200;
//fade circle in and out
TweenMax.fromTo(circle_inst, 1, {alpha: 0}, {alpha:1,repeat: 1,repeatDelay: 5,yoyo: true,onComplete: removeCircle});
}
Copy link to clipboard
Copied
Thanks, Ned. Worked great.
Could I declare all the variables for my movie clip instances at the start of my actionscript?
And the larger question is . . . if I am going to have a couple dozen movie clips loading sequentially, one after another, all in the same location (container?) and all with the same tween applied, could this be done in an array of some kind?
Thanks again, Ned.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now