A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: change color of empty sprite

  1. #1
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588

    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;
    			
    			
    		}
    ~calmchess~

  2. #2
    Senior Member
    Join Date
    Jan 2011
    Posts
    171
    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_OVERhighLightListfalse0true);
                
    txt00.addEventListener(MouseEvent.MOUSE_OUTunHighLightListfalse0true);
                
    txt00.userList00.x;
                
                
    addChild(txt00);
                
    addChild(spriteX0);
                
                
    nameArr0.push(userListSo00.data[i]);
                
    txtArr0.push(txt00);
                
    spriArr0.push(spriteX0);
                
                
                if (
    varX0 == 1) {
                
    spriteX0.userList00.y;
                
    txt00.userList00.y;
                }else{
                
    spriteX0.userList00.25;
                
    txt00.userList00.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.drawRect00spriArr0[Number(e.currentTarget.name-1)].widthspriArr0[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

  3. #3
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    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
    ~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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center