Wednesday 15 September 2010

actionscript: acces now object instance -


My problem is that after creating new movie clips by me, I do not know how to access them

  Miscellaneous numOfBalls: int = 5; Var Balls: Array = New Array (); Import flash.utils.getDefinitionByName; Function addBall (instanceName: string) {var mciname: String = "ball"; Var tMC: class = getDefinitionByName (mciname) as class; Var newMc: MovieClip = new TMC () movie clip; Newmc.name = instanceName; Trace ("added" + newmc.name); NewMc.x = Randrends (10, 300); NewMc.y = Randrends (10, 300); AddChild (newMc); Turn it back. Newmc; } Function Randrange (start: number, end: number): number {return mathematical (start + (Math.rendum) * (end-start)); } Var i = 0; While (i & lt; numOfBalls) {ball [i] = adobe ("ball_" + i); I ++; } Trace (this.balls [0]); // returns error trace (this.balls_0); // return error  
  addBall function (instanceName: string): movie clip {Var mciname: string = "ball"; Var tMC: class = getDefinitionByName (mciname) as class; Var newMc: MovieClip = new TMC () movie clip; Newmc.name = instanceName; Trace ("added" + newmc.name); NewMc.x = Randrends (10, 300); NewMc.y = Randrends (10, 300); AddChild (newMc); Return to New Mac; }  

Fix it. Returned to the movie clip, and right bit, instead of returning to newMc. Newmc; The new MC is not related to this.

If you had it. Newmc = newMC can be.


No comments:

Post a Comment