Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Simple 1120: Access to undefined property error

Community Beginner ,
Feb 25, 2016 Feb 25, 2016

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

TOPICS
ActionScript
387
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 25, 2016 Feb 25, 2016

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:

...
Translate
LEGEND ,
Feb 25, 2016 Feb 25, 2016

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});
}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Feb 25, 2016 Feb 25, 2016
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines