-
Senior Member
change color of empty sprite
I'm trying to change the background color of a sprite but the sprite doesn't even seem to be added to the stage. the below code doesn't throw any errors but the empty sprite doesn't change colors...this is just a snippet of the whole class so just ignore the missing type declarations and stuff. Whats the problem? BTW the event fires when the textfield is hovred over but the sprite that is supposed to be behind the textfield doesn't change color and doesn't even seem to be on the stage.
Code:
private function userList(e:SyncEvent):void {
for (var i:String in userListSo00.data) {
//userArr0.push(userListSo00.data[i]);
varX0++;
spriteX0 = new Sprite();
spriteX0.width = 110;
spriteX0.height = 35;
txt00 = new TextField();
txt00.width = 100;
txt00.height = 25;
txt00.name = varX0.toString();
spriteX0.name = varX0.toString();
spriArr0.push(spriteX0);
txt00.text = userListSo00.data[i];
addChild(spriteX0);
addChild(txt00);
nameArr0.push(userListSo00.data[i]);
txtArr0.push(txt00);
txtArr0[varX0-1].addEventListener(MouseEvent.MOUSE_OVER, highLightList, false, 0, true);
txtArr0[varX0-1].addEventListener(MouseEvent.MOUSE_OUT, unHighLightList, false, 0, true);
txt00.x = userList00.x;
if (varX0 == 1) {
spriteX0.y = userList00.y;
txt00.y = userList00.y;
}else{
spriteX0.y = userList00.y + 25;
txt00.y = userList00.y + 25;
}
}
//create array to act as list
//update a text field to display the list
//when a user enters or exits updat list and entire textfield
}
private function highLightList(e:MouseEvent):void {
var newCol0:ColorTransform = new ColorTransform();
newCol0.color = 0x5F5A59;
spriArr0[Number(e.currentTarget.name-1)].graphics.beginFill( 0x00FF00 );
spriArr0[Number(e.currentTarget.name-1)].graphics.drawRect( 0, 0, spriArr0[Number(e.currentTarget.name-1)].width, spriArr0[Number(e.currentTarget.name-1)].height );
spriArr0[Number(e.currentTarget.name-1)].graphics.endFill();
//spriArr0[Number(e.currentTarget.name-1)].alpha = 0.1;
//spriArr0[Number(e.currentTarget.name-1)].transform.colorTransform = newCol0;
trace(e.currentTarget.name);
}
private function unHighLightList(e:MouseEvent):void {
var newCol1:ColorTransform = new ColorTransform();
newCol1.color = 0x000000;
spriArr0[Number(e.currentTarget.name-1)].transform.colorTransform = newCol1;
}
-
PHP Code:
private function userList(e:SyncEvent):void {
for (var i:String in userListSo00.data) {
//userArr0.push(userListSo00.data[i]);
varX0++;
spriteX0 = new Sprite();
spriteX0.width = 110;
spriteX0.height = 35;
txt00 = new TextField();
txt00.width = 100;
txt00.height = 25;
txt00.name = varX0.toString();
spriteX0.name = varX0.toString();
txt00.text = userListSo00.data[i];
txt00.addEventListener(MouseEvent.MOUSE_OVER, highLightList, false, 0, true);
txt00.addEventListener(MouseEvent.MOUSE_OUT, unHighLightList, false, 0, true);
txt00.x = userList00.x;
addChild(txt00);
addChild(spriteX0);
nameArr0.push(userListSo00.data[i]);
txtArr0.push(txt00);
spriArr0.push(spriteX0);
if (varX0 == 1) {
spriteX0.y = userList00.y;
txt00.y = userList00.y;
}else{
spriteX0.y = userList00.y + 25;
txt00.y = userList00.y + 25;
}
}
//create array to act as list
//update a text field to display the list
//when a user enters or exits updat list and entire textfield
}
private function highLightList(e:MouseEvent):void {
var newCol0:ColorTransform = new ColorTransform();
newCol0.color = "0x5F5A59";
spriArr0[Number(e.currentTarget.name-1)].graphics.beginFill( "0x00FF00" );
spriArr0[Number(e.currentTarget.name-1)].graphics.drawRect( 0, 0, spriArr0[Number(e.currentTarget.name-1)].width, spriArr0[Number(e.currentTarget.name-1)].height );
spriArr0[Number(e.currentTarget.name-1)].graphics.endFill();
//spriArr0[Number(e.currentTarget.name-1)].alpha = 0.1;
//spriArr0[Number(e.currentTarget.name-1)].transform.colorTransform = newCol0;
trace(e.currentTarget.name);
}
private function unHighLightList(e:MouseEvent):void {
var newCol1:ColorTransform = new ColorTransform();
newCol1.color = "0x000000";
spriArr0[Number(e.currentTarget.name-1)].transform.colorTransform = newCol1;
}
arkitx
-
Senior Member
Thanks I solved the problem by not using a sprite although I'll take a look at what you did when I have time. Thanks
--calmchess
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|