1

I have a file abc.swf embed in a html file called index.html

The SWF file needs to access abc.xml

The abc.xml is stored in Rooms/abc.xml

The index.html is stored in Schedule/index.html

In the abc.swf, I have code:

inforequest=new URLRequest("~/Rooms/abc.xml");

However I got an error:

Error #2044: Unhandled ioError:. text=Error #2032: Stream Error

I know this is because the URL is wrong but I dont know how to fix that. I've tried: Rooms/abc.xml, abc.xml, ../Rooms/abc.xml but none of them worked. Please help!

EDIT:

This is the html file:

@model Booking_Ticket_Management_System.Models.Schedule

@{
ViewBag.Title = "XmlGenerate";
}

<h2>Choose your seats</h2>
<object width="500" height="600">
<param name="movie" value="~/Rooms/@Url.Content(Model.Room.Map)"/>
<embed src="~/Rooms/@Url.Content(Model.Room.Map)" width="500" height="600"/>
</object>
Tung Pham
  • 579
  • 4
  • 11
  • 29

2 Answers2

2

try this,

var myRequest:URLRequest = new URLRequest("../abc.xml");
shankar
  • 632
  • 4
  • 14
  • It means I have to use absolute Url. Is there any way to use relative Url? – Tung Pham May 14 '14 at 08:36
  • If you want to use relative Url, try like this var myRequest:URLRequest = new URLRequest("../abc.xml"); – shankar May 14 '14 at 08:43
  • When I used absolute Url and placed the swf file into the same folder as the html file then I run swf file, it worked, but if I run the html file, it didnt work. I dont know why. – Tung Pham May 14 '14 at 08:51
  • did you embed SWF file in that HTML page? – shankar May 14 '14 at 08:58
  • else try this one http://stackoverflow.com/questions/137326/best-way-to-embed-a-swf-file-in-a-html-page – shankar May 14 '14 at 09:00
  • where is your abc.swf file? – shankar May 14 '14 at 09:05
  • I used "~/Rooms/@Url.Content(Model.Room.Map)" to get the swf file from database. It showed the swf file incorrectly as the swf file didnt recognize the xml file because of the Url path. – Tung Pham May 14 '14 at 09:07
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/52653/discussion-between-tung-pham-and-shankar) – Tung Pham May 14 '14 at 09:20
2

Get into habit to always add at least 2 listeners: Complete - which normally is added by all, and IOErrorEvent which normally is skipped by all:)

var loader:Loader = new Loader();

    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderHandler, false, 0, true);
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, loaderHandler, false, 0, true);

    loader.load(new URLRequest("path/to/image.jpg"));

//...
protected function libLoadHandler(e:Event):void 
{
    var loader:Loader = (e.target as LoaderInfo).loader;
    if(e.type == Event.COMPLETE || e.type == IOErrorEvent.IO_ERROR)
    {
        //unregister both as COMPLETE and IO_ERROR are "finishing" events
        loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, loaderHandler, false);
        loader.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR, loaderdHandler, false);

        //do something after event based on event type
    }
}
Lukasz 'Severiaan' Grela
  • 6,078
  • 7
  • 43
  • 79