开发者

Swapping movieclips with other assets at runtime in a Flash component

I have an animated character swc that is an empty skeleton basically (has all the body parts, animations, and functions/vars). I want to essentially put different clothes on that character at runtime so I don't have to have many copies of this character in my resources.

For example, I have 'skeleton' (the non-clothed model) and 'Bob', 'Jane', and 'Mary' characters. 'skeleton' is animated and fully works as an exported swc, and to get the other characters in their clothes/skins, I open up Flash CS5 and replace the movie clips with the 'clothed' versions of the components. To clarify,'skeleton' has "b开发者_开发技巧ody parts" as movie clips that are all animated on the timeline, such as "head","face","left arm","right arm", etc. I open up 'Bob', who has the same exact design as 'skeleton', with the exception that 'Bob' has all the clothes and such as differently-designed movie clips. The size, shape, orientation, and reg points are all the same across all the components. After I've replaced all the movie clips in 'skeleton', I export it as a swc named 'Bob.swc' and I do this for all the characters.

What I'm asking is, how can I do this process ^, but at runtime instead, so I don't have all these duplicate root swcs ('skeleton' has a lot of frames on it) so I can cut down on a bunch of space? So I can do something like:

// bob gets all the actions and animations  of skeleton
var bob:UIMovieClip = new skeleton() 
// replace the body movieclip with a new looking one
bob.body = resources.bodyassets['bob']['body'] 

Or something similar to that?


Would adding the skin parts as children of your skeleton parts work ? Could you have 'guide' movie clip inside each body part which helps you animate then another empty movie clip sibling to the 'guide', inside body where you'll add the skin ? If you add the skin inside the animated body part it should copy it's transforms(position/rotation/scale). something like :

    var bob:UIMovieClip = new skeleton() 
    bob.body.skin.addChild(resources.bodyassets['bob']['body']);
    bob.body.guide.visible = false;

if the bob.body contains shapes, or a single movieclip, you should be able to something like:

var bob:UIMovieClip = new skeleton();
bob.body.addChild(resources.bodyassets['bob']['body']);//add skin for body
bob.body.graphics.clear();//clear existing template/helper graphics
//or, depdening on the case
bob.body.removeChildAt(0);

HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜