Buffered MovieClip -- Image Sequence

So in a search to play a short film for a game, I ran across movieClips with image sequences. Unfortunately, movieClips load all the images at once. Which means any movie made into an image sequence can easily crash an application.

Thus, I attempted to create the function below as a sort of buffered movieclip. The function below loads the images intermittently so that the application doesn’t crash(given any 40 frames don’t go beyond maximum texture memory).

This runs smoothly on the computer but my phone has a hard time swapping out the old movieclip with the new one. The video freezes and then runs the clip every time.

So how can I make the video play smoothly?
[lua]-----------------------------
– INCLUDES

require “movieclip”

– LOCALS

local deviceWidth = display.contentWidth
local deviceHeight = display.contentHeight

– MOVIE

–set sequence
local clip = {}
for i=1, 100 do
local j =""
if i < 10 then j = “0000”…i
elseif i < 100 then j = “000”…i
elseif i < 1000 then j = “00”…i
elseif i < 10000 then j = “0”…i end
clip[i] = “frame_”…j…".jpg"
end
–set table
clipSet = {}
local slide = 1
local count = 1
for i = 1, 5 do
local smallclip = {}
for j = 1, 20 do
smallclip[j] = clip[count]
count = count + 1
end
clipSet[i] = smallclip
end

– MOVIE FUNCTION

function bufferMovie(clipSet)
slide = 1
local count = 0
newset = {}
for i = 0, 10 do newset[i] = clip[count]; count = count + 1 end
local movie = movieclip.newAnim(newset)
movie.x = deviceWidth * 0.5; movie.y = deviceHeight * 0.5

–Event Listener
playing = function ( event )
if movie:currentFrame() == movie:totalFrames() * 0.5 then
slide = slide + 1
if slide < 10 then
newset = {}
for i = 0, 10 do newset[i] = clip[count]; count = count + 1 end
buff = movieclip.newAnim(newset)
buff.x = deviceWidth * 0.5; buff.y = deviceHeight * 0.5
end
elseif movie:currentFrame() == movie:totalFrames() then
if slide < 10 then
movie:removeSelf()
movie = buff
movie:play()
buff = nil
else
movie:stop()
end
end
end
Runtime:addEventListener(“enterFrame”, playing)
movie:play()
end
bufferMovie(clipSet)[/lua] [import]uid: 54716 topic_id: 12121 reply_id: 312121[/import]