+1

Setting up loops within wire

sovtek fa 11 anys actualitzat fa 11 anys 7
Within my scrubber (the triple bar icon within my app toolbar), I have a list of pages that appears. Each of these pages has a storyId connected to them. When a page is clicked, I am attempting to highlight every page that has the same story id.

Since I can only have one instance of an alias, I figure the only way that I can do this is by getting the first page of the story, and creating a loop to go through the range of the story and highlight each page. My problem is that random pages get skipped sometimes. Could this have something to do with the way I have my sync's setup? Do you know of a better way to do this?

Within "showStoryInfo" action, I have "setupHighlightVars". This sets up all the variables I need to get the correct highlighting of pages. From the datasource, I retrieve the page the page range. I then play the action "highlightStory".

Within the "highlightStory" action, I check to see if the variable "storyPage" is less than the "storyStartPage" variable + the "pageRange". If so, then I make the highlight bar, "STORYFOCUS-[var:storyPage]", visible and assign a +1 to the "storyPage" variable so that it will loop through all pages of the story and highlight all results.

I also do something very similar within removeHighlight. I simple loop through every page within the magazine and make the STORYFOCUS-whatever an alpha of 0. It seems to randomly miss some elements within this loop as well.

Should I be approaching this loop differently within the constraints of wire?
any thoughts on this?
Sorry for the late reply. Let me look into this today and I will get back to you.
The issue here seemed to be a timing issue accessing the datasource to assign your variables. I made a small change to the wire in your setupHighlightVars action and it seems to have given it enough of a gap to work correctly. I added a .5 sec delay to the play action inside of your setupHighlightVars action. This seems to give the datasource time to define all the pages properly.

I also moved the play action inside your removeHighlight action inside of your if statement and that covers the issues with missing a page to remove.


<action name="removeHighlight">
<if lhs="[system:orientation]" operator="e" rhs="portrait">
<assign property="var:totalPagesInBook" value="[datasource:pagesFeed.dataSourceResultCount]" />
<else>
<assign property="var:totalPagesInBook" value="[eval: [datasource:pagesFeed.dataSourceResultCount] * 2]" />
</else>
</if>
<if lhs="[var:removeHighlightPage]" operator="lt" rhs="[var:totalPagesInBook]">
<alpha value="0" target="STORYFOCUS-[var:removeHighlightPage]" />
<assign property="var:removeHighlightPage" value="[eval: [var:removeHighlightPage] + 1]" />
<play action="removeHighlight" />
</if>
</action>


I hope this helps!
Thanks Ian it def helped
Still seem to have some problems with the longer stories randomly but ill tinker with the syncs
Seems to be working perfectly now, thanks for the help!