John,
Thanks for the tips. I think I got it between your help and one spot
in the UIComponent help. So the code I was getting caught up in was
the line
toolTipCreate="event.toolTip=this.createTip()
Where createTip created a custom tooltip as described in a number of
posts I've seen before. What I failed to understand was that the code
is really a small function and equivalent to:
onInit(): void{
...
chkbox1.addEventListener(ToolTipEvent.TOOL_TIP_CREATE, onToolTipCreate);
}
private function onToolTipCreate(thisEvent : ToolTipEvent): void {
thisEvent.toolTip = this.createTip();
trace("ToolTipCreate");
}
So I was able to get this model to display my custom tooltips for my
subset of items. On the TOOL_TIP_SHOW event, I can initialize the
tooltip components.
Thanks for your help,
Rich
--- In [email protected], John Kirby <[EMAIL PROTECTED]> wrote:
>
> Correction here. Replace in
> wToolTip.setComponentClass(AreaCodeSearchWindow) with
> wToolTip.setComponentObject(AreaCodeSearchWindow);
>
> John Kirby said the following:
> >
> > Below is how I handle custom components in a tooltip.
> >
> > weather.WeatherToolTipManager extends ToolTipManager. WeatherToolTip
> > Extend ToolTip . Just create a WeatherToolTip object and use the
> > setComponentClass(UiComponent) to store the custom componet. Then
pass
> > the tooltip to the create custom tooltip to allow you to view your
> > component inside a tooltip.
> >
> >
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application backgroundGradientColors="[0xFFFFFF,0xFFFFFF]"
> > backgroundColor="0xFFFFFF" xmlns:mx="http://www.adobe.com/2006/mxml"
> > layout="absolute" >
> >
> > <mx:Script><![CDATA
> >
> > public var wToolTip:WeatherToolTip;
> >
> > private function showTip(event:Event):void {
> >
> > if (WeatherToolTipManager.toolTipOpen){
> > return;
> > }
> >
> > //Create tooltip and add component to it
> > wToolTip = new WeatherToolTip();
> > wToolTip.setComponentClass(AreaCodeSearchWindow);
> > // adjust coordinates inside tooltip
> > wToolTip.setCoordinates(20,10);
> >
> >
> > // use custom createCustomToolTip to add tooltip and its
> > component as a child to the tooltipManager
> > // This essentially is the same as the createToolTip
> > except you pass a complex componet vs. text to the tooltip
> >
> > WeatherToolTipManager.createCustomToolTip(event.currentTarget.x +
> > event.currentTarget.width,
> >
> > (event.currentTarget.y +10),wToolTip,"errorTipRight");
> >
> >
> > // customize the tooltip
> > wToolTip.setStyle("cornerRadius", 10);
> > wToolTip.setStyle("backgroundAlpha", 0.40);
> > wToolTip.setStyle("backgroundColor", "#4ca0d4");
> > wToolTip.setStyle("borderColor", "#4ca0d4");
> > wToolTip.setStyle("backgroundGradientColors",
> > "[0xFFFFFF,0xFFFFFF]");
> >
> >
> > }
> >
> > ]]></mx:Script>
> >
> > <mx:Panel id="myPanel" click="showTip(event)" ></mx:Panel>
> > </mx:Application>
> >
> >
> > There is a destroy method to close/remove the tooltip. This could be
> > called by a button component inside the tooltip or handled via a
> > rollover/out event.
> >
> >
> > public class WeatherToolTipManager extends ToolTipManager{
> >
> > public static var toolTipOpen:Boolean = false;
> > public static var currentToolTip:IToolTip;
> >
> >
> > public static function createCustomToolTip(x:Number, y:Number,
> > wToolTip:ToolTip,
> > errorTipBorderStyle:String =
> > null,
> > context:IUIComponent =
> > null):void{
> >
> > var sm:ISystemManager = context ?
> > context.systemManager :
> >
Application.application.systemManager;
> >
> >
> > sm.toolTipChildren.addChild(wToolTip);
> >
> >
> > if (errorTipBorderStyle){
> > wToolTip.setStyle("borderStyle", errorTipBorderStyle);
> > }
> >
> >
> > currentToolTip = wToolTip;
> > wToolTip.move(x, y);
> > toolTipOpen = true;
> > }
> >
> >
> >
> > public static function destroyToolTip(toolTip:IToolTip):void{
> > var sm:ISystemManager = toolTip.systemManager;
> > sm.toolTipChildren.removeChild(DisplayObject(toolTip));
> > toolTipOpen = false;
> >
> > }
> > }
> >
> > public class WeatherToolTip extends ToolTip {
> > private var tipClass:Class;
> > private var tipX:int;
> > private var tipY:int;
> >
> > private var classInstance:Object;
> >
> > public function WeatherToolTip(){
> > super();
> > // Make the ToolTip invisible to the mouse so that it
doesn't
> > // interfere with the ToolTipManager's mouse-tracking.
> > mouseEnabled = false;
> > }
> >
> > public function getTipComponent():Object{
> > return this.classInstance;
> > }
> >
> > public function setComponentClass(tipClass:Class):void{
> > this.tipClass = tipClass;
> > }
> >
> > public function setComponentObject(objClass:Object):void{
> > this.classInstance = objClass;
> > }
> >
> > public function setCoordinates(x:int,y:int):void{
> > this.tipX = x;
> > this.tipY = y;
> >
> > }
> >
> > override protected function createChildren():void {
> > super.createChildren();
> >
> > classInstance.parentTip = this;
> > classInstance.x = this.tipX;
> > classInstance.y = this.tipY;
> > classInstance.addEventListener("closeTip",destroyTip);
> > addChild(DisplayObject(classInstance));
> > }
> >
> > public function destroyTip():void {
> > WeatherToolTipManager.destroyToolTip(this);
> > }
> > }
> > }
> >
> >
> >
> >
> > richmcgillicuddy said the following:
> >
> >> John,
> >>
> >> Searched through the docs and it doesn't quite answer my question. So
> >> I have a descendant of ITooltip that is a more complex toolTip with
> >> multiple pieces of information on it. I only want this complex
tooltip
> >> to show up for certain types of objects, others I want the standard
> >> tooltip to show up. These objects get created and placed dynamically.
> >> I'll check the createToolTip event and see if that will override the
> >> standard event but the examples I saw so far all created this
> >> functionality using MXML which works great. I'd rather use the
toolTip
> >> functionality than try to override everything on a rollover, rollout
> >> command.
> >>
> >>
> >> s via email: Switch delivery to Daily Digest
> >>
<mailto:[EMAIL PROTECTED]:%20Digest>
> >> | Switch format to Traditional
> >>
<mailto:[EMAIL PROTECTED]:%20Traditional>
> >>
> >> Visit Your Group
> >>
<http://groups.yahoo.com/group/flexcoders;_ylc=X3oDMTJlaWpycXBtBF9TAzk3MzU5NzE0BGdycElkAzEyMjg2MTY3BGdycHNwSWQDMTcwNTAwNzIwNwRzZWMDZnRyBHNsawNocGYEc3RpbWUDMTE2NDMzNDQ5Nw-->
> >> | Yahoo! Groups Terms of Use <http://docs.yahoo.com/info/terms/> |
> >> Unsubscribe <mailto:[EMAIL PROTECTED]>
> >> .
> >>
> >
> > --
> > /Whether you think that you can, or that you can't, you are usually
> > right./
> > - Henry Ford
> >
>
> --
> /Whether you think that you can, or that you can't, you are usually
right./
> - Henry Ford
>