Tip – loading a swf with a Bones Armature (IK) into another swf

A few people have asked me how to load a swf file that contains an armature, into another swf file. If you just try to do it the armature doesn’t work. The trick is that you need to register the armature in the loader file. I have attached a couple of very simple files to demonstrate. The bones.swf contains a simple armiture set to ‘Runtime’. The ‘loader.swf’ loads the bones.swf and registers the armature. For more info check out the new IK class in Flash CS4.


import fl.ik.*;
import flash.display.*;

//load the bones swf
var request:URLRequest = new URLRequest("bones.swf");
var loader:Loader = new Loader();
loader.load(request);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, init);

//set up the vars
var boneClip:Sprite;
var myArmature:IKArmature;

function init(e:Event):void{
	//add the clip to the stage
	boneClip = Sprite(loader.content);
	addChild(boneClip);
	//set up IK
	IKManager.setStage(stage);
	myArmature = IKManager.getArmatureAt(0);
	myArmature.registerElements(stage);
	IKManager.trackAllArmatures(true);
}

You can download the example here.

Tags: , ,

7 Responses to “Tip – loading a swf with a Bones Armature (IK) into another swf”

  1. Shamsul Ismin Tumin Says:

    Thanks for the Talks at Adobe Creative Suite 4 launch in Kuala Lumpur on 11 November 2008. The Adobe Team has done a good job by reinventing, restructured, redesigning and integrating all the Adobe Application.I was so impressed with it.

    I’m a photographer/graphic/web designer and I used all the Adobe Applications. Adobe CS4 gonna ROCK my WORLD… AWESOME!!! CS = Cool Stuff heheheheh :-)

  2. ricky williams Says:

    saved me some serious frustration dude. thanks a million.

  3. Tony DiPerna Says:

    Thanks man, this really helped! I spent the last hour pulling out my hair over this.

  4. Flex et inverse kinematics (Bones) at Proxymis Multimedia BLOG Says:

    [...] http://www.mad.com.au/blog/?p=208=1 [...]

  5. yarek Says:

    How to DUPLICATE a movieclip that contains BONES and keep the position of the bones in the duplicated movie ?

  6. paul Says:

    Hey there. I just tried this out in 2 ways to see if there was an issue and all worked as expected. The first way was by creating a movie clip with an armature in it and duplicating the instance on the stage. The second was by creating an armature in a movie clip on the stage, duplicating it in the library then dragging the duplicate to the stage. It worked both ways. All the bones in the duplicates were in the same place and behaving properly. So I am not sure what you are asking? But all seems fine at this end?

  7. daniel Says:

    i looked for a solution to this for days. my main site uses this, and i really didn’t want to redesign. thanks a million

Leave a Reply