# Dynamically created hover captions

**URL:** https://forum.kirupa.com/t/dynamically-created-hover-captions/109918
**Category:** Uncategorized
**Created:** [May 10, 2004, 8:21pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918 "2004-05-10T20:21:28Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)
#### Post date: [May 10, 2004, 8:21pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/1 "2004-05-10T20:21:28Z")

</div>

Okay, this worked in a simple file where it was the only thing on the stage ([see this thread](http://www.kirupaforum.com/forums/showthread.php?t=55969)). Now I am implementing it in a much more complex scenario and the movie clip in question is quite buried so bear with me:

This is in my main timeline:

```auto

Movieclip.prototype.hover = function(sometxt) {
	this.onRollOver = function() {
		_root.m = 1;
		mainMap.map.pan.box.createTextField("caption", 1, mainMap.map.pan.box.test._x+2, mainMap.map.pan.box.test._y+2, 110, 30);
		mainMap.map.pan.box.caption.type = "dynamic";
		mainMap.map.pan.box.caption.multiline = true;
		mainMap.map.pan.box.caption.wordWrap = true;
		mainMap.map.pan.box.caption.size = 10;
		mainMap.map.pan.box.caption.text = sometxt;
		mainMap.map.pan.box.caption.autoSize = "left";
		mainMap.map.pan.box.test.resize();
		trace(mainMap.map.pan.box.caption.text)
	};
	this.onRollOut = function() {
		_root.m = 0;
		mainMap.map.pan.box.caption.text = " ";
	};
};
mainMap.map.pan.mapElements.ktn.hover("text for a caption");

```

The resize() function is just some simplified code from the resizing slideshow. Now this works as in when the ktn MC is rolled over the box appears where the mouse is and resizes to fit the text. When I do a trace on sometxt it reports back the correct text but the text itself doesn’t show. The box is a light blue and the default for createTextField is black so that shouldn’t be a problem.

I’m sure it is something simple and obvious that I am missing so if anyone sees it could you please point it out to me?

Thanks!! :hr:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 7:26pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/2 "2004-05-27T19:26:10Z")

</div>

well, either embed the fonts or keep the over caption outside of the mask and use localtoglobal/globaltolocal to handle positioning

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 7:31pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/3 "2004-05-27T19:31:47Z")

</div>

> [@senocular](#):
>
> well, either embed the fonts or keep the over caption outside of the mask and use localtoglobal/globaltolocal to handle positioning

Not sure I understand how that works. Does that mean capture the local coordinates of the MC I want the caption to appear on (the dot on the map). Then translate that to global coordinates of the stage and have the whole caption/textbox thing at the maintimeline?

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 7:38pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/4 "2004-05-27T19:38:52Z")

</div>

basically, yeah. when you have a position inside a movieclip, its based on the coordinates of that movieclip itself. put a ball mc in a box mc at location (10,10) and move that box around on the main tiemline all you want and that ball will still be at (10, 10). What localtoglobal will do is translate that 10,10 to a global (\_root based) coordinate as though the ball were moving in \_root following the box. This means you can have your hover caption outside of your map completely, but still keep track of the coordinates it _should_ have inside it and translate them to that outside.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 7:40pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/5 "2004-05-27T19:40:18Z")

</div>

Sweet! I’ll give it a shot - thanks for the explanation and for rescuing this thread. 😉

:hr:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 8:40pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/6 "2004-05-27T20:40:11Z")

</div>

So here’s what is really frustrating. I put the whole hover caption box movie clip at the root level to begin this process and it works. I didn’t have to use localtoglobal at all! What’s up with that? Here I was mentally preparing myself for some major brain staggering alerations of my brilliant actionscript (_cough_) and I didn’t have to do a dang thing except unbury my movie clip, bring it to the surface for some light and air, and change all those wicked long paths you see above to reference the clip now at the main timeline.

:sigh: + :trout: = :hangover:

ARGH! :pirate3:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 8:43pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/7 "2004-05-27T20:43:06Z")

</div>

lol, you’ve been too long in that tower;)

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 8:49pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/8 "2004-05-27T20:49:44Z")

</div>

😉 No kidding! Send me a horse will ya? 😛

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 8:55pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/9 "2004-05-27T20:55:45Z")

</div>

…if your hover captions are following the mouse, then you wouldnt need the localtoglobal stuff… which looking back and actually reading, I see you mentioned :trout:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 9:00pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/10 "2004-05-27T21:00:21Z")

</div>

Your wish is my command=)

scotty(-:

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [May 27, 2004, 9:13pm UTC](https://forum.kirupa.com/t/dynamically-created-hover-captions/109918/11 "2004-05-27T21:13:14Z")

</div>

Excellent. Except it needs a super big brain that says “actionscript dictionary”! 😛

@Sen - heh, well I guess it’s always good to learn something new right? Now I just need to incorporate it all into xml . . . :sen:
