# Hover Captions problem

**URL:** <https://forum.kirupa.com/t/hover-captions-problem/184198>\
**Category:** flash\
**Created:** [April 3, 2006, 7:42am UTC](https://forum.kirupa.com/t/hover-captions-problem/184198 "2006-04-03T07:42:57Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikyo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ikyo/32/109_2.png) [@ikyo](https://forum.kirupa.com/u/ikyo)\
**Post date:** [April 3, 2006, 7:42am UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/1 "2006-04-03T07:42:57Z")

</div>

Hi everybody

I’ve follow the [hover captions tuto](http://www.kirupa.com/developer/mx2004/hover_captions.htm), and I’m trying to use this good effect on own flash animation, but because i’m a reel newbies in AS, I encounter problems to adapt the script.

In fact, I’ve put this effect in a clip which is in another clip, so the script is not at the root level. Because of this (but I can be wrong) the effect can’t go through : the caption appear on time, and then no more.

What should I have to change on the script to tell i’m all the stuff aren’t in the root level (I’ve try \_parent…but still the same)

Thank you very very much.

Ikyo

---

<div class="post-metadata">

**Author:** ![Dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@Dutchy](https://forum.kirupa.com/u/Dutchy)\
**Post date:** [April 3, 2006, 7:50am UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/2 "2006-04-03T07:50:27Z")

</div>

how can somebody help if you post no script or fla?

Dutchy

---

<div class="post-metadata">

**Author:** ![ikyo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ikyo/32/109_2.png) [@ikyo](https://forum.kirupa.com/u/ikyo)\
**Post date:** [April 3, 2006, 7:57am UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/3 "2006-04-03T07:57:57Z")

</div>

Thanks for you quick answer Dutchy…

I won’t post my \*.fla because i’ve made so many work on it…and the script is just under the link i’ve send

Here is it :  
[FONT=“Courier New”][COLOR=“Blue”][SIZE=“2”]b1.onRollOver = function() {

captionFN(true, “E-Mail!”, this);  
this.onRollOut = function() {

captionFN(false);

};

};  
b2.onRollOver = function() {

captionFN(true, “Portable Devices”, this);  
this.onRollOut = function() {

captionFN(false);

};

};

captionFN = function (showCaption, captionText, bName) {

if (showCaption) {

\_root.createEmptyMovieClip(“hoverCaption”, this.getNextHighestDepth());  
cap.desc.text = captionText;  
cap.\_width = 7\*cap.desc.text.length;  
cap.\_alpha = 75;  
//  
if ((bName.\_width+bName.\_x+cap.\_width)\>Stage.width) {

xo = -2-cap.\_width;  
yo = -17;

} else {

xo = 2;  
yo = -17;

}  
hoverCaption.onEnterFrame = function() {

cap.\_x = \_root.\_xmouse+xo;  
cap.\_y = \_root.\_ymouse+yo;  
cap.\_visible = true;

};

} else {

delete hoverCaption.onEnterFrame;  
cap.\_visible = false;

}

};[/SIZE][/COLOR][/FONT]

The script works perfectly when I put it on the root level, but it get jam when I put it on a clip which is in another clip…

ikyo

---

<div class="post-metadata">

**Author:** ![Dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@Dutchy](https://forum.kirupa.com/u/Dutchy)\
**Post date:** [April 3, 2006, 8:02am UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/4 "2006-04-03T08:02:47Z")

</div>

hi,

you are not calling the function in the root when you put this line on a button outside of the root:

```
ActionScript Code:
[FONT=Courier New][LEFT]captionFN[COLOR=#000000]([/COLOR][COLOR=#000000] **true** [/COLOR], [COLOR=#FF0000]"E-Mail!"[/COLOR], [COLOR=#0000FF]this[/COLOR][COLOR=#000000])[/COLOR];

```

[/LEFT]  
[/FONT]

change it to:

```
ActionScript Code:
[FONT=Courier New][LEFT][COLOR=#0000FF]_root[/COLOR].[COLOR=#000080]captionFN[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000] **true** [/COLOR], [COLOR=#FF0000]"E-Mail!"[/COLOR], [COLOR=#0000FF]this[/COLOR][COLOR=#000000])[/COLOR];

```

[/LEFT]  
[/FONT]

and it should work

edit: do it with all the captionFN function calls!!!

Dutchy

---

<div class="post-metadata">

**Author:** ![ikyo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ikyo/32/109_2.png) [@ikyo](https://forum.kirupa.com/u/ikyo)\
**Post date:** [April 3, 2006, 8:59am UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/5 "2006-04-03T08:59:32Z")

</div>

Thanks for your kindful help…

I’ve try to adapt what you say, things go better, but I still donnot have the moving thing hover my buttons. :jail:

My code is

[COLOR=“Blue”][SIZE=“2”][FONT=“Courier New”]image01.onRollOver = function() {  
\_root.captionFN(true, “Janvier 2006  
Renouvellement de la Poste”, this);  
this.onRollOut = function() {  
captionFN(false);  
};  
};  
image02.onRollOver = function() {  
\_root.captionFN(true, “Mars 2006  
Les Brigades du tigre”, this);  
this.onRollOut = function() {  
captionFN(false);  
};  
};  
\_root.captionFN = function (showCaption, captionText, bName) {  
if (showCaption) {  
\_root.createEmptyMovieClip(“hoverCaption”, this.getNextHighestDepth());  
cap.desc.text = captionText;  
cap.\_width = 4.5\*cap.desc.text.length;  
cap.\_alpha = 75;  
//  
if ((bName.\_width+bName.\_x+cap.\_width)\>Stage.width) {  
xo = 17-cap.\_width;  
yo = -17;  
} else {  
xo = 17;  
yo = -17;  
}  
hoverCaption.onEnterFrame = function() {  
cap.\_x = \_root.\_xmouse+xo;  
cap.\_y = \_root.\_ymouse+yo;  
cap.\_visible = true;  
};  
} else {  
delete hoverCaption.onEnterFrame;  
cap.\_visible = false;  
}  
};[/FONT][/SIZE][/COLOR]

Where am I wrong ?  
Sorry about my lack of knowledge

Many thanks

Ik

---

<div class="post-metadata">

**Author:** ![Dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@Dutchy](https://forum.kirupa.com/u/Dutchy)\
**Post date:** [April 3, 2006, 1:02pm UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/6 "2006-04-03T13:02:18Z")

</div>

hi,

try this(and read comments):

```auto

image01.onRollOver = function() {
	_root.captionFN(true, "Janvier 2006
Renouvellement de la Poste", this);
	this.onRollOut = function() {
		captionFN(false);
	};
};
image02.onRollOver = function() {
	_root.captionFN(true, "Mars 2006
Les Brigades du tigre", this);
	this.onRollOut = function() {
		captionFN(false);
	};
};
// PLACE THIS CODE IN ROOT
_root.captionFN = function(showCaption, captionText, bName) {
	if (showCaption) {
		//WHY CREATE AN EMPTY MOVIE CLIP (IS NOT USED!!!??)
		//_root.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
		// PUT THE CAP MOVIE CLIP IN THE ROOT
		_root.cap.desc.text = captionText;
		_root.cap._width = 4.5*_root.cap.desc.text.length;
		_root.cap._alpha = 75;
		//
		if ((bName._width+bName._x+_root.cap._width)>Stage.width) {
			xo = 17-_root.cap._width;
			yo = -17;
		} else {
			xo = 17;
			yo = -17;
		}
		_root.onEnterFrame = function() {
			_root.cap._x = _root._xmouse+xo;
			_root.cap._y = _root._ymouse+yo;
			_root.cap._visible = true;
		};
	} else {
		delete _root.onEnterFrame;
		_root.cap._visible = false;
	}
};

```

hope it helps,  
Dutchy

---

<div class="post-metadata">

**Author:** ![ikyo](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/ikyo/32/109_2.png) [@ikyo](https://forum.kirupa.com/u/ikyo)\
**Post date:** [April 3, 2006, 2:52pm UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/7 "2006-04-03T14:52:55Z")

</div>

Many thanks for your help Dutchy

But it still don’t work in spite of a copy paste of your code on my flash 8 project…  
:\*(

The best result I’ve have is due to thi code :

```auto
image01.onRollOver = function() {
	_root.captionFN(true, "Janvier 2006
Renouvellement de la Poste", this);
	this.onRollOut = function() {
		captionFN(false);
	};
};
image02.onRollOver = function() {
	_root.captionFN(true, "Mars 2006
Les Brigades du tigre", this);
	this.onRollOut = function() {
		captionFN(false);
	};
};
_root.captionFN = function (showCaption, captionText, bName) {
	if (showCaption) {
		_root.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
		cap.desc.text = captionText;
		cap._width = 4.5*cap.desc.text.length;
		cap._alpha = 75;
		// 
		if ((bName._width+bName._x+cap._width)>Stage.width) {
			xo = 17-cap._width;
			yo = -17;
		} else {
			xo = 17;
			yo = -17;
		}
		hoverCaption.onEnterFrame = function() {
			cap._x = _root._xmouse+xo;
			cap._y = _root._ymouse+yo;
			cap._visible = true;
		};
	} else {
		delete hoverCaption.onEnterFrame;
		cap._visible = false;
	}
};

```

Things goes right but the “hover captions” remain on the page (it should desappear) and it doesn’t go with the mouse (see [here](http://www.mikrosimage.fr/test/test.html) on the “Archive” page

Wish you a good evening

Ik

ikyo

---

<div class="post-metadata">

**Author:** ![Dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@Dutchy](https://forum.kirupa.com/u/Dutchy)\
**Post date:** [April 3, 2006, 2:57pm UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/8 "2006-04-03T14:57:47Z")

</div>

Hi,

you needed to change the code for the onEnterframe, because now it is looking for the cap in the hovercaption movieclip and I assume it is in the \_root.

try this:

ActionScript Code:

[FONT=Courier New][LEFT]\</p\>  
\<p\>\_root.[COLOR=#000080]captionFN[/COLOR] = [COLOR=#000000] **function** [/COLOR] [COLOR=#000000]([/COLOR]showCaption, captionText, bName[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]“hoverCaption”[/COLOR], [COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]getNextHighestDepth[/COLOR]COLOR=#000000[/COLOR][COLOR=#000000])[/COLOR];\</p\>  
\<p\> cap.[COLOR=#000080]desc[/COLOR].[COLOR=#0000ff]text[/COLOR] = captionText;\</p\>  
\<p\> cap.[COLOR=#0000ff]\_width[/COLOR] = [COLOR=#000080]4[/COLOR].[COLOR=#000080]5[/COLOR]_cap.[COLOR=#000080]desc[/COLOR].[COLOR=#0000ff]text[/COLOR].[COLOR=#0000ff]length[/COLOR];\</p\>  
\<p\> cap.[COLOR=#0000ff]\_alpha[/COLOR] = [COLOR=#000080]75[/COLOR];\</p\>  
\<p\> [COLOR=#808080]_// \</p\>\*[/COLOR]  
\<p\> [COLOR=#0000ff]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> xo = [COLOR=#000080]17[/COLOR]-cap.[COLOR=#0000ff]\_width[/COLOR];\</p\>  
\<p\> yo = -[COLOR=#000080]17[/COLOR];\</p\>  
\<p\> [COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> xo = [COLOR=#000080]17[/COLOR];\</p\>  
\<p\> yo = -[COLOR=#000080]17[/COLOR];\</p\>  
\<p\> [COLOR=#000000]}[/COLOR]\</p\>  
\<p\> hoverCaption.[COLOR=#0000ff]onEnterFrame[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]cap[/COLOR].[COLOR=#0000ff]\_x[/COLOR] = [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]\_xmouse[/COLOR]+\_root.xo;\</p\>  
\<p\> [COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]cap[/COLOR].[COLOR=#0000ff]\_y[/COLOR] = [COLOR=#0000ff]\_root[/COLOR].[COLOR=#0000ff]\_ymouse[/COLOR]+\_root.yo;\</p\>  
\<p\> [COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]cap[/COLOR].[COLOR=#0000ff]\_visible[/COLOR] = [COLOR=#000000] **true** [/COLOR];\</p\>  
\<p\> [COLOR=#000000]}[/COLOR];\</p\>  
\<p\> [COLOR=#000000]}[/COLOR] [COLOR=#0000ff]else[/COLOR] [COLOR=#000000]{[/COLOR]\</p\>  
\<p\> [COLOR=#0000ff]delete[/COLOR] hoverCaption.[COLOR=#0000ff]onEnterFrame[/COLOR];\</p\>  
\<p\> [COLOR=#0000ff]\_root[/COLOR].[COLOR=#000080]cap[/COLOR].[COLOR=#0000ff]\_visible[/COLOR] = [COLOR=#000000] **false** [/COLOR];\</p\>  
\<p\> [COLOR=#000000]}[/COLOR]\</p\>  
\<p\>

[/LEFT]

[/FONT]  
edit: something strange happened??? to the code i"ll post it below

Dutchy

---

<div class="post-metadata">

**Author:** ![Dutchy](https://avatars.discourse-cdn.com/v4/letter/d/65b543/32.png) [@Dutchy](https://forum.kirupa.com/u/Dutchy)\
**Post date:** [April 3, 2006, 3:04pm UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/9 "2006-04-03T15:04:22Z")

</div>

```auto

_root.captionFN = function(showCaption, captionText, bName) {
	if (showCaption) {
		_root.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
		cap.desc.text = captionText;
		cap._width = 4.5*cap.desc.text.length;
		cap._alpha = 75;
		// 
		if ((bName._width+bName._x+cap._width)>Stage.width) {
			xo = 17-cap._width;
			yo = -17;
		} else {
			xo = 17;
			yo = -17;
		}
		hoverCaption.onEnterFrame = function() {
			_root.cap._x = _root._xmouse+_root.xo;
			_root.cap._y = _root._ymouse+_root.yo;
			_root.cap._visible = true;
		};
	} else {
		delete hoverCaption.onEnterFrame;
		_root.cap._visible = false;
	}
};

```

Dutchy

---

<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:** [April 3, 2006, 3:06pm UTC](https://forum.kirupa.com/t/hover-captions-problem/184198/10 "2006-04-03T15:06:41Z")

</div>

Hey ya’ll try using the appropriate code tags. It’s really easy just use [noparse]

```auto
 your code here 

```

[/noparse].

It’ll make it much easier for others to read your code and maybe see where the problem is. :hr:
