PDA

View Full Version : images stop loading after switching data set


ghostdog
05-23-2006, 02:30 AM
I have a view containing images. the images are created according to paths specified in a dataset, in the following way:
<view datapath="..." >
<image src="$path{'@img_path'}" ... />

now, I want to switch the dataset in runtime in
order to change the images in the view. everything works OK until I try to switch before the current set of images finished downloading. in that case no images are shown at all. I tried doing 'unload' on the images before switching but this does not seem to help. any suggestions?

here is some code to demonstrate the problem:

<canvas debug="true">

<dataset name="imgdata_1">
<images>
<img id="a1" imgpath="img_1/a.jpg" />
<img id="a2" imgpath="img_1/b.jpg" />
<img id="a3" imgpath="img_1/c.jpg" />
</images>
</dataset>

<dataset name="imgdata_2">
<images>
<img id="b1" imgpath="img_2/a.jpg" />
<img id="b2" imgpath="img_2/b.jpg" />
<img id="b3" imgpath="img_2/c.jpg" />
</images>
</dataset>

<attribute name="curdata" type="number" value="1"/>

<method event="oninit">
imgView.setAttribute("datapath", "imgdata_1:/images/img");
// Debug.write("init!");
</method>

<!-- a button to switch the image set -->
<button y="15" x="150" onclick="changeSet()">Switch set
<method name="changeSet">
Debug.write("change from: " + canvas.getAttribute("curdata"));
if(canvas.getAttribute("curdata") == 1) {
canvas.setAttribute("curdata", 2);
imgView.setAttribute("datapath", "imgdata_2:/images/img");
}
else {
canvas.setAttribute("curdata", 1);
imgView.setAttribute("datapath", "imgdata_1:/images/img");
}

</method>
</button>


<view id="mainView" width="400" height="600" y="50" x="150">
<simplelayout axis="y" spacing="10"/>
<view id="imgView"
bgcolor="#e8f2e8">
<image src="$path{'@imgpath'}" stretches="both">
<method event="onload" >
Debug.write("loaded!!!");
</method>
</image>
</view>
</view>
</canvas>

thanks in advance,
Amir

jstretch
05-23-2006, 07:29 AM
At first I want to recommend disabling the swich button onclick, and renable it in the imgView's onload method. But since multiple images are being loading this would be called when the first image loads instead of the last...still may work.

Also I noticed after it locks up the debugger wont respond when manually typing in objects and functions. The multiple requests for media are probably getting confused somewhere and simply shutting down laszlo...or atleast the object and debugger.