Accessing IK structures within movieClips??
Greetings everyone!
My name is Chris and I have recently begun working with Adobe Flash CS5 and Actionscript 3.0. I have a good bit of knowledge regarding OOP underneath my belt, and working with AS3 has so far been pretty awesome. That being said I am having a little bit of trouble working with Inverse Kinematic structures and AS3. Here is my predicament:
So what I would like to have is a number of tentacles on the stage that reach out for the mouse cursor. Through all the tutorials and whatnot that I have sorted through thus far I have gotten it working, however I have only gotten it working when the armatures are placed in the main scene. I have made a tentacle movie clip that has an armature within it and placed a number of those within the scene. I can modify the positions of the endJoints of those tentacle movie clips by gaining reference to the respective armatures using the following code:
BEGIN CODE
var i:int;
for (i=0; i<IKManager.numArmatures; i++)
{
var arma:IKArmature = IKManager.getArmatureAt(i);
var topBone:IKBone = arma.getBoneByName("topBone");
var endJoint:IKJoint = topBone.tailJoint;
var curPoint:Point = endJoint.position;
thePosition = endJoint.position;
var theMover:IKMover = new IKMover(endJoint,curPoint);
moverArray.push(theMover);
}
END CODE
Where moverArray is a vector of IKMovers. I then use the following code to move the tentacles toward the mouse pointer:
BEGIN CODE
var i:int;
for (i=0; i<moverArray.length; i++)
{
moverArray.moveTo(thePosition);
}
END CODE
Where thePosition is a point containing info about mouseX and mouseY. Like I said earlier this works perfectly for any armatures that are placed in the main scene, however the coordinate system is apparently different for any armatures that are placed within movie clips. I did a bit of an experiment to confirm this. I traced the following two numbers mouseX and poker1.mouseX (poker1 is the name of an instance of my tentacle movie clip that has been placed on the main scene) . Sure enough the two numbers were different.
So now that you all know where I am currently at, I would like to pose the following two questions:
1) Is there a way that, if I fill a vector full of IKMovers attached to armatures that have been referenced as I currently am doing (referencing the armatures using IKManager.getArmatureAt();) is there a way that I can trace back from the IKMover to the movie clip that contains the armature that contains the IKMover's point so that I can then find the mouseX and mouseY points relative to the said movie clip and thus animate the tentacle appropriately?
2) Is there a way that I can access an armature that is within a movie clip other than what I am currently doing? I have tried doing movieClipInstanceName.IKManager.GetArmatureByName("ArmatureName"); but I get the following error: TypeError: Error #1010: A term is undefined and has no properties, even though I can still call to movieClipInstanceName.x and movieClipInstanceName.y without error.
I know this might be a bit of a confusing question, so if any clarification is needed please let me know. Otherwise thank you all for helping me out ![]()
