Flash CS6 as3 Navigate to URL stops timeline animation!
Copy link to clipboard
Copied
Hello
I'm hoping someone can help me out! I'm quite new to flash but slowly getting the hang of it. I'm trying to make an interactive banner using jpegs converted to buttons etc with type, all animated. I've got separate layers for everything including mask layers and actions. I just want to navigate on a top layer which is invisible to take the user to a new URL. Everything is working great until I put more than one URL link in the code, as soon as I do the whole banner animation stops!!
If someone could suggest a few ideas it would be much appreciated as I'm all out?!
Many thanks,
here's the code:
import flash.events.MouseEvent;
btn1.addEventListener(MouseEvent.CLICK, btn1Click_1);
btn2.addEventListener(MouseEvent.CLICK, btn2Click_2);
function btn1Click_1(event: MouseEvent): void
{
navigateToURL(new URLRequest("http://www.google.com"), "_self");
}
function btn2Click_2(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.youtube.com"), "_self");
}
addEventListener(MouseEvent.MOUSE_OVER, mo);
function mo (event:MouseEvent):void
{
event.currentTarget.stop();
}
function mo2 (event:MouseEvent):void
{
event.currentTarget.play();
} addEventListener(MouseEvent.MOUSE_OUT, mo2);
Copy link to clipboard
Copied
Your mouse over listeners appear to be assigned to nothing (aka the main timeline) and they are telling the currentTarget to stop. I suspect that is what might be causing the problem
Copy link to clipboard
Copied
This has nothing to do with the URLs.
by writing:
addEventListener(MouseEvent.MOUSE_OVER, mo);
addEventListener(MouseEvent.MOUSE_OUT, mo2);
without referencing an object you want to target Flash assumes you want to target the object you are placing that code on.
In this case: your main timeline.
addEventListener(...)
//gets interpreted as
this.addEventListener(...)
also: read up on the difference between MOUSE_OVER and ROLL_OVER
Copy link to clipboard
Copied
Thanks Ned and moccamaximum for the replies.
The last bit of code does apply to the whole timeline as it stops the animation with a Mouse Over/Roll Over. Taking this away has no effect on the animation in the timeline. The only thing that seems to stop the timeline animation is the second button URL request!
btn2.addEventListener(MouseEvent.CLICK, btn2Click_2);
and:
function btn2Click_2(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.youtube.com"), "_self");
}
Works perfectly without this command. I don't get it!
Copy link to clipboard
Copied
Do you get any error message?
Copy link to clipboard
Copied
I didn't get any error messages at all. Yes I had a look at the mouse events and it wasn't the MOUSE_ROLL/OUT. That was the idea of the code moccamaximum, it was supposed to stop the entire timeline with a MOUSE_OVER so the banner stops.
I Finally got the banner working. Turns out I had to put the actions to the start of the mask frame. I was under the understanding that the code should all go on one actions layer! Did the trick to get it working.
Thank you for your suggestions and help.
Copy link to clipboard
Copied
Did you read up on the difference between MOUSE_OVER/ROLL_OVER?
when using MOUSE_OVER the event is fired for all children of the display object that the listener was added to.
In your case: Any child of the main timeline, which will cause an event mess,that is likely to cause chaos.
trace the MOUSE_OVER out to check if multiple events are fired, when you are using mouse_over, if so, change to roll_over and see where you land.
(same thing for MOUSE_OUT, change it to ROLL_OUT)

