ikyo
April 3, 2006, 7:42am
1
Hi everybody
I’ve follow the hover captions tuto , 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
Dutchy
April 3, 2006, 7:50am
2
how can somebody help if you post no script or fla?
Dutchy
ikyo
April 3, 2006, 7:57am
3
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
Dutchy
April 3, 2006, 8:02am
4
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
ikyo
April 3, 2006, 8:59am
5
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
Dutchy
April 3, 2006, 1:02pm
6
hi,
try this(and read comments):
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
ikyo
April 3, 2006, 2:52pm
7
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 :
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 on the “Archive” page
Wish you a good evening
Ik
ikyo
Dutchy
April 3, 2006, 2:57pm
8
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
Dutchy
April 3, 2006, 3:04pm
9
_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
Hey ya’ll try using the appropriate code tags. It’s really easy just use [noparse]
your code here
[/noparse].
It’ll make it much easier for others to read your code and maybe see where the problem is. :hr: