Dont ask me why BUT when I test this code in my adobe flash CS3 it works fine and the link opens fine now when I test this on my server it does not open the link...

Any Ideas?

Thanks, Regards X

Below is my code:

button_N.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

function mouseDownHandler(event:MouseEvent):void {
      navigateToURL(new URLRequest("http://www.google.com/"));
}

Dani AI

Generated

Quick summary: the fact that the button worked in the Flash IDE but failed once uploaded — and that publishing to Flash Player 8 fixed it for you — strongly points to an environment / embedding / security mismatch rather than a simple listener or instance-name bug. 's instance-name and event-type checks were useful sanity tests, and was right to point at embed/security parameters as a likely cause.

What to check (concise, practical):

  • Player / ActionScript alignment — confirm the SWF you uploaded and the container (if this SWF is loaded into another SWF or an HTML page) target compatible Flash Player / AS versions. AS3 needs Flash Player 9+; mixing AS versions or AVMs can change how the runtime and browser interact.

  • HTML/object/embed parameters — verify the page that hosts the SWF does not forbid script or networking. A restrictive allowScriptAccess / allowNetworking setting on the HTML/object embed can stop a SWF from opening a URL when running in a browser even though it works in the IDE.

  • Popup blockers vs target behavior — test navigation that replaces the current page (same window) to rule out browser popup blocking. If same-window navigation works but new-window/open is blocked, the browser is likely preventing the popup.

  • Debugging hints — run the content in the Flash Player debug build and watch for SecurityError or runtime traces; add a simple trace on the click handler to confirm the event actually fires when hosted. Check browser console/network for plugin errors and ensure the server serves the SWF with the correct MIME type.

  • Loaded-by-another-SWF pitfalls — if this SWF is loaded into a larger movie, check that the parent isn’t intercepting clicks (overlays, invisible movieclips) and that the loader/page isn’t imposing stricter params.

Short-term: compiling for FP8 is an acceptable quick workaround (as found), but if you move to FP9/AS3, work through the checklist above to find the embedding/security cause so the newer player can be used reliably.

Recommended Answers

All 6 Replies

I would try renaming the instance of your button to google_btn. Actionscript 3.0 works best with buttons and movie clips when instance names use the suffix _btn or _mc respectively.

It sounds like a minor change but it might help. Also, are you using mouse down over CLick for a special reason?

Example change:

function nav(event:MouseEvent):void {
      navigateToURL(new URLRequest("http://www.google.com/"));
}

goggle_btn.addEventListener(MouseEvent.CLICK, nav);

My last piece of advice is to make sure you created a separate layer in flash for the actions

Sorry if I am stating the obvious. Since I do not have the .fla file I want to cover all bases.

let me know if that helps.
-S

you also might need to create a variable to load the URL request. I will look for a past project and will post it tomorrow. But someone else reading this post might be able to give you that piece of code before then

Same thing no luck...

If it makes a difference the fla filed is published as n swf and then loaded by another bigger fla to play it but this should matter...

Like with the things all above, they are more correct programming then actually being right and wrong.

Tried everything above still same thing worked off server didnt work on server.

Note: MouseDown and Click both worked.

Thanks, keep the help coming.

Regards, X

Here is the variable declaration I spoke of in my last post. Written for Actionscript 3.0. Also if you are working in CS3, be mindful that you have selected actionscript 3.0 in the drop down menu within the actionscript window and script assist is turned off.

I hope that helps. Let me know.

Example change:

var nav_req:URLRequest = new:URLRequest(http://google.com/");

function nav(event:MouseEvent):void {
      navigateToURL(nav_req, "_blank");
}

goggle_btn.addEventListener(MouseEvent.CLICK, nav);

-S

just a thought, AS3.0 does not handle scenes the same way as past versions of AS. i tried it on one project and could not get it to work so i gave up. So there may be something else we are missing as well with a .swf inside a .swf.

hang in there. there has to be an actionscript wiz out there that will be able to help you.

I had a similar problem integrating paypal. It was a security feature problem. I changed my allowScriptAccess and allowNetworking param values and it fixed things. Here's what I set the values at:
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowNetworking" value="all" />

I made my own solution.

I went to publishing settings and change the version from Flash Player 9 to Flash Player 8.

Ive seen similar code like above to declare a button being selected.

Im thinking for long ass flash movies the new AS3 is alot better but for short sharp stuff like this "on release" is a whole lot easier.

Anyways it works now, GG Flash Player 8!

Might give flash player 9 a try some time in the near future.

Thanks, Regards X

PS: Thanks for all the help im sure ill use it in the future

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.