PDA

View Full Version : Possible to load XML dataset from SWF?


jimhsu
03-31-2005, 02:12 PM
I'm trying to have my compiled Laszlo SWF file load a dynamic XML dataset. Thus far, it either displays the data that was already baked in during compile, or it hangs (probably on a request).

Is there any way to load an XML dataset from a SWF? I'm wondering if JavaScript would work.

p.s. This works great with an LPS. However, I'd like to know if LPS is absolutely necessary.

Here is a simple test case:

<canvas>
<dataset name="dset" src="phonebook.xml"/>

<simplelayout axis="y"/>

<view datapath="dset:/phonebook/employee">
<simplelayout axis="x"/>
<text datapath="firstName/text()"/>
<text datapath="lastName/text()"/>
<text datapath="phone/text()"/>
</view>

<button>Reload
<method event="onclick">
dset.doRequest();
</method>
</button>
</canvas>

hqm
03-31-2005, 02:25 PM
Check some of the examples - the demos/vacation-survey.lzx, for example. You need to tell the compiler if a dataset should be baked in at compile time, or fetched via HTTP at runtime. You can also specify whether the dataset is autoloaded at app startup (request="true") or not. You can fire the request under program control using the doRequest() method.

jimhsu
04-01-2005, 11:49 AM
Thank you, Henry! Ok, with his help, I figured out how to do this:

First, the dataset line is changed to http type:

<dataset name="dset" src="phonebook.xml" type="http"/>

Second, the compiled SWF is placed on a web server, and invoked with a URL such as:

http://localhost/dataremote.swf?lzproxied=false

Note: The last part "?lzproxied=false" is critical.

hqm
04-01-2005, 03:07 PM
Note you can also set this property on the canvas and it will be "baked in" to the app, so you won't need the query arg:

<canvas proxied="false">


the attribute name in that case is "proxied", not "lzproxied" as it is for the query arg.