Shop Mobile More Submit  Join Login
Warning: This tutorial is very old and the links in it are no longer valid.
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:
 
:icongaminggoru:
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?

Reply
:icondoom-the-wolf:
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: doom-the-wolf.deviantart.com/g… .
Reply
:icondabatch:
Dabatch Featured By Owner Nov 7, 2013
It isn't working once you change the release code, it makes it not release for me.
Reply
:icondoom-the-wolf:
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.
Reply
:icondabatch:
Dabatch Featured By Owner Nov 7, 2013
Never mind, it's working now.
Reply
:icontwisty1010:
twisty1010 Featured By Owner Jul 1, 2013   Artist
Kripes
Reply
Hidden by Owner
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Nov 23, 2012
I cannot allow these kind of messages to spread around the internet more than they already have.
Reply
:iconpinkandfriends:
pinkandfriends Featured By Owner Nov 23, 2012  Student Digital Artist
im sorry, you may remove it if you lik
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Nov 23, 2012
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 Featured By Owner Nov 23, 2012  Student Digital Artist
yes mam/ sir
Reply
:iconkuchiyuki:
Kuchiyuki Featured By Owner 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:
Doom-the-wolf Featured By Owner Aug 22, 2012
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
:iconmad-monkey-queen:
Mad-Monkey-Queen Featured By Owner Oct 12, 2013
That's the problem I'm having. :XD: I'm pretty good with computers but know nothing about programming. :XD:
Reply
:iconkuchiyuki:
Kuchiyuki Featured By Owner 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 Featured By Owner Aug 21, 2012  Hobbyist General Artist
Nevermind,I fixed it.
Reply
:iconbobstickles:
Bobstickles Featured By Owner 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
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner May 19, 2012
I dont have any Flash version beyond Flash CS3. So I can't open that file. Do you know how programming works? It looks to me like there are some concepts you don't understand.

I have an 11 chapter tutorial on ActionScript, in a gallery folder labeled "Learn Things", which will explain all of the important concepts in detail.
Reply
:iconbobstickles:
Bobstickles Featured By Owner May 20, 2012  Hobbyist Digital Artist
ah okay, I only know the basics really.
I'll read through it then, thank you for responding :)
Reply
:iconjackaw78:
jackaw78 Featured By Owner Apr 9, 2012
where did you get actionscript 3.0 i tried to download it and it didnt work it actullay crashed my computer:pissedoff::tombstone:
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Apr 9, 2012
I don't understand what you mean. ActionScript isn't a program, it's a language. Flash is the program you need. Try to find it on Adobe.com. There might be a trial version.
Reply
:iconsashiiko-anti:
Sashiiko-Anti Featured By Owner Feb 21, 2012  Student Interface Designer
Hi!i was really happy to find such a nice tutorial but somehow i got a mistake in my code and can't figure out what to do.
it says i have a syntax error in those 2 lines
  if(i.indexOf("_drag") > -1){
     _root[i].onPress = function(){

i will really appreciate if you could help me!
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Feb 22, 2012
Those two lines seem to be correct. The error could be on any of the lines previous to those. Check them carefully for mistakes.

But I highly discourage you from using code you don't understand. If you don't know about programming, you should check out my 11 part series about ActionScript. I have a folder in my gallery dedicated to that, it's called "Learn things"
Reply
:iconsashiiko-anti:
Sashiiko-Anti Featured By Owner Feb 22, 2012  Student Interface Designer
thank you for reply!
well- i'm new to programming but i do understand the purpose of every line and what evey element does- you made very nice expanations for every code! so it's not like it's some kind of foreign language for me. that's why i feel sad that i couldn't find the mistake.
but thank you anyway!
Reply
:iconxxdarkreshiramxx:
xXDarkReshiramXx Featured By Owner Feb 14, 2012
thanks now i made my first flash game :dance:
Reply
:icon26nitonic:
26nitonic Featured By Owner Jan 19, 2012  Hobbyist General Artist
oisome
Reply
:iconkingdesmond:
kingdesmond Featured By Owner Dec 31, 2011  Student General Artist
Epic.
Reply
:iconuberfrill14:
uberfrill14 Featured By Owner Sep 22, 2011  Hobbyist General Artist
I think you make better tutorials than the other guys on this site.
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Sep 22, 2011
Many of the tutorials on deviantart are made by people who don't even know what they are teaching. I made this one to give people the right kind of information.
Reply
:iconuberfrill14:
uberfrill14 Featured By Owner Sep 22, 2011  Hobbyist General Artist
Well, you did your job well. Thanks.
Reply
:iconfoxesgoquack:
foxesgoquack Featured By Owner Jan 12, 2011
Why, if you know how to, have you never made a dressup? (just wondering)
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Jan 12, 2011
It's because they are overused, overrated and, ultimately, very boring. I think adding one more to the list of thousands would be a waste of space on the internet.
Reply
:iconabstract-panda:
abstract-panda Featured By Owner May 6, 2011  Professional Digital Artist
Wow. If you think so than it's really weird that you made this tutorial. Wonder why.
But anyway it is useful, thank you.
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner May 6, 2011
It was to try to undo the wrong teaching that the other tutorials do. Many of the people who make dress-up tutorials don't even know what the code means and aren't really qualified to teach other people.
Reply
:iconabstract-panda:
abstract-panda Featured By Owner May 7, 2011  Professional Digital Artist
So you managed not to let your disgust get the better of you :) Nice job!
Reply
:iconzoecreed:
zoecreed Featured By Owner Dec 8, 2010  Student General Artist
wowy
Reply
:iconmagiclove24:
magiclove24 Featured By Owner Dec 6, 2010  Hobbyist Traditional Artist
ARGH!!! it won't work!!! can you give me a link?????
Reply
:icontwilightluv10:
TwilightLuv10 Featured By Owner Nov 7, 2010  Hobbyist General Artist
Nice tutorial!!!
Reply
:iconhapuriainen:
Hapuriainen Featured By Owner Nov 5, 2010  Hobbyist Digital Artist
What version of Flash is this for? Now I have the basic knowledge of java so I tried to use this, but I get a syntax error for the first two rows of the loop. I'm wondering if I'm using a different version or something like that, because I copypasted the code.
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Nov 5, 2010
This should work with Actionscript 2.0. But you need to understand the code in order to use it.

I discourage copying and pasting code, some of the elements in the code depend on parts of the stage. Try to write the code yourself based on what you learned in the tutorial.
Reply
:iconhapuriainen:
Hapuriainen Featured By Owner Nov 5, 2010  Hobbyist Digital Artist
I do understand mostly what the code is about (I decided to study the basics of java before even trying to do anything with this tutorial), I just copypasted it because I thought it was the best way to avoid typos. I guess I still managed to make a typo then.
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Nov 6, 2010
It is highly possible that the code itself is not suitable for your program. You should read the error messages and try to correct them. The error messages are usualy self-explanatory.
Reply
:iconhapuriainen:
Hapuriainen Featured By Owner Nov 6, 2010  Hobbyist Digital Artist
I guess it's possible that the code is not suitable for my program for some reason then. I'll try it again some other time.

The error message doesn't say anything else but "syntax error", which doesn't help me too much.
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Nov 6, 2010
Program? If you have Flash 8 or higher and you're using Actionscript 2.0, it will work.
Reply
:iconhapuriainen:
Hapuriainen Featured By Owner Nov 6, 2010  Hobbyist Digital Artist
I guess I made a typo then. I don't know how it's possible though since I copypasted the code and didn't alter the loop part yet (I wanted to see if it worked properly before altering it to fit my needs), but maybe a new attempt will be more succesful.
Reply
:icondoom-the-wolf:
Doom-the-wolf Featured By Owner Nov 6, 2010
You must have gotten something more than just "Syntax Error". The program should tell you what line it's on. Then you can find out what's wrong with the line.

I still recommend using the code, not as a base for modification, but as a base for understanding. Instead of copying it and changing it, you should read it, learn from it and then rewrite your own version of it.

For how long have you had programming experience?
Reply
(1 Reply)
:iconpikachu91:
Pikachu91 Featured By Owner Oct 29, 2010
thanks but i dont know how to open actionscript!!!!! i downloaded it but i cant use it!!!
Reply
Add a Comment:
 
×




Details

Submitted on
January 5, 2010
Image Size
496 KB
Resolution
800×600
Link
Thumb
Embed

Stats

Views
55,207 (5 today)
Favourites
264 (who?)
Comments
82
Downloads
496
×