Loading XML, ApplicationDirectory

.NET Edition of the F-IN-BOX
dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Loading XML, ApplicationDirectory

Postby dscha » Tue Jun 24, 2008 4:22 pm

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

dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Postby dscha » Tue Jun 24, 2008 5:10 pm

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);
}

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Tue Jun 24, 2008 7:17 pm

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.
Best regards, Artem A. Razin,
F-IN-BOX support
Ask your question here: http://www.f-in-box.com/support.html

dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Having another problem

Postby dscha » Thu Jun 26, 2008 4:25 pm

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

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Re: Having another problem

Postby Softanics » Thu Jun 26, 2008 4:41 pm

dscha wrote:Could this mean the xml loaded is wrong?


Yes. Have you debugged the code, does it really provide xml content?
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Postby dscha » Thu Jun 26, 2008 5:13 pm

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.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Jun 26, 2008 5:23 pm

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 \ ...
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Postby dscha » Thu Jun 26, 2008 5:54 pm

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.

dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Postby dscha » Thu Jun 26, 2008 6:44 pm

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.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Jun 26, 2008 8:17 pm

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.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html

dscha
Posts: 7
Joined: Tue Jun 24, 2008 4:14 pm

Postby dscha » Thu Jun 26, 2008 8:56 pm

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.

Softanics
Site Admin
Posts: 1402
Joined: Sat Sep 18, 2004 3:03 am
Location: Russia, St. Petersburg
Contact:

Postby Softanics » Thu Jun 26, 2008 9:25 pm

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.
Best regards, Artem A. Razin,

F-IN-BOX support

Ask your question here: http://www.f-in-box.com/support.html


Return to “.NET Edition”

Who is online

Users browsing this forum: No registered users and 19 guests

cron