deviant art

Deviant Login Shop  Join deviantART for FREE Take the Tour
[x]
Download File
SWF, 496 KB
more ▶

More from *Doom-the-wolf

Featured in Groups:

Details

January 5, 2010
496 KB
800×600
Link
Thumb

Statistics

Comments: 72
Favourites: 256 [who?]

Views: 47,358 (7 today)
Downloads: 465 (0 today)
[x]
:icondoom-the-wolf:
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 for..in 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){
    E.currentTarget.startDrag();
    }
    function dropItem(E){
    clip = E.currentTarget;
    clip.stopDrag();
    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:
 
love 2 2 joy 7 7 wow 1 1 mad 0 0 sad 0 0 fear 0 0 neutral 0 0
Hidden by Owner
:icondoom-the-wolf:
I cannot allow these kind of messages to spread around the internet more than they already have.
Reply
:iconpinkandfriends:
~pinkandfriends Nov 23, 2012  Hobbyist Filmographer
im sorry, you may remove it if you lik
Reply
:icondoom-the-wolf:
I recommend you not to spread messages that ask you to send them to other people. I also recommend you to tell other people to do the same. Maybe one day those messages will cease to exist.
Reply
:iconpinkandfriends:
~pinkandfriends Nov 23, 2012  Hobbyist Filmographer
yes mam/ sir
Reply
:iconkuchiyuki:
Mood: Optimism !Kuchiyuki Aug 19, 2012  Hobbyist General Artist
Thank for making this~ It save a lot of time.

But, I'm having problems with the snapping/Pythagoras's Theorem code. I get how it works and all the pieces of it. The movie clips drag perfectly without the code, but once I put the code in, it stops. I'm not getting any errors. The code is fine. I checked billions of times for typos (and I've put it in at least 10 times.) I'm just wondering.. is there something I'm missing?

I'm only up to that part on the tutorial, if that's important.
Reply
:icondoom-the-wolf:
I'm not sure if you know programming or not. But it would be better if you did. Trying to use code you don't understand can be a problem. I haven't seen what you did, so I can't explain where you went wrong.
Reply
:iconkuchiyuki:
!Kuchiyuki Aug 22, 2012  Hobbyist General Artist
I just was putting an extra semicolon somewhere. I understand it 50/50. I'm going to read your tutorials though.
Reply
:iconkuchiyuki:
!Kuchiyuki Aug 21, 2012  Hobbyist General Artist
Nevermind,I fixed it.
Reply
:iconbobstickles:
*Bobstickles May 19, 2012  Hobbyist Digital Artist
hi, i'm having some trouble with the 2 parts code, I've copied in the loop code do i need to change the [i] to anything like the instance name of the doll? I named my 2 pieces the same as yours just to make it easier to understand but when I test movie I get error codes ^^; I was wondering if you could take a look at it for me and let me know [link] it's a cs5.5 document if that's okay it's only a test file so feel free to scribble on it, thank you so much if you can help :)
Reply
Add a Comment: