Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Extensions and Plugins > Components

Reply
 
Thread Tools Rating: Thread Rating: 1 votes, 5.00 average. Display Modes
Old 04-05-2012, 09:45 AM   #1
kennie1212
Registered User
 
Join Date: Apr 2012
Posts: 4
Default [AS3] Change the colour of a movieclip using a combo box

Hi,

I'm fairly new to Action-script and am having trouble trying to change the colour of a movie clip (instance: mcborder) once a colour has been selected with the combo box.

Code so far:

import fl.controls.ComboBox;
import fl.data.DataProvider;

var pickcol:Array = new Array(
{label:"Red"},
{label:"Blue"},
{label:"Green"},
{label:"Yellow"},
{label:"Orange"},
{label:"Purple"},
{label:"Pink"}
);

var aCb:ComboBox = new ComboBox();
aCb.dropdownWidth = 210;
aCb.width = 200;
aCb.move(150, 50);
aCb.prompt = "Pick a Colour";
aCb.dataProvider = new DataProvider(pickcol);
aCb.addEventListener(Event.CHANGE, changeHandler);

addChild(aCb);

function changeHandler(event:Event):void {
}

If any one could help it would be much appreciated

Thanks

Last edited by kennie1212; 04-05-2012 at 12:20 PM.
kennie1212 is offline   Reply With Quote
Old 04-05-2012, 02:09 PM   #2
groeterud
Go ahead and ask.. DO EET
 
Join Date: Apr 2011
Location: Norway
Posts: 99
Default

i would suggest using a If sentence to check for the label in the changeHandler function
groeterud is offline   Reply With Quote
Old 04-05-2012, 02:35 PM   #3
SephirothOWA
Senior Member
 
Join Date: Jun 2010
Location: Ipswich, England
Posts: 263
Default

ActionScript Code:
import fl.controls.ComboBox; import fl.data.DataProvider; import flash.geom.ColorTransform; var pickcol:Array = new Array( {label:"Red", colour: 0xffffff}, {label:"Blue", colour: 0x0000ff}, {label:"Green", colour: 0x00ff00}, {label:"Yellow", colour: 0xffff00}, {label:"Orange", colour: 0xff9900}, {label:"Purple", colour: 0x6600ff}, {label:"Pink", colour: 0xff00ff} ); var aCb:ComboBox = new ComboBox(); aCb.dropdownWidth = 210; aCb.width = 200; aCb.move(150, 50); aCb.prompt = "Pick a Colour"; aCb.dataProvider = new DataProvider(pickcol); aCb.addEventListener(Event.CHANGE, changeHandler); addChild(aCb); function changeHandler(event:Event):void { var colorTransform:ColorTransform = new ColorTransform(); colorTransform.color = aCb.selectedItem.colour; // then apply the colour transform to your target object }
SephirothOWA is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:52 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.