Note: When referencing IKArmature objects within a document class, be sure to first check the frameConstructed event to ensure that all objects have been populated.
else IKManager.numArmatures = 0 and IKManager.trackAllArmatures(false) will not work.
the bad thing is frameConstructed runs every frame. so one way is to use a boolean variable to track and run the code once.
can also use ENTER_FRAME
eg.:
public function IK_MC() // constructor
{
trace("start ik");
IKManager.trackAllArmatures(false); // will not work
this.addEventListener(Event.ENTER_FRAME, constructed);
}
function constructed(e:Event):void
{
//trace(IKManager.numArmatures);
if(IKManager.numArmatures > 0 && !init)
{
IKManager.trackAllArmatures(false);
var arm:IKArmature = IKManager.getArmatureByName("Armature_2");
trace(arm);
var arm2:IKArmature = IKManager.getArmatureAt(0);
trace(arm2);
init = true;
}
}
No comments:
Post a Comment