Basically, what you need to do is first have animations for the guy swinging the sword (without the sword). Set it up so this plays when you press a key. Have another actor that is the sword, which lines up with the player doing the same animation. When it is swinging, set a variable (you might want a few values so you can have a more powerful swing as well), and when not swingin, the variable should be 0. When the sword collides with an enemy, check the variable and do damage accordingly.
The alternate method is to use three actors:
- One graphic which includes both player and sword, and doesn't collide with anything.
- One separate mask, which is invisible, which the graphic is parented to. This should do all the events that the player normally would.
- On attack mask, also invisible (this need only be created when attacking). This does the damage.
Both ways have pros and cons.