Shop Mobile More Submit  Join Login


Submitted on
January 5, 2010
Image Size
496 KB


54,452 (6 today)
261 (who?)
Well, after making my first tutorial. I decided that making a Dress-up tutorial wouldn't be too hard. I tried a bit harder to decorate.

Almost every dress-up game on deviantart has the same few mistakes. And the reason is because the makers spend most of their time drawing and don't see the importance of Actionscript. Then they copy and paste what I call "The Sacred Code" on every MovieClip.

So this tutorial will focus on the problems and will show you how to solve them. However, there are many more things you can do than what you find in this tutorial. Don't stop here.

Tiny intro to ACTIONSCRIPT 3.0

I should add that Actionscript 3.0 doesn't use the same code as before. What you learned here will not be very useful.
  • Events are handled with the function addEventListener().

  • The press and release events disappear and the mouseUp event only handles events within the MovieClip.

  • _root disappears and is substituted by stage.

  • The loop no longer gets MovieClips. It only gets variables. To get MovieClips, you'll have to use the getChildAt(N) function, where N ranges from 0 to the number of MovieClips contained.

  • The this operator only works within object methods. In the events it's replaced with the currentTarget property of the input parameter.

  • All variables starting with "_" lose it. So "_x" becomes "x", "_y" becomes "y", "_visible" becomes "visible" and so on.

  • And a pile of other changes. Maybe you should stick with Actionscript 2.0

  • But if you want to try Actionscript 3.0, your code might look a bit more like this:

    //All the MovieClips destination points
    rightarmplate_drag.dX = 120;
    rightarmplate_drag.dY = 56;
    lefttarmplate_drag.dX = 120;
    //Write this code for every single object you have
    rightarmplate_drag.addEventListener( "mouseDown", dragItem);
    rightarmplate_drag.addEventListener( "mouseUp", dropItem);
    lefttarmplate_drag.addEventListener( "mouseDown", dragItem);
    lefttarmplate_drag.addEventListener( "mouseUp", dropItem);
    //These two functions are universal
    function dragItem(E){
    function dropItem(E){
    clip = E.currentTarget;
    var distX:Number = clip.dX-clip.x;
    var distY:Number = clip.dY-clip.y;
    var distance:Number = Math.sqrt(distX*distX+distY*distY);
    if(distance < 20){
    clip.x = clip.dX;
    clip.y = clip.dY;
Add a Comment:
GamingGoru Featured By Owner May 5, 2014  Student Digital Artist
I got the code for the destination positions to work (and it's amazing), but I'm stuck on the code for connected movie clips. On line 6 (Where the .onMouseMove function Is) I get the error: "Operator '=' must be followed by an operand"
And then the next two lines both get Syntax Errors. I haven't done anything different to the whole code except change their instance names (but they still have _drag in them). How do I fix these errors?

Doom-the-wolf Featured By Owner May 5, 2014
I can't solve the problem without some code to look at. Send me a note with the part of the code that's giving you errors. I also recommend not working with code you don't understand. If you're new to programming, you should go check my ActionScript tutorials here:… .
Dabatch Featured By Owner Nov 7, 2013
It isn't working once you change the release code, it makes it not release for me.
Doom-the-wolf Featured By Owner Nov 7, 2013
This code is for teaching purposes only. You're supposed to write your own code using the knowledge you gained in this tutorial.
Dabatch Featured By Owner Nov 7, 2013
Never mind, it's working now.
twisty1010 Featured By Owner Jul 1, 2013   Artist
Hidden by Owner
Add a Comment: