Enabled false -> no more ToolTip

7 views
Skip to first unread message

Axel Aigret

unread,
May 16, 2008, 6:06:05 AM5/16/08
to as...@googlegroups.com
Hi everybody :)

In my application, i want to have tooltip when a button is not
actived, because a men can look what do button even if he can use it i
think.
So for this not so easy , and deep in code lol.
I have reput the mouseEnabled and remove and add the Click event ,
but it's very specific and not i want so much.

Maybe it's can be possible to enhance aswing to have this possibility.

In more i put you the code to do automatic grey icon for disable ,
maybe add the function too in AsWing util class ;).

Have fun :)

Axel


override public function setEnabled(b:Boolean):void
{
super.setEnabled(b);
mouseEnabled = true;
if( !b )
{
if(_fClick != null) removeEventListener(
MouseEvent.CLICK, _fClick ) ;
}
else
{
if(_fClick != null) addEventListener( MouseEvent.CLICK,
_fClick ) ;
}

}

protected function onDisabledIconLoaded( disableIcon : LoadIcon
, e : Event) : void
{
var buttonBitmap : Bitmap = GraphicUtils.bitmapOn(
disableIcon.getAsset() ) ;
setDisabledIcon( new AssetIcon( createBlackWhiteBitmap(
buttonBitmap.bitmapData )) ) ;
}

protected function createBlackWhiteBitmap( b : BitmapData ) :
Bitmap
{
var bBW : BitmapData = b.clone() ;
for( var i : uint = 0 ; i < b.width ; ++i )
for( var j : uint = 0 ; j < b.height ; ++j )
{
bBW.setPixel( i , j , GraphicUtils.getGreyColor(
bBW.getPixel(i, j ) )) ;
}
return new Bitmap( bBW ) ;
}

////
public static function getGreyColor( color : uint ) : uint
{
const red : uint = ( color >>> 16 ) & 255 ;
const green : uint = ( color >>> 8 ) & 255 ;
const blue : uint = ( color ) & 255 ;
const newColor : uint = ( red + green + blue ) / 3 ;
const alpha:uint = ( color >>> 24 ) & 255 ;
return ( alpha << 24 ) | ( newColor << 16 ) | ( newColor <<
8 ) | newColor;
}

iiley

unread,
May 16, 2008, 9:34:09 AM5/16/08
to as...@googlegroups.com
Thanks for sharing :)

2008/5/16, Axel Aigret <axel0...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages