HOME | DD
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
pichu90 In reply to ??? [2019-07-11 04:26:40 +0000 UTC]
www.adobe.com/products/animateβ¦
π: 0 β©: 0
Madelynnong [2016-10-19 12:12:31 +0000 UTC]
drag and drop in as3 is:
import fl.events.MouseEvent;
dragger.addEventListener(MouseEvent.MOUSE_DOWN,drag);
dragger.addEventListener(MouseEvent.MOUSE_UP,drop);
function drag(e:MouseEvent):void {
this.startDrag();
}
function drop(e:MouseEvent):void {
this.stopDrag();
}
π: 0 β©: 0
The-Terminal-Show [2015-12-02 10:31:07 +0000 UTC]
I haven't made a dress up game since Flash 4.0 so I was hoping this would work for me, however i get the error 1120: Access of undefined property santahat".
I made a new layer named santahat, and I dragged the symbol named santahat onto the first frame, then applied your code to the actions of the first frame. Maybe I just did something wrong here, either way if you know what I messed up I'd really appreciate it for some feedback.
There's a surprising lack of really basic guides like this for code babies like me lol.
Thanks!
π: 0 β©: 1
pichu90 In reply to The-Terminal-Show [2015-12-04 05:31:09 +0000 UTC]
Well, it could be a case of misspelling somewhere, what does the code look like?
π: 0 β©: 1
The-Terminal-Show In reply to pichu90 [2015-12-04 08:57:08 +0000 UTC]
It took another three hours before I realized my own dumb error, I hadn't set an instance name only the layer and symbol. I got everything to work out eventually, so thanks a lot for the guide.
π: 0 β©: 0
MuchGhost [2015-12-02 03:15:33 +0000 UTC]
what if I want a different instance name in regards to the drag and drop, what would I change?
EDIT: I figured it out, but the code can't be used more than once
π: 0 β©: 0
liana6748 [2015-11-09 21:47:07 +0000 UTC]
It worked for one item, but with more than one, it gives this message:Scene 1, Layer 'Hair', Frame 1, Line 7, Column 10 Β Β 1021: Duplicate function definition.Β Scene 1, Layer 'Hair', Frame 1, Line 10, Column 11 Β Β 1021: Duplicate function definition. Any tips? (I'm using Pro CC 2014) Β
π: 0 β©: 1
pichu90 In reply to liana6748 [2015-11-10 04:53:48 +0000 UTC]
Be careful in not specifying the same name for an object twice somewhere else -- maybe its in another movie clip/button?
π: 0 β©: 1
PeachyPieArt [2015-10-14 21:22:22 +0000 UTC]
Is there a way to get it to snap to the body where I want it to be? pichu90 Β
π: 0 β©: 1
pichu90 In reply to PeachyPieArt [2015-10-17 05:36:55 +0000 UTC]
I'd love to do this! However I haven't yet done it so I can't help
π: 0 β©: 0
pichu90 In reply to pikakingbro0320 [2015-02-06 06:38:37 +0000 UTC]
Nope, its free to use :3
π: 0 β©: 1
pikakingbro0320 In reply to pichu90 [2015-02-07 01:05:10 +0000 UTC]
Oh, yay :3(By Fluttershy)
π: 0 β©: 0
DollFox [2014-10-27 22:21:36 +0000 UTC]
How would you make it so the color of body modifications are the same as the body? ;w; Sorry. Great tutorial Β owo~
π: 0 β©: 0
fadaksdesign [2014-02-19 12:11:49 +0000 UTC]
i just need an extra code. i mean in my game the user has to pick specific clothes.. how can i make the cloth returns to its initial position if it was incorrect?Β
thanks in advance.Β
π: 0 β©: 0
WhiteCat1235 [2014-02-12 18:04:13 +0000 UTC]
I don't have Publish Settings ;3;
Can u give me link because stupid google won't help me find where is ;3;
π: 0 β©: 1
pichu90 In reply to WhiteCat1235 [2014-02-14 08:53:39 +0000 UTC]
Should be in your Flash application - under the file menu ^^
π: 0 β©: 0
GamingGoru [2014-01-02 07:09:20 +0000 UTC]
I have a problem. I followed the instructions, I copy-pasted the codes to the action script (re-naming the instance names of course), but when I test it out, everything gets all seizure-like: All the frames and animations play rapidly by themselves and nothing is clickable. What was I doing wrong? (I'm using Actionscript 3)
π: 0 β©: 0
GamingGoru [2013-12-26 08:12:38 +0000 UTC]
Very nice tutorial! I'm gonna try making a dress up game!
π: 0 β©: 0
PrincessMephista [2013-12-26 07:02:25 +0000 UTC]
what do you do if you want multiple color pickers for other objects
π: 0 β©: 0
Sheena5612 [2013-07-14 21:16:25 +0000 UTC]
as you can put the color picker code to multiple objects?
π: 0 β©: 0
alpesh88ww [2013-05-31 07:51:10 +0000 UTC]
can u help me i need drag item within scroll and drop on stage when complete a task one animation will appear something like "good job" in flash as3
thanks ......plz plz plz help me!!
π: 0 β©: 0
ChaoticCinder [2013-05-22 19:32:55 +0000 UTC]
I have download a full free version and the only settings it has for actionscripts are 1.0 and 2.0
There's no Actionscript 3.0 !!!
π: 0 β©: 1
pichu90 In reply to ChaoticCinder [2013-05-23 04:43:10 +0000 UTC]
Probably an older version of Flash, by Macromedia I guess?
I recommend Adobe CS3 and later :3
π: 0 β©: 1
ChaoticCinder In reply to pichu90 [2013-05-23 18:36:37 +0000 UTC]
Hum...
By other methods, I'm doing the dress up.
Thank you, If its possible I will search it.
π: 0 β©: 0
Katherine-Robertson [2013-03-18 07:15:43 +0000 UTC]
Do you know how to get a color picker for Action Script 2?
π: 0 β©: 1
pichu90 In reply to Katherine-Robertson [2013-03-19 06:04:34 +0000 UTC]
Once I did, but it was a third party tool that I don't think exists any more
π: 0 β©: 1
Katherine-Robertson In reply to pichu90 [2013-03-23 09:39:57 +0000 UTC]
Haha okay thanks anyway and I found one.
π: 0 β©: 0
TailTehEeveelution [2013-03-01 19:46:28 +0000 UTC]
I don't have the Actions-Frame option.
I'm using the Free Trial version of CS6
π: 0 β©: 0
Magweno [2013-02-07 22:40:58 +0000 UTC]
Heh I got it, I wasn't renaming the function name
I also had a problem where the MCs were starting out black but I just removed this part of the code:
BodycolorInfo.color = cpBody.selectedColor;
Body.transform.colorTransform = BodycolorInfo;
and that sorted it >_>
π: 0 β©: 0
Magweno [2013-02-03 22:51:14 +0000 UTC]
Whoops sorry something bugged there and I posted too early!
*changed it accordingly in your code, it works fine! Then I added another (same layer, AS is in the same frame), changed the 'Body' and 'cpBody' to something different and now neither of them work and the colourpickers just flash and spazz :c
If I get rid of one, the other works, but both won't work together. Eep, what am I doing wrong!
π: 0 β©: 0
Magweno [2013-02-03 22:48:10 +0000 UTC]
Oof amazing tutorial put so simply, thank you! *0*
I am having trouble getting more than one colourpicker working though, I've added a new colorpicker MC to my stage, given it a different instance name and changed it accordingly in your code
π: 0 β©: 0
wachey [2012-11-25 07:33:19 +0000 UTC]
I tried to do the color picker, and had copied/pasted the code you have in your artists notes into the action script. I have it on actionscript 3.0, have the frame selected, and changed the names appropriately on the code since mine are different, but I keep getting errors that claim "access to undefined property..."
Any idea what that means?
π: 0 β©: 1
pichu90 In reply to wachey [2012-12-01 07:26:56 +0000 UTC]
Somewhere you have a typo or placing the code in the wrong timeline ^^
π: 0 β©: 0
Anna-chu2 [2012-11-01 22:06:31 +0000 UTC]
umm one problom how do you download flash docment
π: 0 β©: 0
Hyrika [2012-07-10 05:02:08 +0000 UTC]
Great tuts ^^
I have questions:
-I'm using Adobe Flash Professional CS5 and the Color Picker option isn't in the User Interface, so do you any idea where they are instead? o.o;
-Also do you know how to do the "Reset" and "Random" button?
Thanks in advance!
π: 0 β©: 1
pichu90 In reply to Hyrika [2012-07-10 07:21:10 +0000 UTC]
Thanks
I have CS3 but I think it should be similar -- the color picker should be available in the tools menu (or hit Ctrl+F2)
The reset button is something I had to make manually, and all it does is reset the colors to their original state. The random button triggers an animation which hides the mew (or Sparks) and makes the other character appear :3
π: 0 β©: 1
Hyrika In reply to pichu90 [2012-07-10 11:55:24 +0000 UTC]
Oh I mean as in the color picker where you can just drag it down to the frame itself , but for some reason I can't drag it like in the tuts due to it not appearing on the same place you mentioned haha o.o;;
DO you know how to code them though? XD
π: 0 β©: 1
pichu90 In reply to Hyrika [2012-07-12 04:43:55 +0000 UTC]
The color picker is a draggable item under the Components tab if your publish settings are Actionscript 3.0. The coding should be in the tutorial though :3
π: 0 β©: 1
caykie [2012-04-12 00:51:42 +0000 UTC]
Question!
How do you make buttons on AS 3.0?
like the ones in this tutorial and the ones in your dress-up;
Is it the same as AS 2.0 buttons? :3
Thanks!
π: 0 β©: 1
pichu90 In reply to caykie [2012-04-16 00:19:29 +0000 UTC]
I think I have it in this tutorial, but it's not the same as AS 2.0 buttons which are easier to code in my opinion. Look under tutorials if you need more help :3
π: 0 β©: 1
| Next =>

























