Archive

Posts Tagged ‘Flex’

Arrow ToolTips in Flex with Customized Color and Position

March 5th, 2009

Flex doesn’t make it easy to customize your ToolTip’s positioning or look. You can write your own ToolTip style and draw your own borders or you can use the “error tips” that already have arrows built in.

Manually creating and destroying tooltips

Rather than use the ‘toolTip’ property of a component, we’re going to use the ToolTipManager to create and remove tooltips. This method allows us to position tooltips anywhere on the stage, apply animations, and provide dynamic text.

private var myToolTip:ToolTip;
 
private function showToolTip(evt:MouseEvent, text:String):void
{
   // Create a simple tooltip that appears at the mouse x and y position
   myToolTip = ToolTipManager.createToolTip("Tooltip", evt.x, evt.y) as ToolTip;
}
 
// Remove the tooltip
private function killToolTip():void
{
   ToolTipManager.destroyToolTip(myToolTip);
}

To use the above functions, we need to assign them to a components mouseOver and mouseOut events:

<mx:Button label="Button" mouseOver="showToolTip(event)" mouseOut="killToolTip()"/>
Adding arrows by using Flex’s “error tips”

When creating tooltips by using “ToolTipManager.createToolTip(…)” you can pass in a 4th parameter as a string that specifices which error tip to use. The available options are:

  • “errorTipAbove”
  • “errorTipBelow”
  • “errorTipRight”

Error tips default to a red background color and black text but you can easily change this through styles:

myToolTip.setStyle("borderColor", "#ff6600");
myToolTip.setStyle("color", "white");
Positioning tooltips above, below, and to the right

Another pitfall when creating tooltips manually is specifying the position of the tooltip. The “createToolTip” method requires the x and y coordinates passed in are “global” coordinates, rather than the local x and y coordinates within a container. This makes it a little more tricky to place a tooltip directly below or to the right of a component. The easiest way to fix this is using the method “contentToGlobal(point)”.

var pt:Point = new Point(evt.currentTarget.x, evt.currentTarget.y);
pt = evt.currentTarget.parent.contentToGlobal(pt);
Putting it all together (right click for source):
  • Share/Save/Bookmark

Tucker Flex , ,

Flex Custom Column Chart ItemRenderer

February 22nd, 2009

I’ve spend a lot of time lately trying to figure out how to draw on chart components and how to use Degrafa (graphics framework for Flex). I thought it’d be cool to have a column chart change colors programmatically based on its value.

This example demonstrates how to:
  • Createa custom ItemRenderer and apply it to a series
  • Use Degrafa to convert numbers to a color in the spectrum
  • Convert pixel to chart coordinates to smoothly change column colors

See the example below, more code and comments after the break (right click to view source):

Read more…

  • Share/Save/Bookmark

Tucker Flex , , ,

Hello world!

January 4th, 2009

My name is Tucker Watson and I’m a software developer for Activelogix located in Charlotte, NC.  I graduated from Clemson University in May 2008 with a degree in Computer Science and have since been working on a Flex project to allow end-users to manage and monitor their facilities.

I was introduced to the HVAC world in 2005 while interning at Tridium.  I was a software tester for two summers and spent one as a software developer.  This blog will mostly revolve around Niagara AX and Flex development.

  • Share/Save/Bookmark

Tucker Flex, Niagara, Periscope , , , , , , ,