Page 1 of 1

Loading XML, ApplicationDirectory

Posted: Tue Jun 24, 2008 4:22 pm
by dscha
My flash files are set to read an xml file that is in the same directory. However I do not want to put the xml in the working directory. Is there a way to load the xml into the flash object manually through c#, or change the active directory the f_inabox object thinks it is running from?

Whats the easiest way to load XML right into the f_inabox object?
Could you post a small working example?

Thanks

Posted: Tue Jun 24, 2008 5:10 pm
by dscha
Thanks. I found what i was looking for.

Heres a little function to convert a string to a byte array if anyone needs it.


// convert a string to a byte array.
public static byte[] StrToByteArray(string str)
{
System.Text.ASCIIEncoding encoding = new System.Text.ASCIIEncoding();
return encoding.GetBytes(str);
}

Posted: Tue Jun 24, 2008 7:17 pm
by Softanics
Thank you for your question.

So have you resolved the issue?

You should use a fake URL, something like "/private/1.xml". Then handle this path using OnLoadExternalResourceByRelativePath

Thank you.

Having another problem

Posted: Thu Jun 26, 2008 4:25 pm
by dscha
I was able to load xml into a few flash files, but a few flash files in particular are giving me a problem. If I capture the OnLoadExternalResourceByRelativePath and load in xml to these certain flash files they render a blue/turquoise box in my flash object and the xml does not seem to properly load. Any ideas why this would happen? Have you seen this before?

Could this mean the xml loaded is wrong? Is it f_inabox or somehow my flash file doing this? These particular flash files load information from a url.

Thanks

Re: Having another problem

Posted: Thu Jun 26, 2008 4:41 pm
by Softanics
dscha wrote:Could this mean the xml loaded is wrong?


Yes. Have you debugged the code, does it really provide xml content?

Posted: Thu Jun 26, 2008 5:13 pm
by dscha
Well the method I was using to load is the following:

string Message = "";
Message += ("<URLTAG>");
Message += ("<url=\"http://sample.url.com" />");
Message += ("</URLTAG>");

byte[] messageBuffer = StrToByteArray(Message );
Stream.Write(messageBuffer, 0, messageBuffer.Length);

and it has been working for several other files.

Is there a better/different method to use when writing the xml to the stream? The File works fine if I load and run it from flash using an xml file, but for some reason what appears to be the same xml is not working in .net.

Posted: Thu Jun 26, 2008 5:23 pm
by Softanics
dscha wrote:Well the method I was using to load is the following:

string Message = "";
Message += ("<URLTAG>");
Message += ("<url="http://sample.url.com" />");
Message += ("</URLTAG>");


Is this exact copy?

Here:

Message += ("<url="http://sample.url.com" />");

the second " without \ ...

Posted: Thu Jun 26, 2008 5:54 pm
by dscha
Yea that was actually a typo and wont compile.

should have been.

string Message = "";
Message += ("<URLTAG>");
Message += ("<url=\"http://sample.url.com\" />");
Message += ("</URLTAG>");


Hmm. I guess Ill have to find out what is going on. I assume its something in the flash thats causing this box to be rendered when the xml gets loaded with the wrong info.

Posted: Thu Jun 26, 2008 6:44 pm
by dscha
The flash file does require you to set permissions on the folder its running from, and im not sure if this would be an issue or not.

If your folder does not currently have permissions and you run the file you will be redirected to the flash player settings manager after clicking on settings on the pop up dlg.

http://www.macromedia.com/support/docum ... er04a.html


Could this cause an issue with the flash object in the control? Possibly because it might be running a cached or instanced version of the file? Havent looked into how that works yet.

Posted: Thu Jun 26, 2008 8:17 pm
by Softanics
Is it possible to test what xml content the movie received?

May be the movie loaded an xml successfully, but it can't load from the passed URL (I've noticed that you pass URL in xml)? What do you think about this idea?

Also, if it's possible, you can send me the sources to support (at) f-in-box.com

But at the first, it would be great to test what xml is really loaded into the movie.

Thank you.

Posted: Thu Jun 26, 2008 8:56 pm
by dscha
How do I test what xml content the movie received? Is there a way to test this after the stream.write has occurred?

It works fine for the url in a folder with just the swf, and the xml file. but through .net code for some reason its not working.

Ill try making a project and see if I can send it to you for tomorrow. Im not sure what is going on.

Posted: Thu Jun 26, 2008 9:25 pm
by Softanics
dscha wrote:Ill try making a project and see if I can send it to you for tomorrow. Im not sure what is going on.


It would be really great.