Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7033001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:00:24+00:00 2026-05-28T01:00:24+00:00

I have been looking for a better way to handle this issue maybe its

  • 0

I have been looking for a better way to handle this issue maybe its just the verbiage I’m using but I’m not finding the answer I want. I’ll explain what I’m doing and hopefully someone out there will be able to explain how to do this.

When developing a flash project on my machine I can use something like:

        var request:URLRequest = new URLRequest("images.xml"); 
        var loader:URLLoader = new URLLoader();
        loader.addEventListener(Event.COMPLETE, handleResult);
        loader.addEventListener(IOErrorEvent.IO_ERROR, handleIOError);
        loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, handleSecurityError);

        loader.load(request);

As long as the images.xml file is located in the same directory as the .fla then it works fine. However once I move the .swf, .xml and my images to the web it all goes down the drain. The .swf can no longer find the .xml file and I know why. Using FlashBug I can read the error in the console.

IOError: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://www.mydomain.com/images.xml"]

And there’s the problem when I move my .swf to my web server the URLRequest adds my domain to the request. Since the file was just located in the same directory on my machine it didn’t cause an issue to just say “images.xml” but now in order to make it work I have to change it to “http://www.mydomain.com/flash/myproject/images.xml”.

I want to know if there is a way to force the .swf to just continue to look in the directory it is in for the files it needs. I think having to spell it out is counter-intuitive because then I can’t just move the files without having to re-write my AS3 code.

I know this can be done I’ve seen projects do it, I just wish I knew how they did it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:00:25+00:00Added an answer on May 28, 2026 at 1:00 am

    I want to know if there is a way to force the .swf to just continue to
    look in the directory it is in for the files it needs.

    Yes, there is, you can use the base attribute of the object and embed tags.

    As default, relative paths in ActionScript are resolved relative to the page that contains the Flash, not relative to the swf file, but the base attribute lets you specify another directory path, that is used to resolve relative paths.

    So for your example path above, it would be something like this:

    <param name="base" value="/flash/myproject/">
    
    <embed base="/flash/myproject/" src="...
    

    Or if you use SwfObject to embed the swf, you can specify base via the attributes parameter:

    http://code.google.com/p/swfobject/wiki/documentation

    Edit:

    A followup on this, although the answer has already been accepted, but since you comment that you where initially looking to handle it in ActionScript instead of HTML, and for possible future readers:

    If you for some reason don’t want to, or can’t, set the base attribute in the HTML, an alternative in ActionScript is to use loaderInfo.url to get the URL of the swf, pick the directory part of that and use it as a path to load files that are next to the swf. This is code copied from a project of mine, including the comments:

    // URL to the directory (folder) the main swf file is loaded from.
    // Can be used to load other files realtive to the swf (instead of realtive to the page, which is default).
    // So swfDir will normaly be like "http://www.site.com/upload/somefolder/"
    var swfDir:String = loaderInfo.url.substring(0, loaderInfo.url.lastIndexOf("/")+1);
    

    And later, when you want to load for example an XML file, you would do:

    var request:URLRequest = new URLRequest(swfDir + "images.xml");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking at using TDD and implementing proper testing (only just started
I have been looking at the _layouts/SpUsageSite.aspx logs for my site, but they are
Sorry for the length of this, but more info is usually better than not
I have been looking for an elegant and efficient way to chunk a string
Recently I have been looking at jquery/javascript solutions to emulating the placeholder attribute, but
I have been looking in google for a solution to my problem but no
I've been looking at this Stackoverflow question and have the answer implemented. It works
Have been looking at the MVC storefront and see that IQueryable is returned from
I have been looking into IKVMing Apache's FOP project to use with our .NET
We have been looking at g++ versions 3.2.3 and 4.2.4. With 4.2.4, the performance

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.