PDA

View Full Version : Cursor position to tigger animation question



worldly1
March 28th, 2007, 06:17 PM
Hello All,

I’m fairly new to Flash 8 (Pro) and have used only very basic actionscript.

I have made a navigation menu bar with fly-out sub-menus and have everything working correctly. Now I want to put an animated gradient background movie clip behind the menu and set it up so that when the cursor is over/within the boundary of the gradient clip it will trigger it to gotoandplay x frame, and when the cursor leaves the area, trigger another gotoandplay event.

It seems I can’t set it up with onrollover and onrollout actionscript because of the menu that sits above it, so it seems I need some way or work around to know when the cursor enters and leaves an area or set of coordinates (or in this case is above a certain y coordinate) and trigger.

I found this site

http://www.senocular.com/flash/tutorials/buttoncapturing/

which I thought might have the answer but I’m not advanced enough to follow it.

Any advice or direction will be much appreciated.

Scott

npgames
March 28th, 2007, 06:59 PM
i would try a hittest like...



onClipEvent(load){
ovr = 0
if(this.hitTest(_xmouse, _ymouse, true))if(ovr == 0){
gotoAndPlay(frame)
ovr = 1
}
if(this.hitTest(_xmouse, _ymouse, true)){
}else if(ovr == 1){
gotoAndPlay()
}
}


im not positive it will work ,and i cant test it because im on a school comp without flash
but it should be a nudge in the right direction

worldly1
March 28th, 2007, 07:07 PM
Hello Nick,

Thanks for the response. Would I attach this code to the gradient movie clip instance?

Scott

npgames
March 28th, 2007, 07:08 PM
yes

worldly1
March 28th, 2007, 07:15 PM
OK, I did that and it's not working, and I really don't have a grasp of what that code you provided is doing. I'll try and pick it apart and understand it. It's hard being a newbie!

Scott

npgames
March 28th, 2007, 07:18 PM
sorry that was a noob idea,
what it should have done was make a variable that said if the mouse was over or not over. then if the variable was different than what it realy was, it would gotoandplay the frame, and then correct itself, what happens when you put that in your code

worldly1
March 28th, 2007, 07:29 PM
It doesn't do anything when I test the movie. The code passes "check syntax" and no errors are reported.

So I'm in the dark.

Scott

npgames
March 28th, 2007, 07:30 PM
IM A RETARD

ya, i know one of the things i did wrong, and i didnt use the right clipevent,


onClipEvent(load){
ovr = 0
}
onClipEvent(enterFrame){
if(this.hitTest(_xmouse, _ymouse, true))if(ovr == 0){
gotoAndPlay(frame)
ovr = 1
}
if(this.hitTest(_xmouse, _ymouse, true)){
}else if(ovr == 1){
gotoAndPlay()
}
}

worldly1
March 28th, 2007, 07:38 PM
Well I'm not above asking for help from the retarded ;-)

But still a no go. It passes syntax check and no run time error reports. It just doesn't do anything.

Scott

joran420
March 28th, 2007, 08:05 PM
post your fla

npgames
March 28th, 2007, 08:41 PM
lol, id try posting the fla,

and make sure you are putting something inside the play function

worldly1
March 28th, 2007, 08:42 PM
Ok I've attached it. The animated gradient symbol ("Background gradient") is in the bottom layer entitled "Background" and has the code Nick P suggested earlier attached to the symbol.

What I want is that when the cursor enters the area of this gradient movie clip it should gototAndPlay frame 2 of this clip, and then when the cursor leaves, it should gotoAndPlay frame 11. So easy to so with button instances, but not in this case.

Thanks for taking a look,

Scott

npgames
March 28th, 2007, 08:44 PM
its problably me but, where is the fla, like where is it posted

worldly1
March 28th, 2007, 08:51 PM
Oops, I guess the file was too big (133kb) so I'm attaching a zipped version. Hope this works.

Scott

npgames
March 28th, 2007, 09:00 PM
as i dance around the room with the croud cheering,


onClipEvent(load){
ovr = 0
}
onClipEvent(enterFrame){
if(this.hitTest(_root._xmouse, _root._ymouse, true))if(ovr == 0){
gotoAndPlay(2)
ovr = 1
}
if(!this.hitTest(_root._xmouse, _root._ymouse, true))if(ovr == 1){
this.gotoAndPlay(11)
ovr = 0
//extra bit
trace("NICK IS GREAT");
}
}

and if you MUST you can delete the

//extra bit
trace("NICK IS GREAT")

lol

worldly1
March 28th, 2007, 09:17 PM
You dance buddy!!

As I bang my head for not just posting my problem this morning. I spent most of the day trying to figure it out.

Now, if only I knew what your solution was doing. I'll pick it apart and figure it out eventually.

Oh, and the truism "Nick is great" had a good showing. I'll delete the trace, but it definitely stays in the comments!

Thank you SO much. I really appreciate it.

Have a perfect evening,

Scott

npgames
March 28th, 2007, 09:25 PM
well im tired of dancing (not realy) but ill describe what i did easy like

onClipEvent(load){
ovr = 0
}
//made a new variable to use as long as this movie exists, you can name it almost anything


onClipEvent(enterFrame){

if(this.hitTest(_root._xmouse, _root._ymouse, true))if(ovr == 0){

//this tells you if the instance touches (hittests) the _x and _y corrdinates of the mouse,and also checks if the ovr is active which must be "0"

gotoAndPlay(2)
ovr = 1
}

// this tells it to go to where you want it to go and stops it from repeating by changing ovr to "1"


if(!this.hitTest(_root._xmouse, _root._ymouse, true))if(ovr == 1){
this.gotoAndPlay(11)
ovr = 0

//almost the same thing but in reverse, i just figured out the "!" thingy today, lol
}
}

its not the best "picking" but its good for a sophmore