Tuesday, December 6, 2011

Repeat with doesn't work

I always get this wrong. You may not recognize some of thecode but you can figure it out. What is supposed to happen is thatwhile the music is playing it looks at the time elapsed and changesframes when certain cuepoints are met. Say that gCuelist = [1000,2000, 3000, 4000, 5000, 6000, 7000] gPage is the frame. So frame 1is page 1.

When I run this I get and error : list expected for handler.but I see the correct list in the debugger. One problem is that thedebugger says k = 7 right from the start rather than starting withone and changing as a time is reached. Can anyone see my problem?

global gCuelist, gPage

on ChangePage

repeat with k = 1 to 7
if dmm_CDExtGetElapsedTrackMillisec() %26gt;= getAt(gCuelist,k)and dmm_CDExtGetElapsedTrackMillisec() %26lt; \ getAt(gCuelist,k+1)then gPage = k
end repeat
go to frame gPage

end if
end
Repeat with doesn't work
when k=7
k+1=8
Repeat with doesn't work
Ah, you're right. I added a 0 to the beginning and anothercuepoint at the end, the last cuepoint is the total length of thetrack. When that point is reached something happens anyway. But thescript still doesn't run. I don't know why it says that the list isexpected for handler and then shows the entire list in thedebugger. If I could just get it to go from page 1 to 2, but assoon as I start the program the error pops up.
I fixed it!!!
global gCuelist, gPageNos, gPage, gTrack

on ChangePage

if dmm_CDExtGetElapsedTrackMillisec() %26lt;%26gt;dmm_CDExtLengthTrackMillisec(gTrack) then

repeat with k = 1 to gPageNos

if dmm_CDExtGetElapsedTrackMillisec() %26gt;=getAt(gCuelist,k) and dmm_CDExtGetElapsedTrackMillisec() %26lt;getAt(gCuelist,k+1) then gPage = k

end repeat
go gPage

end if
end if

end

%26gt;%26gt;then gPage = k

I'd change this to:

then
gPage = k
exit repeat

No sense iterating your whole list unless you need to. Withsuch a short
list it likely won't matter, but it's good practice to alwaysdo this.

--
Dave -
Head Developer
www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/


  • msdn
  • No comments:

    Post a Comment