0

I'm a bit new to as3, so forgive me if these are dumb questions. Two questions...

Premise: I'm loading a character from a swf file, and want to add avatar to it. I have him animated walking and also standing (stand_mc, walk_mc). I also have his body parts separated out, so inside each of the animations mc's is a head_mc, body_mc, etc etc.

First question, how can I access the body parts for any animation? here's my code so far:

    var WalkAnim:Class = SWFLoader.getClass('walk_mc'); //Using Greensock loader; but it's the same as using appDomain.getDefinition();
    var walkAnim:MovieClip = new WalkAnim();
    addChild(walkAnim);

Second question, adding walkAnim just creates an instance of the mc definition. How can I edit the definition in the library to do something like..

    var Hat:Class = SWFLoader.getClass('accessory_hat_mc');
    var hat = new Hat();
    WalkAnim:addChild(Hat)//???

So that if I have multiple instances on stage, they'll all be updated. Thanks in advance for the help!

4

1 回答 1

0

基本上,要访问子元素,您使用点语法。这看起来像这样(最后一行):

var WalkAnim:Class = SWFLoader.getClass('walk_mc');
var walkAnim:WalkAnim = new WalkAnim(); // I have typed your var as WalkAnim, not MovieClip.
addChild(walkAnim);
walkAnim.head_mc.rotation += 5;

要回答您的第二个问题,您将无法在运行时编辑定义。您可以向每个实例添加一个项目:

var Hat:Class = SWFLoader.getClass('accessory_hat_mc');
var myHat:Hat = new Hat();
walkAnim.head_mc.addChild(myHat);
于 2012-06-11T04:32:55.667 回答