Actionscript Question
- Started
- Last post
- 10 Responses
- lyrek
I want to have a movie play a certain mc when the user's mouse leaves the boundaries of a .swf and enters the surrounding page.
I've tried creating a mc that encompasses the whole movie so that an on (rollOut) works, but if I put it in back, other mcs on the stage think return a rollOut to the mc in the bg. I tried putting it in the front, but that makes the mcs behind it unusable. Help?
- ********0
look up hitTest - i think that's what you need - maybe try to restate what you want...
- lyrek0
does this hitTest work with an on (rollOut)?
Restated:
Imagine I want an event to happen when a user rolls his mouse off the .swf and onto the surrounding HTML page.
The movie has scrollbars and movie clips, so if I have an on (rollOut) on a mc on the background, this is triggered when the user rolls over the components in the foreground, even though they haven't rolled out of the movie (they've only rolled onto another mc which makes the bg mc think they've rolled out).
Does that make sense? And I've tried moving the bg mc to the front and making it invisible, but it deactivates the scrollbars and menus, because they're behind the all-encompassing clip, now. :(
Help?
- ********0
DISCLAIMER: The following post is made by someone who is pretty shit at ActionScript. Alternative opinions advised
I sometimes use a button that is basically a thin square border (completely empty in the middle). Have this border on the edges of ur swf and have it detect on(rollOver). When the mouse has "practically" rolledout of ur swf, an event will be trigerred.
I've pulled an all-nighter, i shud get some sleep... in two hours. When my flat-mate wakes up and i can instruct him as to how to print all this stuff i've done.
- enobrev0
from my experience, flash can't actually track the mouse once it's left the movie (unfit?). And for whatever reason, I haven't found a var that states that the mouse is gone... but, I've used something similar to this recently:
bounds = createEmptyMovieClip('bounds', 9999);
bounds.lineStyle(1, 0x000000, 100);
bounds.moveTo(5, 5);
bounds.lineTo(Stage.width -5, 5);
bounds.lineTo(Stage.width - 5, Stage.height -5);
bounds.lineTo(5, Stage.height -5);
bounds.lineTo(5, 5);bounds.onEnterFrame = function() {
if (hitTest(_root._xmouse, _root._ymouse)) {
trace('ON');
} else {
trace('OFF');
}
}copy and paste that into a new movie and you'll see the affect in the trace.
Basically, it creates a box about 5 pixels smaller than the movie. Then it checks if the mouse is in that box.
That extra 5 pixels gives it room to test the mouse position pretty well.
Also, you'll notice I put it at dept 9999. I believe it can be under other things (try putting at 1), but i haven't had the change to try
good luck!
- CyBrainX0
You could try the invisible border of buttons thing, but you should have a high frame rate because you could move the mouse fast enough that your mouse will never be over those buttons during a frame.
- ********0
MOTHA FUCKA!!!
It's the 25th today!!!!!!!!!!!!!!!!!!!!!!!!!!
fuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuckfuck fuck fuck, fuck fuck fuck, All that sleep lost!!!!
dammit, was looking at the wrong year on my calendar ALL WEEK :(
- lyrek0
Kuz, I tried yours and it gave me the problem that Cy was referring to.
Eno, urs worked great in an empty mc, but in my movie it keeps saying:
on
on
on
on
on...even though I'm
off
off
off
off
off... :(i'll keep playing w/ this one. Thanks for ur help!
- lyrek0
bump
- cinder0
Doing it in flash itself will be buggy and inconsistent because it would be possible to move your mouse out real quick and the flash movie wouldn't trigger.
I don't think there's any way to do it across more than IE5.
I'm sure there's some sort of custom insane crap you can do in IE5, though.
JS would be your best bet . . .
But if you explain WHY you want to do this and what you want to happen, or what effect you'd like to achieve - there might be a way better way to do it
(like making the flash full browser, no scale, and keep the content in the center while using the function explained earlier to trigger stuff)
- unformatted0
maybe try something like this.
on mc which triggers another mc to play after leaving boundries:
this.onMouseMove = function() {
if(!this._hitTest(_level0._xmous... _level0._ymouse, true) {
play some movieclip;
}
}