Skip to main content
Known Participant
October 9, 2006
Question

rollover text in buttons doesn't work inside movieclip

  • October 9, 2006
  • 12 replies
  • 683 views
hello,
i have a problem, i need to put a text when rollovers a button with the mouse and that small text follows the mouse,
i already now to do that but the problem is that the buttons are inside a movie clip so the text doesn't apear, it doesn't work

can anybody help me?

my code is this:

b2.onRollOver = function() {

captionFN(true, "Cervejaria", this);
this.onRollOut = function() {

captionFN(false);

};

};
b3.onRollOver = function() {

captionFN(true, "Eventos", this);
this.onRollOut = function() {

captionFN(false);

};

};
b4.onRollOver = function() {

captionFN(true, "Cafetaria", this);
this.onRollOut = function() {

captionFN(false);

};

};
b5.onRollOver = function() {

captionFN(true, "Bebidas", this);
this.onRollOut = function() {

captionFN(false);

};

};
b6.onRollOver = function() {

captionFN(true, "Localização", this);
this.onRollOut = function() {

captionFN(false);

};

};
b7.onRollOver = function() {

captionFN(true, "Chás", 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;

}

};




(b2; b3; b4; b5; b6 and b7 are the buttons)

thank you (sorry my english)
This topic has been closed for replies.

12 replies

in_v3rtAuthor
Known Participant
October 24, 2006
can anibody help me with this problem?
in_v3rtAuthor
Known Participant
October 20, 2006
well, but i need to return to that first frame because is the frame that have all the buttons.

is like this: i have a first frame with one button and a movie clip with 6 buttons i click in one button an go and play some frames with information about that button. then i close the information to return to the frame with that buttons to continuing exploring the site.

but when the frame is loaded the text box apears in my mouse : s
Participating Frequently
October 19, 2006
i believe its because when you go back to the first frame you are re-declaring all the code again, try to have it go back to a frame that dosent have the code on it.
in_v3rtAuthor
Known Participant
October 19, 2006
Ok... i am in the first frame with all that buttons, the text box apears and disapears in the mouse fine when i rollover the buttons then
I click in one button and go an play another frames with information then i close and return to the first frame. And in the moment the frame is loaded the text box without the text apears in my mouse.

Maybe is important to say that i have a single button that is outside the movieclip it is in the main timeline with this code:

b1.onRollOver = function() {

captionFN(true, "Apresentação", 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;

}

};


i hope i was clarify

sorry about english
Participating Frequently
October 19, 2006
why are you leaving the frame? cant you just stay there?
in_v3rtAuthor
Known Participant
October 19, 2006
why that happens? it should just apear when i rollover a button

please help me

thnks
in_v3rtAuthor
Known Participant
October 19, 2006
hello again,

now I have another problem

when i return to the frame that have that code the text box but just the box apears in the mouse

the box has this instance name >> cap
Participating Frequently
October 12, 2006
oh ok glad you figured it out
in_v3rtAuthor
Known Participant
October 12, 2006
I did like you said:

b2.onRollOver = function() {
_root.captionFN(true, "Cervejaria", this);
};
b3.onRollOver = function() {
_root.captionFN(true, "Eventos", this);
};
b4.onRollOver = function() {
_root.captionFN(true, "Cafetaria", this);
};
b5.onRollOver = function() {
_root.captionFN(true, "Bebidas", this);
};
b6.onRollOver = function() {
_root.captionFN(true, "Localização", this);
};
b7.onRollOver = function() {
_root.captionFN(true, "Chás", this);
};
captionFN = function (showCaption:Boolean, captionText:String, bName:MovieClip) {
if (showCaption) {
_root.createEmptyMovieClip("hoverCaption", 420);
with (_root.hoverCaption) {
this.createTextField("cap", 0, 0, 0, bName._x, bName._y);
cap.autoSize = true;
cap.selectable = false;
if ((bName._width+bName._x+cap._width)>Stage.width) {
xo = -2-cap._width;
yo = -17;
} else {
xo = 2;
yo = -17;
}
}
hoverCaption._alpha = 75;
hoverCaption.onEnterFrame = function() {
cap._x = _root._xmouse+xo;
cap._y = _root._ymouse+yo;
};
bName.onRollOut = function() {
_root.captionFN(false, "", this);
};
cap.text = captionText;
} else {
delete _root.hoverCaption.onEnterFrame;
_root.hoverCaption.removeTextField(cap);
_root.removeMovieClip(hoverCaption);
}
};


but the text still doesn't disappear!

so I put the code like this:

b2.onRollOver = function() {
_root.captionFN(true, "Cervejaria", this);
this.onRollOut = function() {

_root.captionFN(false); }
};
b3.onRollOver = function() {
_root.captionFN(true, "Eventos", this);
this.onRollOut = function() {

_root.captionFN(false); }
};
b4.onRollOver = function() {
_root.captionFN(true, "Cafetaria", this);
this.onRollOut = function() {

_root.captionFN(false); }
};
b5.onRollOver = function() {
_root.captionFN(true, "Chás ", this);
this.onRollOut = function() {

_root.captionFN(false); }
};
b6.onRollOver = function() {
_root.captionFN(true, "Localização", this);
this.onRollOut = function() {

_root.captionFN(false); }
};
b7.onRollOver = function() {
_root.captionFN(true, "Bebidas", this);
this.onRollOut = function() {

_root.captionFN(false); }
};
captionFN = function (showCaption:Boolean, captionText:String, bName:MovieClip) {
if (showCaption) {
_root.createEmptyMovieClip("hoverCaption", 420);
with (_root.hoverCaption) {
this.createTextField("cap", 0, 0, 0, bName._x, bName._y);
cap.autoSize = true;
cap.selectable = false;
if ((bName._width+bName._x+cap._width)>Stage.width) {
xo = -2-cap._width;
yo = -17;
} else {
xo = 2;
yo = -17;
}
}
hoverCaption._alpha = 75;
hoverCaption.onEnterFrame = function() {
cap._x = _root._xmouse+xo;
cap._y = _root._ymouse+yo;
};
cap.text = captionText;
} else {
delete _root.hoverCaption.onEnterFrame;
_root.hoverCaption.removeTextField(cap);
_root.removeMovieClip(hoverCaption);
}
};

And now the text disapears fine.
Participating Frequently
October 12, 2006
oh chang the line

bName.onRollOut = function() {
_root.captionFN(false);
};

to this

bName.onRollOut = function() {
_root.captionFN(false, "", this);
};