Lingo Dictionary > L-N > loopCount |  |

loopCount

Syntax

    sound(channelNum).queue([#member: member(whichmember), {#startTime: milliseconds, #endTime: milliseconds, #loopStartTime: milliseconds, #loopEndTime: milliseconds, #loopCount: numberOfLoops, #preloadTime: milliseconds, #rateShift: shiftAmount}])
    sound(channelNum).loopCount

Description

Cast member property; the total number of times the specified sound in sound channel `channelNum` is set to loop. The default is 1 for sounds that are simply queued with no internal loop.

You can loop a portion of a sound by passing the parameters `loopStartTime`, `loopEndTime`, and `loopCount` with a `queue()`, `play()`, or `setPlayList()` command. These are the only methods for setting this property.

If `loopCount` is set to 0, the loop will repeat forever. If the sound cast member's `loop` property is set to `TRUE`, the `loopCount` will return 0.

When this property is tested, the value is for the currently playing, paused, or queued sound.

Example

This handler queues and plays two sounds in sound channel 2. The first sound, cast member introMusic, loops five times between 8 seconds and 8.9 seconds. The second sound, cast member creditsMusic, loops three times. However, no `#loopStartTime` and `#loopEndTime` are specified, so these values default to the `#startTime` and `#endTime`, respectively.

    on playMusic
    	sound(2).queue([#member:member("introMusic"), #startTime:3000,\
    	#loopCount: 5,#loopStartTime:8000, #loopEndTime:8900])
    	sound(2).queue([#member:member("creditsMusic"), #startTime:3000,\
    	#endTime:8000, #loopCount:3])
    	sound(2).play()
    end

Example

This handler displays an alert indicating how many times the loop in the cast member of sound 2 plays. If no loop has been set in the current sound of sound channel 2, `sound(2).loopCount` returns 1.

    on showLoopCount
    	alert "The current sound's loop plays" && sound(2).loopCount && "times."
    end

See also

`breakLoop()`, `setPlaylist()`, `loopEndTime`, `loopsRemaining`, `loopStartTime`, `queue(), getPlaylist(), play() (sound), stop() (sound)`