1

AS3 noob here. I am using the following code to successfully send a var to my php/database. My problem is that, of course, when I click my button in the Flash movie the browser navigates away to the "http://www.mydomain.com/charity.php?id=c" url.

    function onPressHandlerc(evt:MouseEvent):void { 
    var url:String = "http://www.mydomain.com/charity.php?id=c";
    var request:URLRequest = new URLRequest(url);
    try {
    navigateToURL(request, '_blank');
    } catch (e:Error) {
    trace("Error occurred!");
    }
    } 

How do I set the navigateToURL() to not try to open a "_blank" window and just pass the var silently?

Thanks in advance for any help!

Machineuser
  • 93
  • 1
  • 1
  • 13

1 Answers1

3

Ah think you actually want to use a URLLoader instead of navigateToURL for this case. navigateToURL is real similar to window.open in js if you're familiar, you want something more like AJAX I think which is where the URLLoader comes in.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html

http://help.adobe.com/en_US/as3/dev/WS5b3ccc516d4fbf351e63e3d118a9b90204-7cfd.html#WS5b3ccc516d4fbf351e63e3d118a9b90204-7cf5

shaunhusain
  • 19,630
  • 4
  • 38
  • 51
  • You have gotten me closer than anyone yet on several forums! Thank you! It is updating my database as desired without opening a new blank window. Now the weird part. This script is **only working on the Mac**(in all major browsers)! I am of the belief that Flash is pretty browser/platform agnostic. How the heck can it be not functioning correctly on the PC (in all major browsers)??? My same identical page with a Flash movie is updating my report.php when used on a Mac but not when used on a PC. Does anyone have any ideas why this may be and what I might do about it? Thanks shaunhusain! – Machineuser Dec 05 '12 at 20:54
  • Additonal input: When I click one of my 3 buttons in my Flash Movie on a Mac I can see my report.php page update on any PC browser. But when I click one of my 3 buttons in my Flash movie while using a PC browser the vars don't seem to be getting passed to my database/report.php. I am totally at a loss! What on earth? – Machineuser Dec 05 '12 at 21:05
  • Are you using the debug flash player on both if not install it from here http://www.adobe.com/support/flashplayer/downloads.html, perhaps you're running into a run-time error but not seeing it. Another issue I've seen that's a strange one is sometimes declaring the URLRequest on the line before using it in the loader has made a difference on different systems. Glad I could help some. Also note use firefox or something other than chrome for debugging on windows unless you configure chrome it won't use the debug player. – shaunhusain Dec 05 '12 at 21:27
  • I ran the debugger at your suggestion (thanks) and did not see any errors or problems. This is really weird. Came home and tried it on my PC and it works in all browsers except Internet Exploder. It's still not updating the database when using IE, which of course is an important browser. I'm researching URLLoader not working in IE but haven't found anything promising yet. I have also added a crossdomain.xml file which is what I think the other browsers on the PC were looking for but still no luck with IE. :-( Trying to catch problems with Firebug too. – Machineuser Dec 06 '12 at 02:04
  • Hmm sorry to hear that, not sure of any issue in IE with this. You may want to try out using Charles Web debugging proxy you can use it for free for 30 min at a time, works very well as a proxy particularly for AMF and SSL traffic but is good for everything. – shaunhusain Dec 06 '12 at 04:26
  • Please update your question and post your current code, as both are now not accurately reflecting the current issue. It might actually be good to mark this question as answered as URLLoader is the correct answer, and then open a new question regarding URLLoader not working with IE and posting the current code. – prototypical Dec 06 '12 at 06:41
  • Done. New post here: [link](http://stackoverflow.com/questions/13746128/as3-urlloader-not-working-in-ie-on-pc) Thanks so much to all for the help so far. – Machineuser Dec 06 '12 at 14:53