-
Mouse over a certain place to get text
Hello. I'm working on someone's Flash project and my task is to add roll over text to all the buttons in the project. The problem is I can't use the actual buttons because the are underneath some other animation. What I want to do is to add roll over text using the coordinates of the button but not the actual button. Is that possible?
Thanks in advance,
Celebor
-
FK'n_dog
use the Mouse.addListener method
example - button at x:50, y:50, width:100, height:50
main timeline code -
PHP Code:
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
if((_xmouse>50 && _xmouse<150) && (_ymouse>50 && _ymouse<100)){
trace("show text");
}
};
Mouse.addListener(mouseListener);
btn.onRelease = function(){ trace("button");}
-
Originally Posted by a_modified_dog
use the Mouse.addListener method
example - button at x:50, y:50, width:100, height:50
main timeline code -
PHP Code:
var mouseListener:Object = new Object();
mouseListener.onMouseMove = function() {
if((_xmouse>50 && _xmouse<150) && (_ymouse>50 && _ymouse<100)){
trace("show text");
}
};
Mouse.addListener(mouseListener);
btn.onRelease = function(){ trace("button");}
Thanks for the reply! I used your code and it worked in sort of different way then I wanted When I mouse over the spot indicated in the script a flash "Output" window pop ups showing the text. What I'm looking for is like sort of text box floating at your mouse point with text.
PS
I didn't reply for so long because I broke my leg and didn't go to work.
-
FK'n_dog
the output window opens as a result of using trace()
you need to replace trace() with the code you use to show your text box
-
I see!
This is the code I use to make it work:
Code:
};
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;
}
};
And this part to link to specific buttons:
Code:
};
binder_btn.onRollOver = function() {
captionFN(true, "TEXT HERE", this);
this.onRollOut = function() {
captionFN(false);
};
The thing is, this code works on buttons, not coordinates. Can you please tell me how I would merge your and this codes?
-
FK'n_dog
PHP Code:
// binder_btn at x:50, y:50, width:100, height:50
mouseListener.onMouseMove = function() {
if((_xmouse>50 && _xmouse<150) && (_ymouse>50 && _ymouse<100)){
captionFN(true, "TEXT HERE", binder_btn);
} else {
captionFN(false);
}
};
-
Originally Posted by a_modified_dog
PHP Code:
// binder_btn at x:50, y:50, width:100, height:50
mouseListener.onMouseMove = function() {
if((_xmouse>50 && _xmouse<150) && (_ymouse>50 && _ymouse<100)){
captionFN(true, "TEXT HERE", binder_btn);
} else {
captionFN(false);
}
};
Sadly it's not working. By not working I mean nothing happens at all. I tried fiddling with the code but the amount of syntax errors I got is unspeakable. I think that the code I provided relies on the actual button too much. Since I can't work with buttons because of the way this project was done (very annoying -_-) I found better code that might suit yours much better. Here it is:
Code:
hoverover.onRollOver = function() {
this.onEnterFrame = function () {
caption._alpha += (100-caption._alpha)/3;
caption._x -= (caption._x-_xmouse)/2;
caption._y -= (caption._y-_ymouse)/2;
}
};
hoverover.onRollOut = function() {
this.onEnterFrame = function() {
caption._alpha += (0-caption._alpha)/3;
};
};
Again I'm not sure how to apply it using coordinates although I will try to do it myself. But it would be very nice if you could help me once again! Thank you!
-
Problem resolved! Thank you for your time!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|