A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 41

Thread: [RESOLVED] Error opening URL (external resources)

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    26

    resolved [RESOLVED] Error opening URL (external resources)

    I'm trying to load external XML and JPEGS using loadMovie and XML.load but keep getting intermittent "Error opening URL" messages. Sometimes the resources load othertimes not.

    Looking at the server logs, there are no 404 errors and System.security.allowDomain has been set.

    I've used onLoad for XML and created a preloader for the JPEG which will retry when a failure occurs BUT even doing this doesn't always work.

    Does anyone have any suggestions? or had similar experiences?

    I've trawled the net and this site and come up blank, so any comments would be very much appreciated. Thank you.

  2. #2
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    so the xml resource cannot be loaded show me the path you use for loading the xml are you loading the file onto a webserver to test it or are you testing it locally ? .......showing me the path to the problem file will probably be enough for me to figure out what is happening.
    ~calmchess~

  3. #3
    Member Pepember
    Join Date
    Jul 2001
    Location
    Berlin
    Posts
    886
    by external do you mean the files are on a different server?
    if you try loading stuff from a different server than the one hosting your flash app, you need to put a crossdomain.xml on that other server allowing the app to access the files.
    Please sign here

  4. #4
    Junior Member
    Join Date
    Aug 2007
    Posts
    26
    Hi calmchess,

    Thanks for replying...

    The XML is running off an internal development webserver - with the swf hosted the same domain and System.security.allowDomain set-up.

    The xml urls vary but they all use the following code:

    <code>
    MovieController.prototype.fetchDataObject = function(request) {

    if (this._content[request]) return false;

    var xml = new XML();
    xml.caller = this;
    xml.request = request;
    xml.loaded = false;
    xml.retries = 0;
    xml.onLoad = function(success) {
    if (!success && this.retries < 3) {
    ++this.retries;
    if (this._debug) trace('RETRY ('+this.retries+'): '+this.request);
    this.load(this.caller._siteprefix+'FlashTalk/'+this.request);
    } else {
    this.caller.onDataXml(this);
    this.loaded = true;
    }
    }
    xml.load(this._siteprefix+'FlashTalk/'+request);
    return xml;

    }
    </code>

    Where this._siteprefix is somthing like:

    "http://localhost/"

    And request would be one of:

    "Site"
    "Blocks/Block/site-block1"
    "News/Record/1"
    etc

    Full code attached.

    Example XML below.

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <content id="Blocks/Block/site-block2">
    <attribute name="date_created">2007-07-01</attribute>
    <attribute name="block">site-block2</attribute>
    <attribute name="type">imagelink</attribute>
    <attribute name="title">REALLY GREAT!</attribute>
    <attribute name="text">Number 1 in FHM&amp;#39;s Top 15 Cool T-shirts. This could make summer very interesting!&lt;br /&gt;</attribute>
    <attribute name="link">News/28</attribute>
    <attribute name="product">CRLT19</attribute>

    <attribute name="image">assets/products/lady/vests/CRLT19w.jpg</attribute>
    </content>



    The most frustrating element is that sometimes the XML/Jpeg loads and othertimes, it doesn't. Any clues?
    Attached Files Attached Files

  5. #5
    Junior Member
    Join Date
    Aug 2007
    Posts
    26

    crossdomain.xml

    Quote Originally Posted by theTick
    by external do you mean the files are on a different server?
    if you try loading stuff from a different server than the one hosting your flash app, you need to put a crossdomain.xml on that other server allowing the app to access the files.
    Hi theTick,

    Both the xml and jpegs are on the same server (and domains) - although, this isn't the case when I'm testing in the authoring environment. The problem is intermittent, rather than just not allowing me to access the resources at all (and behaves the sames for a variety of domain names e.g. localhost, http://testserver/project, etc).

    Presumably crossdomain.xml doesn't apply here?

    Any other ideas?

  6. #6
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    lets trace the actual resources being loaded are you using loadMovie to load the jpeg?? trace the jpegs container and see if it...is getting anything in it wheter it be the bitmap or [object object].......make a trace on the function that fires the image being loaded like this .....trace("yes it fired"); and put that in the function that loads the jpeg so we can make sure that its fireing everytime does it work if you test it in the flash environment ?? if it works each time in the flash environment (when you press cntrl enter) then we at least know the code is working properly....if you want to see your functions fireing in the browser then use msg0.text = "yes it fired" ; and place a dynamic text box on the stage ....and put the msg0.text code in the function you wish to test.
    ~calmchess~

  7. #7
    Junior Member
    Join Date
    Aug 2007
    Posts
    26
    Calmchess:

    If it makes any difference, the XML is generated on the server using php.

  8. #8
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    check your php on the command line....php myfile.php......do you get any warnings ??
    ~calmchess~

  9. #9
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    can you remove your allow domain policy file...if you can remove it and test it.....if it works everytime then your domain policy file is the problem.
    ~calmchess~

  10. #10
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    error opening url messages? are you compiling the .swf on the webserver ?? you do know the .swf and php have to be on the webserver in order for the php to fire right?
    ~calmchess~

  11. #11
    Junior Member
    Join Date
    Aug 2007
    Posts
    26
    Calmchess,

    Thanks for all the ideas, much appreciated!

    Okay so, I've put a trace on the loadMovie and on the loadXML here's an example:

    LOAD: http://localhost/assets/products/boy...180/CRT25w.jpg
    [snip]
    Error opening URL "http://localhost/assets/products/boy/tees/thumbs/180x180/CRT25w.jpg"
    RETRY (1): http://localhost/assets/products/boy...180/CRT25w.jpg
    _level0.imageMenu_mc.mcLargeImages.Boy_Tees_CRT25

    This can happen when I'm loading 2 or 20 images at a time.

    Definitely no PHP errors either when accessing the URL (I've got warnings switched on) or in the logs.

    I don't use a crossdomain.xml.

    And the same problem happens when System.security.allowDomain() is used or not.

    Is it the fact that I'm loading several images/resources at once? Is the flash player timing out? If so, why? and can I do anything about it?

    I tried changing the HTTP Keep-Alive timeout headers for the XML to no avail e.g. <?php header('Keep-Alive: timeout=20, max=100'); ?>

    For reference: I'm using Flash 8 and FP9.

    Any other ideas?

  12. #12
    Junior Member
    Join Date
    Aug 2007
    Posts
    26

    trace code

    For some reason, the trace code got lost in my post

    Here's what I added to the loadLargeImage function:

    var src = this._menuitems[url].value;
    var mcLarge = mcLargeImages.createEmptyMovieClip(id, mcLargeImages.getNextHighestDepth());
    trace('LOAD: '+this._siteprefix+src);
    mcLarge.loadMovie(this._siteprefix+src);

    And to the preloader, when I retry having detected the fail with getBytesTotal() < 0:

    if (this._debug) trace('RETRY ('+this._retries[target]+'): '+url);
    trace(mc);
    for (var p in mc) { trace(p+' => '+mc[p]); }
    mc.loadMovie(url);

    Notice I output trace the clip and it's properties - and there don't appear to be any, as you would expect, I guess?

  13. #13
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    assets is not the root folder of the webserver right...because ......localhost is referring to the root folder of the webserver ........try putting the jpeg in the first folder of your webserver and then say http://localhost/crt25w.jpg....also flash is case sensitive in its paths so make sure you don't have crt25.JPG instead of crt25.jpg
    ~calmchess~

  14. #14
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    you have a path problem....i think your xml and everything is working properly.....sometimes i forget to try the simplest solution first....I will await an answer about my last post...
    ~calmchess~

  15. #15
    Junior Member
    Join Date
    Aug 2007
    Posts
    26
    Quote Originally Posted by calmchess
    assets is not the root folder of the webserver right...because ......localhost is referring to the root folder of the webserver ........try putting the jpeg in the first folder of your webserver and then say http://localhost/crt25w.jpg....also flash is case sensitive in its paths so make sure you don't have crt25.JPG instead of crt25.jpg
    Unfortunately, I can't put the jpeg's into the root level of the domain because they are content managed - the urls above are also generated by the php, so no room for silly typos, and I've double checked that they are indeed case and character perfect.

    Does flash have problems loading assets from different folders?

    As you can see from the trace, the URLs include the domain and full path. Though, in one incarnation, the siteprefix is set to just '/' i.e. without the http://localhost.

    We're definitely ticking off the possible causes!

    Any other thoughts?

  16. #16
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    use absolute paths ...http://localhost /asset_folder/crt.jpg


    always..../root_folder/assestfolder/crt.jpg has always given me problems as well as c:/root_folder/asset_folder/crt.jpg.... and i don't think c:\root_folder\assest_folder\crt.jpg....works in flash.........you are using windows as a server right?
    ~calmchess~

  17. #17
    Junior Member
    Join Date
    Aug 2007
    Posts
    26

    full trace

    Just so as not to cause any confusion, I've attached a full trace.

    The url's in there are live and can be access from your browser.

    (You'll notice that the dynamic site is under development and not live yet - only a static version built by the designers)

  18. #18
    Junior Member
    Join Date
    Aug 2007
    Posts
    26
    Sorry, here's the attachment!!!
    Attached Files Attached Files

  19. #19
    Junior Member
    Join Date
    Aug 2007
    Posts
    26
    Quote Originally Posted by calmchess
    use absolute paths ...http://localhost /asset_folder/crt.jpg
    always..../root_folder/assestfolder/crt.jpg has always given me problems as well as c:/root_folder/asset_folder/crt.jpg.... and i don't think c:\root_folder\assest_folder\crt.jpg....works in flash.........you are using windows as a server right?
    Definitely using absolute paths... at least in this incarnation.

    (I'm using Linux as the server Mandriva on my dev. machine and Fedora on the live server).

  20. #20
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    now i'm thinking you aren't waiting ...for the jpegs to load before you put them in their respective movie clip containers...........you need to use an onload event to fire only after the movieclip container loads.....hold on a minute i have to decrypt some files before i can give you a more definate answer on how to use the onload method with loadMovie.
    ~calmchess~

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