Copy link to clipboard
Copied
stop();
blueTarget.addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
function mousehandler2(e:MouseEvent):void {
removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
gotoAndStop("lose");
}
nexttButton.addEventListener(MouseEvent.MOUSE_DOWN, mousehandler3);
function mousehandler3(e:MouseEvent):void {
removeEventListener(MouseEvent.MOUSE_DOWN, mousehandler3);
MovieClip(root).nextFrame();
}
Above is my coding. My issue is that whenever the mouse goes over blueTarget, it doesn't go to the lose screen as it's supposed to.
Am I missing something? Thanks
Luke
It makes a lot of difference. Because scope changes.
If your code is inside of the blueTarget, for example, than it should be:
addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
function mousehandler2(e:MouseEvent):void
{
removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
MovieClip(root).gotoAndStop("lose");
}
Copy link to clipboard
Copied
The code is correct.
Make sure:
- You have a instance on stage called 'blueTarget';
- That it doesn't have any children getting in the way;
- Also that the 'blueTarget' doesn't have a irregular shape that it's interfering with the mouse over.
Copy link to clipboard
Copied
Hi JoaoCesar
My shape is a normal rectangle, I don't think children are in the way however I don't know how to check that and the shape on the stage is called blueTarget.
When the mouse goes over it, all it does is disappears and stays on that frame, doesn't go to lose screen which I named correctly
Thanks
Luke
Copy link to clipboard
Copied
Oh I see...
You said you named your lose screen correctly. But the function gotoAndStop("lose") sends to a label on the timeline named "lose" not to a symbol on the stage called "lose".
Copy link to clipboard
Copied
Correct, it's a frame labeled "lose" not a symbol named "lose"
Thanks
Luke
Copy link to clipboard
Copied
OK. No problem!
Here is a sample: animate_cc_as3_mouse_over.zip - Google Drive .
I hope it helps.
Regards,
JC
Copy link to clipboard
Copied
I opened the SWF File with ease but the FLA File in the folder isn't
When I try to open the FLA File, after I extracted the zip, it says "Unexpected File Format" and won't open
Resend the file maybe? Display code here?
Thanks
Luke
Copy link to clipboard
Copied
What version of Animate are you using? Mine is 18.0.1 (Build 115).
Anyway, I updated the link with a XFL format wich you should be able to open.
Please let me know if it works for you.
Copy link to clipboard
Copied
The FLA opened ok for me.
The going to the lose frame is working. What is there in the test file that isn't working?
Copy link to clipboard
Copied
I see, that was a sample of a working file. The main difference seems to be setting the nexttbutton listener after you get to its frame.
Copy link to clipboard
Copied
I tried taking out the nexttbutton code and just left the blueTarget code and it's still doing the same thing. Once the mouse hits the blueTarget which is a blue rectangle, it disappears, stays on the frame and doesn't go to the lose frame.
Still couldn't get the FLA file to open for some reason and the XFL file won't work since I have CS4 and not Animate.
Thanks
Luke
Copy link to clipboard
Copied
Um, I'm on Adobe Flash CS4 Version 10.0.... Am I in the wrong place lol
Thanks
Luke
Copy link to clipboard
Copied
I reconstructed the sample file in Flash Pro CS3. This should open in CS4 ok:
http://colin.scienceninja.com/flash_pro_cs3_as3_mouse_over.fla
Copy link to clipboard
Copied
Would it be easier if I sent you my SWF of my project. and maybe FLA as well? Cause my code is inside if a button if that makes a difference.
Do you want my FLA & SWF File so you can see what I'm talking about?
Thanks
Luke
Copy link to clipboard
Copied
It makes a lot of difference. Because scope changes.
If your code is inside of the blueTarget, for example, than it should be:
addEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
function mousehandler2(e:MouseEvent):void
{
removeEventListener(MouseEvent.MOUSE_OVER, mousehandler2);
MovieClip(root).gotoAndStop("lose");
}
Copy link to clipboard
Copied
Wow, I can't believe I didn't think of that. Sorry for leaving that detail out! Thanks for your help JoaoCesar and Colin Holgate. It now works!
Thanks
Luke
Copy link to clipboard
Copied
No problem!
The important thing is that it's working now!