startup-solo.lzx
<canvas width="800" height="600" bgcolor="#677080" proxied="false">
<debug fontsize="12"/>
<script>
var appstart = getTimer();
</script>
<view resource="startup_launching.png"/>
<dataset name="svars" type="http" src="startup.var" request="true"/>
<dataset name="ping" type="http"/>
<handler name="ondata" reference="svars">
global.ping_interval = Number(svars.getPointer().xpathQuery("/params/@ping_interval"));
global.ping_timeout = Number(svars.getPointer().xpathQuery("/params/@timeout"));
global.ping_url = svars.getPointer().xpathQuery("/params/@ping_url");
global.succ_url = svars.getPointer().xpathQuery("/params/@succ_url");
global.fail_url = svars.getPointer().xpathQuery("/params/@fail_url");
// set up a task to try to retrieve the ping_url
ping.timeout = Number(ping_interval);
Debug.write('ping_interval = ', ping.timeout);
Debug.write('ping_url = ', ping_url);
global.pdel = new LzDelegate(ping, 'doRequest');
ping.setSrc(ping_url);
ping.doRequest();
</handler>
<handler name="ondata" reference="ping">
Debug.write('SUCCESS: lz.Browser.loadURL(',succ_url,');');
lz.Browser.loadURL(succ_url);
</handler>
<handler name="ontimeout" reference="ping">
Debug.write('ping.ontimeout');
canvas.checkloaded();
</handler>
<handler name="onerror" reference="ping">
Debug.write('ping.onerror, elapsed ', (getTimer() - appstart));
if ( (getTimer() - appstart) > ping_timeout) {
Debug.write('FAIL: lz.Browser.loadURL(',fail_url,');');
lz.Browser.loadURL(fail_url);
} else {
lz.Timer.addTimer(global.pdel, ping_interval);
}
</handler>
<method name="checkloaded">
Debug.write('checkloaded, elapsed ', (getTimer() - appstart));
if ( (getTimer() - appstart) > ping_timeout) {
Debug.write('FAIL: lz.Browser.loadURL(',sparams.fail_url,');');
lz.Browser.loadURL(sparams.fail_url);
} else {
ping.doRequest();
}
</method>
</canvas>
Cross References
Named Instances