1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
import fl.transitions.*;
import fl.transitions.easing.*;
import fl.ik.*;
var squelette:IKArmature = IKManager.getArmatureByName("Bonhomme");
var os_bras_gauche:IKBone = squelette.getBoneByName("os_bras_gauche");
trace(os_bras_gauche.hasOwnProperty("length")); //false
var el1:Tween = new Tween(bras_gauche, "scaleX", Regular.easeIn, 1, 2, 2, true);
var el2:Tween = new Tween(bras_gauche, "scaleY", Regular.easeIn, 1, 2, 2, true);
el2.addEventListener(TweenEvent.MOTION_FINISH, scaling_finished);
function scaling_finished(evt:TweenEvent):void {
resize_bone(os_bras_gauche, 2);
}
function resize_bone(bone, ratio) {
var hj:IKJoint = bone.headJoint;
var tj:IKJoint = bone.tailJoint;
var pos_head : Point = hj.position;
var pos_tail : Point = tj.position;
var tail_mover:IKMover = new IKMover(tj, pos_tail);
pos_tail.x = pos_head.x + ((pos_tail.x - pos_head.x) * ratio);
pos_tail.y = pos_head.y + ((pos_tail.y - pos_head.y) * ratio);
tail_mover.moveTo(pos_tail); //Crée un déplacement
var bone_length = Math.sqrt(Math.pow(pos_head.x = pos_tail.x, 2) + Math.pow(pos_head.y = pos_tail.y, 2));
trace(bone_length);
} |
Partager