Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trying to create tooltips in Flash CS4

Posted on 2011-03-04
12
Medium Priority
?
330 Views
Last Modified: 2012-08-13
I followed a tutorial but something isn't clicking for me because I am getting errors.

Two errors.

First is:
1046: Type was not found or was not a compile-time constant: tooltip.

Second:
1046: Type was not found or was not a compile-time constant: tooltip. Source: var tooltip:tooltip = new tooltip();

I am new to flash. I think this may have something to do with that the class needs to be loaded? I am not sure though.

I am attaching the fla
tooltips.fla
0
Comment
Question by:J C
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 39

Expert Comment

by:blue-genie
ID: 35035910
Hi.
why are you using holder:MovieClip?
is there a reason?

then you can't holder = tooltip;
where holder is a movieclip and tooltip is a tooltip even if it extends a movieclip.

what i recommend.
take the tooltip off the stage.
change the class (linkage) to ToolTip //just to distinguish it from the instance

just add the tooltip instead of using the holder.
check the code snippet below

you're probably going to want to add multiple tooltips, so just use one function for the MouseOverHandler, use a switch  / case and e.currentTarget to determine which button triggered it and change the text accordingly.



 
//step one create a variable to hold our tooltip
var tooltip:ToolTip = new ToolTip();
//step two add the event listeners to our button
chapel_hill.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
chapel_hill.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
chapel_hill.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

function mouseOverHandler(e:MouseEvent):void{
	//create a new tooltip instance
	
	//tell the holder to hold our tooltip
	//add text to the tooltip
	tooltip.tiptext.text = "completed projects";
	//positioning the tooltip on the stage
	tooltip.x = stage.mouseX;
	tooltip..y = stage.mouseY - 15;
	//add the tooltip to the stage
	addChild(tooltip);
}

function mouseOutHandler(e:MouseEvent):void{
	//remove the holder when the cursor is outside our button
	removeChild(tooltip);
}

// this function will move the tooltip everytime the cursor is moved
function mouseMoveHandler(e:MouseEvent):void{
	holder.x = stage.mouseX;
	holder.y = stage.mouseY - 15;
}

Open in new window

0
 

Author Comment

by:J C
ID: 35036041
Would you be willing to tweak the file I uploaded and submit it with one functioning tooltip? I am really new to flash and a working example would really help me to learn. If that's not possible I understand.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35036619
if you copy and paste that code i posted, remove the tooltip from the stage(not the library)
right click in the library and change the linkage from tooltip to ToolTip it will work.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:J C
ID: 35038009
New error.

Description: 1087: Syntax error: extra characters found after end of program.
Source: on (release){
0
 

Author Comment

by:J C
ID: 35038133
I had action script elsewhere in the document that I had to remove. Here is the new error

1120: Access of undefined property holder: holder.x = stage.mouseX;

1120: Access of undefined property holder: holder.y = stage.mouseY - 15;

0
 

Author Comment

by:J C
ID: 35038163
At some point I saw this warning message. A definition for this class could not be found in the classpath, so one will be automatically generated in the SWF file upon export.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35039526
okay first of all, the warning message is fine.
you can create an actual class for the ToolTip but in your case you don't need to , so allowing one to be generated automatically is fine.

then in terms of the error about holder.
if you look at the code snippet about, I have commented out or removed all references to holder.
you literally should be replacing ALL you existing code with the code snippet above.

also this code needs to be in the frame not on a movieclip
on (release) syntax is Actionscript 2 - don't know where / how you're getting that.

0
 

Author Comment

by:J C
ID: 35039553
I've done what you've recommended and the tooltip does not appear when I mouseover chapel_hill.
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35039635
upload your file again - the one that you've implemented the changes on.
0
 

Author Comment

by:J C
ID: 35039658
Here it is
tooltips.fla
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 2000 total points
ID: 35039704
hey sorry i left out the last bit

where it references holder, as I mentioned replace it with tooltip, so it should look like this.


function mouseMoveHandler(e:MouseEvent):void{
      tooltip.x = stage.mouseX;
      tooltip.y = stage.mouseY - 15;
}
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 35046879
and did it work?
0

Featured Post

Plesk WordPress Toolkit

Plesk's WordPress Toolkit allows server administrators, resellers and customers to manage their WordPress instances, enabling a variety of development workflows for WordPress admins of all skill levels, from beginners to pros.

See why 2/3 of Plesk servers use it.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

670 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question