Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-26-2010, 10:21 AM   #1
Yui
Senior Member
 
Join Date: Jun 2008
Location: Romania
Posts: 162
Default tileList; overriding drawTileBackground

Hi guys,

I've been searching a solution to this for a whole day and I have yet to find it.
I have a tileList in which I have overrided the methods drawHighlightIndicator (the mouse over background graphic) and drawSelectionIndicator (the selected tile background graphic). These work perfect.

However, I want to have a tile background graphic in normal state, too (when the item is not highlighted nor selected). I have to say that in this case, the "alternating item color" is not an option for me, because i am drawing a custom graphic (rounded rectangle of certain dimensions and colors, depending on the tile index).

I can't put a background to the ItemRenderer because then the highlight/selected colors don't show up anymore (they're "behind" the renderer);

I tried overriding the drawTileBackground method but i'm getting no background at all.

Does anyone know what i have to do to achieve my goal? or a working example, that would be great.

This is what I have so far if it helps:
ActionScript Code:
/** mouse over skin **/             override protected function drawHighlightIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void             {                 var g:Graphics = Sprite(indicator).graphics;                 g.clear();                 g.beginFill(0x999999, 0.5);                 g.drawRoundRect(2, 2, 40, 40, 10, 10);                 g.endFill();                                indicator.x = x;                 indicator.y = y;             }                         /** mouse down skin **/             override protected function drawSelectionIndicator(indicator:Sprite, x:Number, y:Number, width:Number, height:Number, color:uint, itemRenderer:IListItemRenderer):void             {                 var g:Graphics = Sprite(indicator).graphics;                 g.clear();                 g.beginFill(0xAAAAAA, 1);                 g.drawRoundRect(2, 2, 40, 40, 10, 10);                 g.endFill();                                indicator.x = x;                 indicator.y = y;             } /** i found this code somewhere but it does not work :( **/ override protected function drawTileBackground(s:Sprite, rowIndex:int, columnIndex:int, width:Number, height:Number, color:uint, item:IListItemRenderer):DisplayObject             {                                 color = 0xEEEEEE;                                 width = height = 40;                 var tileBGIndex:int = rowIndex * columnCount + columnIndex;                         var bg:Shape;                 if (tileBGIndex < s.numChildren)                 {                     bg = Shape(s.getChildAt(tileBGIndex));                 }                 else                 {                     bg = new FlexShape();                     bg.name = "tileBackground";                     s.addChild(bg);                 }                         var g:Graphics = bg.graphics;                 g.clear();                 g.beginFill(color, 1);                 g.drawRect(0, 0, width, height);                 g.endFill();                         return bg;             }

Last edited by Yui; 02-26-2010 at 10:25 AM.
Yui 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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:51 PM.

///
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.