0

so I was wondering if there was a way to reference different objects on stage with he same method to save repeating lots of lines of code. This is what I have right now

function bossKilled(i:Number):Void {
  trace("Boss Killed!");
  kills ++;
  _root.bossDeath.gotoAndPlay(2);
  _root["pirate"+i+"Active"] = false;  //name of variable would be pirate1Active
  _root["pirate"+(i+1)+"Active"] = true;  //name of variable would be pirate2Active
  bossDeath._x = _root["pirate"+i+"Active"]._x;
  bossDeath._y = _root["pirate"+i+"Active"]._y; }

However, this reference does not actually affect the variables. I was wondering if this was possible, and if so, what am I doing wrong? Thanks.

aeronaut
  • 53
  • 1
  • 7
  • what kind of reference you are looking for? what arguments should be passed to method you seek? its is not clear from your code sample – Aspiro Jun 06 '15 at 18:19

1 Answers1

0

Not sure what you try to achieve ... pirate1Active is a BOOL. A BOOL has no _x or _y property (nor any other).

If you are not sure where to find your objects in the object tree, you can use the debugger or add some traces on the MCs timeline, like trace (_parent);

Consider switching to AS3, it is much more object oriented and has better tools support.

dogsgod
  • 6,267
  • 6
  • 25
  • 53