+1

Downloadcomplete event only firing once

Richard Lindley fa 12 anys updated by icahill (Administrator) fa 12 anys 1
if I explicitly list downloads in my wire the downloadcomplete event works as expected, firing each time the file is downloaded:


<download downloadcomplete="count-images" url="http://imagelocation/page0000001.jpg filename="page000001.jpg"></download><download downloadcomplete="count-images" url="http://imagelocation/page0000002.jpg filename="page000002.jpg"></download><download downloadcomplete="count-images" url="http://imagelocation/page0000003.jpg filename="page000003.jpg"></download><download downloadcomplete="count-images" url="http://imagelocation/page0000004.jpg filename="page000004.jpg"></download>


However, if I put the download in a loop, the event only gets fired once, the first time:


<assign property="var:index" value="1"/>
<assign property="var:count" value="1"/>

<action name="download-pages">
<if lhs="[var:index]" operator="lte" rhs="4">
<download downloadcomplete="count-images" url="http://imagelocation/page000000[var:index].jpg filename="page00000[var:index].jpg">
<assign property="var:index" value="[eval:[var:index] + 1]"/>
<play action="download-pages"></play>
</if>
</action>

<action name="count-images">
<assign property="var:count" value="[eval:[var:count] + 1]"/>
<scale target="PROGRESSBAR" width="[eval:[var:count] / [var:total] * 100]%" time=".15"></scale>
</action>



What am I doing wrong?

Also, is there any way to add variables in the download tag so the complete has an idea as to which file has downloaded?
Richard,

I tested this scenario and it does appear to be a bug. You will need to use the first solution as a workaround. I will log a bug request.

Regarding your second question, there is a global variable called [file:nameoffile] that can return a yes or a no depending on whether the file is stored in the resource bundle or not. This could be useful as you can check if the last file was downloaded correctly.