ToolTip class for Flash in Actionscript 3

I have created a tool tip class in Actionscript 3 that is reusable and I think it is helpful for anyone wanting a pop-up for additional information. This is what lead up to that happening.

I just started learning Flash a couple of weeks ago. I decided that I wanted a little more pizazz in my photo pages on my web site. I had originally created the pages using Ajax and some Javascript which I think had a pretty nice look.

My earlier incarnations of photo pages used frames to contain the albums, thumbnails, and the photo. Using Ajax, I was able to get the flexibility without using frames. I also created a zoom in feature with Javascript. I had thought about using Flash originally, but at the time I thought I would have to build in all of the photos into the Flash application and I wanted something that would be dynamic. When I added a picture to my portfolio or photos pages, I didn’t want to have to update Flash. In addition to the work I thought I would have to do, my HTML pages (served by PHP) used the same code with a different query string to serve up either the portfolio or the photos pages. I thought I would have to create two different Flash files. The other minor issue was at the time, I didn’t have Flash.

A couple of things changed so that I decided to change my photo pages to use Flash. I found out that Adobe had a special so that I could upgrade my CS3 design standard to CS4 design premium for a little more that just upgrading to CS4. The upgrade to premium added Flash to the suite (as well as other applications). The second thing was that I found out that Flash could read a XML file and dynamically load the images—somewhat similar to how I was using Ajax to load my albums when selected.

Thus started my Flash and Actionscript 3 adventure. I have fallen in love with Flash because of what it can do and I know I’ve only scratched the surface. I really enjoy the power of Actionscript 3 and the ease of use of Flash CS4. The integration with the rest of CS4 is also very nice. I was extremely pleased with so much information and examples of how to accomplish different functions in Flash. It’s amazing the availability of tutorials. One amazing site is http://gotoandlearn.com. In my project, I learned from several tutorials on the site including the information about Pixel Bender, the 3D picture Carousel, XML, and tool tips. I also find many other sources of useful information and tutorials. Since I am using Actionscript 3 and particular using a Document Class, some code I had to adapt, but it was still extremely helpful.

I am continuing to learn many aspects of Flash and Actionscript for both fun and to be able to add to my skills to improve my hireability. I am also considering Flex Builder to code Actionscript, but I’m still not sure of all of the benefits and spending the money.

So after all that, back to my first reusable Actionscript 3 class. It’s a tool tip that is created dynamically based on the text (including HTML formatting) and the requested width. It has several options for customization including background color, line style, corner radius, pointer location (side and position), and pointer size. The text can be formatted using the TextFormat class or the StyleSheet. The text can be set using a text or htmlText property. It needs Flash Player 9 or later. I am open to suggestions for additional features or information regarding problems found. More information, documentation, a demo, and the download is available here. You can see it in use here. Hover the mouse over the blue information icon. I hope you find it useful.
ToolTip class test screenshot

Leave a Reply