HOME | DD

pichu90 — Flash Actionscript 3 Tutorial

Published: 2010-12-12 05:07:02 +0000 UTC; Views: 23004; Favourites: 311; Downloads: 434
Redirect to original
Description As I was making dress up games, I was suggested to try using color pickers for changing colors instead of a button that only goes through a limited selection of colors. Unfortunately, Actionscript 2.0, did not have such a thing as a color picker, so I was left with googling and downloading color pickers made by other people that supported that version. I wanted to try Actionscript 3.0 which supported this, but I had to pretty much relearn my actionscript to make dressups work and it was far from easy as I hadn't seen any tutorials for dressups with Actionscript 3.0!

As I was making dressups for the pokemon fifth-generation, I finally put one together using this version. , and others wanted a tutorial in making dressups with color changers. I have procrastinated enough and finally was able to produce a somewhat less confusing tutorial than my other ones I hope ^_^;

Note: I have copied the code I used for the tutorial below, but the drag and drop part of the code only works if you have an object called "santahat" in your project!

Needless to mention, you should have some basic familiarity with Flash to use this tutorial. Constructive feedback welcome as always! ^_^

COLOR CHANGING
import fl.controls.ColorPicker;
import fl.events.ColorPickerEvent;
import flash.geom.ColorTransform;

var BodycolorInfo:ColorTransform = Body.transform.colorTransform;
cpBody.addEventListener(ColorPickerEvent.CHANGE, colorChange);

BodycolorInfo.color = cpBody.selectedColor;
Body.transform.colorTransform = BodycolorInfo;

function colorChange(e:Event):void
{
BodycolorInfo.color = cpBody.selectedColor;
Body.transform.colorTransform = BodycolorInfo;
}

DRAG & DROP

santahat.buttonMode = true;

santahat.addEventListener(MouseEvent.MOUSE_DOWN, hatPickUp);

stage.addEventListener(MouseEvent.MOUSE_UP, hatDropIt);

function hatPickUp(e:MouseEvent):void
{
santahat.startDrag();
}function hatDropIt(e:MouseEvent):void
{
santahat.stopDrag();
}
Related content
Comments: 154

caykie In reply to ??? [2012-04-18 20:20:52 +0000 UTC]

Alrighty c:

👍: 0 ⏩: 0

LexieSkye [2012-04-08 01:58:00 +0000 UTC]

where do you insert this? :

var BodycolorInfo:ColorTransform = Body.transform.colorTransform;
cpBody.addEventListener(ColorPickerEvent.CHANGE, colorChange);

i have a hard time understanding where to put what.

👍: 0 ⏩: 1

pichu90 In reply to LexieSkye [2012-04-11 05:28:40 +0000 UTC]

This I would put in a layer separate from all other objects, along with all color picking code and button actions like reset and item selection :3

👍: 0 ⏩: 0

AskPonySouthAfrica [2012-03-01 04:58:29 +0000 UTC]

((this is really helpful, thankyou for making the tutorial! ^U^))

👍: 0 ⏩: 0

startheeevee1 In reply to ??? [2012-01-16 17:23:17 +0000 UTC]

i do not use that i use paint...

👍: 0 ⏩: 1

pichu90 In reply to startheeevee1 [2012-01-17 04:35:02 +0000 UTC]

Hard to make a dressup with paint

👍: 0 ⏩: 2

Hatty-hime In reply to pichu90 [2012-03-07 06:33:38 +0000 UTC]

This is random, but LOL. Was just browsing through and this made me lose it.

👍: 0 ⏩: 0

startheeevee1 In reply to pichu90 [2012-01-19 01:15:50 +0000 UTC]

I know....

👍: 0 ⏩: 0

azamono In reply to ??? [2012-01-06 14:32:43 +0000 UTC]

You saved my homework lol. THANKS <3

👍: 0 ⏩: 0

pansage3010 In reply to ??? [2011-10-14 18:20:03 +0000 UTC]

do you know how to add music to a dress up game?

👍: 0 ⏩: 1

pichu90 In reply to pansage3010 [2011-10-16 08:13:14 +0000 UTC]

Yes :3

👍: 0 ⏩: 1

pansage3010 In reply to pichu90 [2011-10-17 14:49:50 +0000 UTC]

please can you make a tutorial on how to add music then?

👍: 0 ⏩: 1

pichu90 In reply to pansage3010 [2011-10-19 04:48:17 +0000 UTC]

At some point yes :3

👍: 0 ⏩: 1

pansage3010 In reply to pichu90 [2011-10-19 06:31:18 +0000 UTC]

thanks

👍: 0 ⏩: 0

graciedesign In reply to ??? [2011-09-20 23:29:47 +0000 UTC]

I'll bookmark this one.

👍: 0 ⏩: 0

Snowdrop-The-Glaceon [2011-08-19 14:35:15 +0000 UTC]

1.cover your mouth 2.make a wish 3.put hand to heart 4.copy and paste this to 15 games in one day. 5. tommarow will be the best day of your life.it acutally works.

👍: 0 ⏩: 0

lugia7894 [2011-08-14 23:25:14 +0000 UTC]

I,m sorry it wont work for me

👍: 0 ⏩: 0

RaiderG8-90475 [2011-07-30 13:54:50 +0000 UTC]

1.cover your mouth 2.make a wish 3.put hand to heart 4.copy and paste this to 15 games in one day. 5. tommarow will be the best day of your life.it acutally works.

👍: 0 ⏩: 0

Kittymuffins98 In reply to ??? [2011-07-28 17:56:04 +0000 UTC]

I need help I keep getting Compiler Errors!

👍: 0 ⏩: 1

pichu90 In reply to Kittymuffins98 [2011-07-29 05:14:33 +0000 UTC]

What kind of error exactly? ^^

👍: 0 ⏩: 1

Kittymuffins98 In reply to pichu90 [2011-07-29 10:50:25 +0000 UTC]

Oh wait nvm,I got it..

👍: 0 ⏩: 0

Sonic-Rulz98 [2011-07-08 13:56:53 +0000 UTC]

Does this work in glash 6 MX?

👍: 0 ⏩: 2

pichu90 In reply to Sonic-Rulz98 [2011-07-10 01:30:27 +0000 UTC]

I don't know

👍: 0 ⏩: 0

Sonic-Rulz98 In reply to Sonic-Rulz98 [2011-07-08 13:57:53 +0000 UTC]

oops i mean Flash

👍: 0 ⏩: 0

caykie [2011-07-01 18:17:41 +0000 UTC]

oh btw, sorry for multiple comments
But how do you change multiple colors on it because i want to change like the fur color and ring color on my dress up but how, i tried and it did not work, i even altered the code for the second one to match it. But i got the first color to change.

Also how do you change the colors on a blinking eye?

Thanks

👍: 0 ⏩: 1

pichu90 In reply to caykie [2011-07-17 04:24:28 +0000 UTC]

I may be late in explaining this, but you have to repeat the process for each individual object (like fur color, tail color, etc with different names for each color picker, colorInfo object and item of course ^^

👍: 0 ⏩: 1

caykie In reply to pichu90 [2011-07-18 22:50:54 +0000 UTC]

Okay, i tried that, like rewrote the code and everything replacing the other code but it still doesn't work .w.

👍: 0 ⏩: 0

caykie In reply to ??? [2011-07-01 16:45:53 +0000 UTC]

I have a problem with the color picker. When I did the color picker i set up everything like in the tutorial but, when i change the color in the color picker it does not change the body's color in my dress-up. help?

👍: 0 ⏩: 2

caykie In reply to caykie [2011-07-01 17:13:53 +0000 UTC]

nvm i got itt.

👍: 0 ⏩: 0

caykie In reply to caykie [2011-07-01 17:08:55 +0000 UTC]

nvm

👍: 0 ⏩: 0

rice-chex In reply to ??? [2011-06-24 06:44:27 +0000 UTC]

This is great! so how do you change the color for more than one object? Do I need to create a new layer for each object? And should I copy/paste the entire code for each one, except for the new symbol names?

👍: 0 ⏩: 1

pichu90 In reply to rice-chex [2011-07-01 05:27:54 +0000 UTC]

For changing colors, that would be a good idea and the code could actually go in one layer separate from all the other objects. I don't suppose it would hurt to separate for each layer though ^-^

👍: 0 ⏩: 0

Miphica [2011-06-19 20:24:22 +0000 UTC]

I started out and went to the components menu, but all it has on it are User Interface and Video.
How do you get the Color Picker option?

👍: 0 ⏩: 1

pichu90 In reply to Miphica [2011-06-20 06:59:47 +0000 UTC]

Go to the Actions menu, find the Actionscript drop-down menu and select Actionscript 3.0. You can also get this if you set the publish settings in Flash to 3.0. Let me know if you have problems ^^

👍: 0 ⏩: 1

Miphica In reply to pichu90 [2011-06-20 19:30:19 +0000 UTC]

Thankyouu

👍: 0 ⏩: 0

BlueTheKitten [2011-05-22 05:01:22 +0000 UTC]

how did you get your new color spectrum?? the one with all the colors??

👍: 0 ⏩: 1

pichu90 In reply to BlueTheKitten [2011-05-22 23:42:03 +0000 UTC]

The color picker I think you mean? It was made by another programmer that I put into the Flash components :3

👍: 0 ⏩: 0

Sutehani [2011-04-03 00:44:54 +0000 UTC]

So, I'm trying to do my own dress up with shading. Not black/color/white, but tints and shades of the color.

And I saw in Victini's, that you do include tint shading to the color picked. However, I cannot figure out how you did this.

Any advice?

👍: 0 ⏩: 1

pichu90 In reply to Sutehani [2011-04-04 01:34:28 +0000 UTC]

It's a tad more complicated than can be explained here but the basic idea is having a second layer with the overlay setting and the first layer is a greyscale version of the original. The color picker changes the color of the overlay layer on top, so it changes the color of the object w/shading more easily. That's a start I hope ^^'

👍: 0 ⏩: 1

Sutehani In reply to pichu90 [2011-04-04 02:34:27 +0000 UTC]

I wound up finally figuring it out myself. I didn't name the instance, but I named the MC, so that was my problem.

Now to figure out how to make something "active" to change it's color

👍: 0 ⏩: 0

Dragite42 [2011-03-30 22:19:45 +0000 UTC]

Flagged as Spam

👍: 0 ⏩: 1

pichu90 In reply to Dragite42 [2011-03-31 04:41:02 +0000 UTC]

Doesn't drag/drop at all or compiler error?

👍: 0 ⏩: 0

ayame18 [2011-03-11 08:08:22 +0000 UTC]

Nice tutorial. Thanks for sharing this here!

👍: 0 ⏩: 1

pichu90 In reply to ayame18 [2011-03-12 09:08:18 +0000 UTC]

You're welcome

👍: 0 ⏩: 0

00jolty In reply to ??? [2011-03-05 22:24:03 +0000 UTC]

I've got it working, but for some reason it makes all of my objects start off black instead of their original colour. Can you please help me figure out what I've done wrong?

👍: 0 ⏩: 1

pichu90 In reply to 00jolty [2011-03-07 01:09:06 +0000 UTC]

Try to set the color picker's color to something other than black ^^

👍: 0 ⏩: 0

FOERVRAENGD In reply to ??? [2011-02-08 11:34:53 +0000 UTC]

omg
finally I have learned this damn actionscript and how it works.

👍: 0 ⏩: 1

FOERVRAENGD In reply to FOERVRAENGD [2011-02-08 11:38:42 +0000 UTC]

one question though: how does it work if I want a colorpicker for example hairstyles on a drag-n-drop-item? How can I do so without messing up the lineart on the symbol when changing it's color?

👍: 0 ⏩: 0

chanxbunn [2011-01-19 15:52:03 +0000 UTC]

ive problem...help D: i paste codes for drag and drop...if one not worked i tryed yourzz but nothing want drag...or drop .q.

👍: 0 ⏩: 1

pichu90 In reply to chanxbunn [2011-01-20 09:22:36 +0000 UTC]

Explain it a little more

👍: 0 ⏩: 1


| Next =>