you need to make all parts you want to replace exported for actionscript and call them in your class by the name you export (a class in a sort of kind of way, but literal in flash). You will get warnings about nothing referencing it, etc, until you put it in your .as class for your main flash body (timeline base, the main class / whatever name you like as long as your .as matches it).
Then by addChild the movieclip 'class' instance you create to the ikNode you want it to follow, or really be ontop of, it will go along with it.
note:I have noticed that if you have an armature animation on the main timeline, it works when testing in flash IDE [test movie] and loops just fine, but in an embed (object) it will not start the animation, and an additional timeline layer with the script of simply
Code: Select all
play();
Code: Select all
play();
Here it is in action
here is a ZIP of the project CS5 format
http://www.supercala.net/tuts/flash_ik/ ... follow.zip
Here is the as3 class
Code: Select all
package
{
/*
simple ik attachment example v1.0 by Kristoffe Brodeur. ©2010 All Rights Reserved.
11-24-2010
*/
//import flash.display.MovieClip;
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.system.*;
//-----
public class follow_ikNode extends MovieClip
{
public var mc_follow:mc_dup;
public var mc_mask1:mc_mask;
public var flowerLdr:Loader;
public var mcFlower:MovieClip;
//-----
public function follow_ikNode():void
{
/*
without this line, the php loads as a text file, instead of the 'server' during testing
local host with flash needs the php installed in apache etc to run
*/
Security.allowDomain("*");
mc_follow=new mc_dup();
mc_mask1=new mc_mask();
mc_mask1.x=(mc_follow.width-mc_mask1.width)/2;
mc_mask1.y=(mc_follow.height-mc_mask1.height)/2;
ikNode_renamed.addChild(mc_follow);
ikNode_renamed.addChild(mc_mask1);
mc_follow.mask=mc_mask1;
//
load_example_image();
}
//-----
public function attach_example_image(e:Event):void
{
var resize:int=84.95;
flowerLdr.width=resize;
flowerLdr.height=resize;
mcFlower.addChild(flowerLdr);
ikNode_3.addChild(mcFlower);
}
//-----
public function load_example_image():void
{
mcFlower=new MovieClip();
flowerLdr=new Loader();
var filename="sunflower.jpg";//600w x 600h jpg image
var reqURL:URLRequest=new URLRequest(filename);
flowerLdr.addEventListener(Event.ADDED,attach_example_image);
flowerLdr.load(reqURL);
}
}
}