A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: URLRequest works in CS3, but not in the browser

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    16

    URLRequest works in CS3, but not in the browser

    Hey guys, brand new to Flash, so please bare with me if this problem is really simple, I've been searching the tubes all day for a solution but haven't found anything (not sure if I'm searching for the wrong thing)

    Here's some AS3 that I just wrote:
    Code:
    var myServer:String = "https://censored";
    var mySite:String = "/cen";
    var mySubSiteID:String = "33";
    var myXML:String = myServer + "/includes/headerXML.cfm?subsiteid=" + mySubSiteID;
    
    var xmlLoader:URLLoader = new URLLoader();
    var xmlData:XML = new XML();
     
    xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
    xmlLoader.load(new URLRequest(myXML));
    myLargeText.text = "1. data loaded";
    
    function LoadXML(e:Event):void {
    	myLargeText.text = "2. data loaded";
    	xmlData = new XML(e.target.data);
    	myLargeText.text = "3. data loaded";
    	ParseHeader(xmlData);
    }
     
    function ParseHeader(xmlInput:XML):void {
    	trace("XML Output");
    	trace("------------------------");
    	trace(xmlInput.header.smalltext.text()[0]);
    	trace(xmlInput.header.maintext.text()[0]);
    	
    	myLargeText.text = xmlInput.header.maintext.text()[0];
    	mySmallText.text = xmlInput.header.smalltext.text()[0];
    	myLargeTextShadow.text = xmlInput.header.maintext.text()[0];
    	mySmallTextShadow.text = xmlInput.header.smalltext.text()[0];
    }
    
    backtomin.addEventListener(MouseEvent.CLICK, backtominHandler);
    function backtominHandler(event:MouseEvent):void {
    	navigateToURL(new URLRequest("/"), '_self');
    	trace("Action: Back to MIN");
    }
    
    linkarea.addEventListener(MouseEvent.CLICK, linkareaHandler);
    function linkareaHandler(event:MouseEvent):void {
    	navigateToURL(new URLRequest(mySite), '_self');
    	trace("Action: Go to Current Page");
    }
    The problem is, when I do Control -> Test Movie, the page works great, goes out, grabs the XML, replaces the text in the swf with the text it found there. However, when I export the movie and open it on my page in a browser, it doesn't do it. I added the myLargeText.text = "1. data loaded"; parts to see how far it was getting, and it always stops working after the first one, which leads me to believe there is a problem with the URLRequest that is not completing.

    Anyone have any ideas? Thanks in advance.
    muh.

  2. #2
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Is this online, or from a local filesystem? Flash has a sandbox for local filesystem stuff that prevents the player from accessing network resources. Upload it to a server and try again.

  3. #3
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    It's on the server where the problem exists, our local intranet.
    muh.

  4. #4
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Not trying to be pedantic here, just clear. If you're accessing it with a file:// url, you'll get the sandbox behavior. You have to see it with http://

    If that's the case, I don't know what else might be wrong.

  5. #5
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    I understand, the ground-level approach really does help think thru a problem, but I am accessing with http://, (actually, https://, but even that works fine in CS3 for testing)

    the only other thing i could think of, is i am running it thru a noclick script (so that activex box doesn't show up around it by default) but i don't see anything wrong with that myself. maybe some fresh eyes will catch something though.

    Code:
    <cfsetting showdebugoutput="no">
    document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="/swflash.cab#version=8,0,0,0" width="648" height="70" id="header" align="top">');
    document.write('<param name="movie" value="/includes/2008_header.swf">');
    document.write('<param name="quality" value="high">');
    document.write('<param name="allowScriptAccess" value="samedomain">');
    document.write('<param name="allowNetworking" value="all">');
    document.write('<cfoutput><param name="flashvars" value="server=#cgi.server_name#&subSiteID=#url.subSiteID#"></cfoutput>');
    document.write('<param name="scale" value="noborder">');
    document.write('</object>');
    muh.

  6. #6
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    nothing? no ones get any ideas or alternatives?
    muh.

  7. #7
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    The only other thing I see is to check that you can access the xml file through just normal downloading at that same url.

  8. #8
    Palindrome emordnilaP Diniden's Avatar
    Join Date
    Feb 2008
    Posts
    230
    The idea for finding said bug is the KISS method. If you have an issue with a simple problem don't try to solve it with obscure complexity. Make another swf that mebbe ONLY has a URLRequest in it and absolutely nothing else. If that works then you know your issue is of different origins. Then you will also have more to discuss in the case of solving your issue.

    Give it a shot and let us know what's up.

  9. #9
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    Yes, I am completely aware of how to keep it simple, if you would like me to verify I have done something, you can just ask, being pedantic only serves to be insulting. I provided the other information so anyone looking at the problem was able to see the entire thing, it's much easier in the long run than slowly rolling out pieces that may or may not be related.

    But just to verify, yes a swf with nothing but a URLRequest continues to work in CS3 and not in the web browser, I can also view the xml as a valid file from within the web browser.
    muh.

  10. #10
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    All right. Perhaps it's a security model thing. URLLoader can dispatch lots of events for different types of errors. I suggest putting in basic handlers for each of them just to see which is happening. The events can be found on the URLLoader livedocs page:
    http://livedocs.adobe.com/flash/9.0/...URLLoader.html

    For quick reference, these events are:

    complete Dispatched after all the received data is decoded and placed in the data property of the URLLoader object.

    httpStatus Dispatched if a call to URLLoader.load() attempts to access data over HTTP.

    ioError Dispatched if a call to URLLoader.load() results in a fatal error that terminates the download.

    open Dispatched when the download operation commences following a call to the URLLoader.load() method.

    progress Dispatched when data is received as the download operation progresses.

    securityError Dispatched if a call to URLLoader.load() attempts to load data from a server outside the security sandbox.

    I suspect that either ioError or securityError is happening.

  11. #11
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Have you checked the path to your file? It is important that the swf is in the same folder as your html.
    - The right of the People to create Flash movies shall not be infringed. -

  12. #12
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    If that was the problem, he wouldn't get the swf at all. He's stated that it does up to the first trace, so he's getting the swf on the screen. There is no requirement that the swf and html it's embedded in actually be in the same folder. I routinely keep swfs in a different directory.

  13. #13
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    See the example. The html file is in the xml_files folder. I have seen horses puking . So I assume any situation even this may not be the case here.
    Attached Files Attached Files
    - The right of the People to create Flash movies shall not be infringed. -

  14. #14
    Will moderate for beer
    Join Date
    Apr 2007
    Location
    Austin, TX
    Posts
    6,801
    Ah, yes. It's important that the path to the xml file is relative to the right path (swf or html). I forget which is used by default. One can explicitly set the base path through the use of the "base" parameter which will end up being the path used to resolve all relative urls in the swf.

  15. #15
    Junior Member
    Join Date
    Mar 2001
    Posts
    16
    First of all guys, I really want to thank you for the help in solving the problem, you guys rock!

    Thanks to the recommendations, I added an error handler into the code (didn't know how to do that before)

    Code:
    xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, LoadXMLioError);
    function LoadXMLioError(e:IOErrorEvent):void {
    	myLargeText.text = "2. io error";
    	myLargeText.text = e.text;
    }
    which in the browser displays the text "error #2032". I searched and found some documentation that flash dislikes when an xml document has the header values:
    Code:
    pragma: no-cache;
    cache-control: no-cache, no-store, must-revalidate;
    So I changed it according to a recommendation I read and found that changing it to
    Code:
    pragma: bogus;
    cache-control: bogus;
    worked beautifully. Once again, thanks for all the help!
    muh.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center