Question

So, basically, what I want to do is replace the contents of a sword MovieClip that's inside a Player MovieClip already, and is animated, so it has multiple instances of the sword MovieClip across the Player MovieClip.

Can I somehow edit the contents of the sword MovieClip in actionscript so as all the sword MovieClips update and are changed?

What I want to achieve is just changing weapons of a character animation that doesn't require me to await every frame and removeChild() the previous weapon and addChild() the new one of every instance of the weapon.

Was it helpful?

Solution

I'm not sure I'm getting it but Maybe you need a weapons event class package WeaponEvents{ import flash.events.Event;

[Event(name="sword1", type="event.sword1")]
[Event(name="sword2", type="event.sword2")] 


public class SwordEvent extends Event
{

    public static const SWORD_1 : String = "sword1";
    public static const SWORD_2 : String = "sword2";

    public var arg:*;

    public function SwordEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, ... a:*) {
        super(type, bubbles, cancelable);
        arg = a;

    }

// Override clone override public function clone():Event{ return new LoadEvent(type, bubbles, cancelable, arg); } } }

Just add the event to when your user chagnes weapons.

OTHER TIPS

I'm in a similar boat as you. Except I have 30-50 bodyparts to cover, so I really can't go the brute force way.

If it's just sword that you want replace though, I assume in the animation it is on its own layer? Then a "cheap way" I found is:

  1. Copy paste all frames in that layer (and only that layer) into another movieclip i.e. Sword1Swing.
  2. Remove that layer (and only that layer) from your MC animation.
  3. In yet another movie layer, put Sword1Swing on frame 1, Sword2Swing on frame 2, etc.
  4. MC.gotoAndStop("SwordSwing"); SwordMC.gotoAndStop("Sword1Swing");
  5. As long as you keep the .x and .y of the SwordMC synchronized with MC, the animation should always line up.
  6. Hand often goes over the top of the sword, in which case... You can copy the hand too. Or the whole arm. Or you can custom shape your sword symbol's basic graphics in the library to match exactly with the empty spaces between fingers (copy and paste hand graphics in place to remove unwanted portions, then delete the hand graphics, then you'll have the perfect shape).

It's the ghetto way I know, I am very much in need of an actual efficient swapping. But this may help you to get through the project fast.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top