|
-
Wow, what a thread brought back from the dead! 2004...
Anyway, now to answer MY question hah.
What I would do nowadays for things like this, when only dealing with a couple clips is to just do a stage wide onmouseup event and check for hittest. For example:
code:
this.onMouseUp=function () {
if (innerClip.hitTest(_root._xmouse,_root._ymouse) {
//do something;
}
else if (outerClip.hitTest(_root._xmouse,_root._ymouse) {
//do something else;
}
Hope that helps!
-
Senior Member
which I dont think is much different than the MANY replies in that thread that state to use hitTest() instead of a simple rollOver() action..
-
 Originally Posted by Mctittles
Wow, what a thread brought back from the dead! 2004...
Anyway, now to answer MY question hah.
What I would do nowadays for things like this, when only dealing with a couple clips is to just do a stage wide onmouseup event and check for hittest. For example:
code:
this.onMouseUp=function () {
if (innerClip.hitTest(_root._xmouse,_root._ymouse) {
//do something;
}
else if (outerClip.hitTest(_root._xmouse,_root._ymouse) {
//do something else;
}
Hope that helps!
Ahh that's just making things confusing... what are you testing for? why are testing for outerClip onMouseUp. Hmm
So would I keep all that onEnterFrame script with if (!this.isRollOver) { etc etc. and then add the onMouseUp hitTest?
This is what I have:
topbar_work_id_hotspot.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (!this.isRollOver) {
this.isRollOver = true;
useHandCursor = true;
topbar_work_id.gotoAndPlay(2);
}
} else {
if (this.isRollOver) {
this.isRollOver = false;
topbar_work_id.gotoAndPlay(8);
}
}
};
And I want to add onRelease as follows...
topbar_work_id_hotspot.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (!this.isRollOver) {
this.isRollOver = true;
useHandCursor = true;
topbar_work_id.gotoAndPlay(2);
topbar_work_id_hotspot.onRelease = function() {
var moveOffImageX:Tween = new Tween(_root.content.image_hold......
}
} else {
if (this.isRollOver) {
this.isRollOver = false;
topbar_work_id.gotoAndPlay(8);
}
}
};
-
 Originally Posted by whispers
which I dont think is much different than the MANY replies in that thread that state to use hitTest() instead of a simple rollOver() action.. 
Not really except for the fact it is using an onMouseUp event because the person who brought this thread back wanted to know about clicking something instead of just rollover. Anyway...
The onMouseUp event is a global event...by that I mean it works for the entire stage. When the mouse comes anywhere, it runs. So you wouldn't need to put this in the onEnterFrame, just by itself. You can also use onMouseDown to look for a global mouseDown event. So what you do is check for when a mouse is clicked down or let up, then inside that you see where the mouse is at the time. If it is over the right clip then do what you want to do for that clip. The reason I checked for for inside and then outside is the hitTest will return true for the inside and true for the outside when you click inside and will reture false for the inside and true for the outside when you click on the outside click but not inside of that...
-
Fan-blooody-tastic. Yeh i have my script
topbar_work_id_hotspot.onEnterFrame = function() {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
if (!this.isRollOver) {
this.isRollOver = true;
useHandCursor = true;
topbar_work_id.gotoAndPlay(2);
}
} else {
if (this.isRollOver) {
this.isRollOver = false;
topbar_work_id.gotoAndPlay(8);
}
}
};
and before that I have
topbar_work_id_hotspot.onMouseUp = function() {
clearInterval(handle);
var moveOffImageX:Tween = new Tween(_root.....
which was previously onRelease. So are you saying onMouseUp worked where onRelease didn't because it is a global function?
Yeh I only needed the inner rollover to be clickable so didnt need another hit test code...
Thanking you,
Now only 2 problems for my website left to solve. Ha
B
-
Glad you got it working. A couple things to note:
.onMouseUp, .onMouseDown, .onMouseMove etc are all global events. This means that it doesn't matter if you apply them to a movie clip or the main timeline or an object, it will always register no matter where on the stage the mouse event occurs. So, to make the script less confusing it's best just to assign it to this or _root (_root.onMouseUp=function). Using the movie clip (topbar_work_id_hotspot.onMouseUp) makes no difference. This is also the reason I had the hitTest code within the onMouseUp event, since it will register a click for any place on the stage.
Also, this jumping through hoops like my example was only to make nested click events work. If you only need the inner rollover clickable then this should work better:
code:
topbar_work_id_hotspot.onPress=function () {
//stuff
}
or...
code:
topbar_work_id_hotspot.onRelease=function () {
//stuff
}
Whichever you fancy...
-
ha ah yeh it isn't working... cos it doesn't matter where i click, it still executes the code. its like using onrelease without assigning it to an mc.
yeh the reason i resurrected this script is because topbar_work_id_hotspot.onRelease=function () { did work... even if it was separate from the rollover within rollover script. ok so I've used what u said earlier:
this.onMouseUp=function () {
if (topbar_work_id_hotspot.hitTest(_root._xmouse,_roo t._ymouse) {
//do something;
why topbar_work_id_hotspot.hitTest.onrelease didn't work I don't know.
Thanks heaps dude.
Appreciate it.
-
"topbar_work_id_hotspot.hitTest.onrelease" Is that what you were trying? It would be "topbar_work_id_hotspot.onRelease"
-
yeh sorry i meant to say topbar_work_id_hotspot.onRelease. If i have your onEnterFrame hitTest script and onRelease it doesn't seem to work... even when they are separately run functions...
-
 Originally Posted by jbum
A simpler fix might be to leave the clips unnested as you had them, and ignore the rollout event for your outer movie if you are still getting a hitTest on the mouse.
So your outer rollout handler would look like this:
code:
on(rollOut)
{
if (!this.hitTest(_root._xmouse, _root._ymouse))
{
// mouse is outside of movie...
// handle rollout normally
}
}
This also has the advantage of not sucking your CPU with a needless onEnterFrame handler.
Hey question... I'm just wondering how to implement this with the situation I have. I've got it working with the previous onEnterFrame script no worries, but I'm wanting to avoid that if I can.
So I have a drawer which onRollOver slides out. Within this drawer I have a holder mc which dynamically loads in a swf (the loaded swf file is determined by another set of buttons). The swf file contains a row of mcs which have onRollOver handlers. The onRollOver is there to execute a script to set a 'bar' to the x-pos of which ever button is rolled over.
This means that I have a Rollover within a Rollover. As I said, applying the mc1.onEnterFrame = function.... to the mcs within the swf works, but I'm wanting to use the cleaner on(rollOut) script.
Cheers
Barton
-
Senior Member
well its sorta up to you how you want to approach this..
but usually some mix of hitTest and onRollOver/Out will work..
just need to decide what top check for?...and when you want to 'activate' the conditional checks..
example:
instead of on EnterFrame... maybe you can use onMouseMove()..
this way ever time the mouse moves it will check to see it is over this drawer clip.. if so.....
once your hitTest is true.. set a variable.. (drawerOpened == true
and then check to see if that var is true or false..
onMouseMove()
check if mouse is over drawerClip.... if it IS..
check to see if isOpened variable is false.. if FALSE..load the .swf with buttons.. if True.. then you have already hovered over clip..and loaded the swf..
the rollOvers in the .swf should still work fine I believe..
-
Yea, it's something that is not designed in the way flash works so you will probably have to do something a little "hacky" for it to work. If you are concerned about resources with a constant onenterframe or onmousemove, perhaps you could only have the onRollOver, onRollOut within the main larger clip. Then when it's rolled over, start the onMouseMove and when it's rolled off delete the onMouseMove. Might want to test a bit on it as onEnterFrame being turned on and off might work better than onMouseMove. The reason being, I think if you move the mouse quick enough where it goes from outside everything to inside one of the smaller ones, the onRollOver will be called, but onMouseMove won't until you move the mouse again...
-
I gotta say, it seems a lot more logical to have the main button execute the onEnterFrame event and the submenu buttons have the onRollOver events.
I hope I wasn't confused and the idea was supposed to be like this originally.
Anyway just made my life easier...
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
|