Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 10-29-2008, 02:45 PM   #1
mhstudio
Mauricio H
 
mhstudio's Avatar
 
Join Date: Mar 2005
Location: Bogota Colombia
Posts: 18
Question [AS3] List component change color of a button

Hello, i have the following problem:

I have a list component with the instance name "my_list", i have some items with some data, i have a variable called "data1" which is the value of the selected item and the instance name of some buttons, what im doing is a list woh change the color of buttons depending of which item in the list i selected. I attached the fla file for better understanding.

I have the following code who changes the color but the problem is when i change the color for a button it changes and with the next button but don't reset the previous button.

function changeHandler(event:Event):void {
var data1 = event.target.selectedItem.data;
var colorTransform:ColorTransform = this[String(data1)].transform.colorTransform;
colorTransform.color = 0xff0000;
this[String(data1)].transform.colorTransform = colorTransform;
addChild(this[String(data1)]);
this[String(data1)].alpha =.4;
}
my_list.addEventListener(Event.CHANGE, changeHandler);
Attached Files
File Type: zip map.zip (4.6 KB, 274 views)
mhstudio is offline   Reply With Quote
Old 10-29-2008, 04:19 PM   #2
mhstudio
Mauricio H
 
mhstudio's Avatar
 
Join Date: Mar 2005
Location: Bogota Colombia
Posts: 18
Question Problem with toggle ColorTransform

Hello, i have the following problem:

I want to make a map and when the user select an item in the list component some part of the map change his color and if the user select another item the previous part return to original color and the new selection change his color.

I have a list component with the instance name "my_list", i have a variable called "data1" which is the value of the selected item and the instance name of the buttons, what im doing is a list woh change the color of buttons depending of which item in the list i selected. I attached the fla file for better understanding.

I have the following code who changes the color but the problem is when i change the color for a button it changes and with the next button but don't reset the previous button.

function changeHandler(event:Event):void {
var data1 = event.target.selectedItem.data;
var colorTransform:ColorTransform = this[String(data1)].transform.colorTransform;
colorTransform.color = 0xff0000;
this[String(data1)].transform.colorTransform = colorTransform;
addChild(this[String(data1)]);
this[String(data1)].alpha =.4;
}
my_list.addEventListener(Event.CHANGE, changeHandler);
Attached Files
File Type: zip map.zip (4.6 KB, 288 views)
mhstudio is offline   Reply With Quote
Old 10-29-2008, 09:05 PM   #3
mhstudio
Mauricio H
 
mhstudio's Avatar
 
Join Date: Mar 2005
Location: Bogota Colombia
Posts: 18
Thumbs up Change color to movieclip or button with list component flash

Hi, i found the solution im posting the code maybe someone could need it

var rojo:ColorTransform = new ColorTransform();
rojo.color = 0x0099CC;
var blanco:ColorTransform = new ColorTransform();
function changeHandler(event:Event):void {
var data1 = event.target.selectedItem.data;
var i=1;
while (i<800)
{var data2 = "s"+i;
if (this[String(data2)]){
this[String(data2)].transform.colorTransform = blanco;
}
this[String(data1)].transform.colorTransform = rojo;i++;
}
}
my_list.addEventListener("change", changeHandler);
mhstudio 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS3] How to change List item's background ideal Components 1 07-15-2008 11:04 AM
change color of button with value of color of dynamic button xsintill ActionScript 1.0 (and below) 5 04-23-2008 08:08 PM
Major Problems trying to capture "click" event in List component ManinBlaq Components 11 01-30-2007 07:12 PM
MP3 Player using List Component and XML Playlist dogandking Components 0 12-05-2006 05:47 PM
Scope Problem with List Component Inside Accordion Scottiedazzle ActionScript 2.0 1 07-18-2006 03:51 PM


All times are GMT. The time now is 05:24 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.