i'm trying to created a auto-rewind movie using a gradient mask in Flash CS4 using AS3. the only problem i'm having is when the movie clip reaches the end of the time line, the maskingLayerMC looses it's gradient. so while the movie rewinds, the maskingLayer has no gradient. it regains it's gradient when the playhead reaches the first frame and once again begins to play.
i've tried adding the .cacheAsBitmap boolean properties on the last frame as well, but it doesn't have any effect and the maskingLayerMC still looses it's gradient.
--- FIRST FRAME ---
//Gradient Masking
maskedLayerMC.mask = maskingLayerMC;
maskingLayerMC.cacheAsBitmap = true;
maskedLayerMC.cacheAsBitmap = true;
//Automatically Rewind Movie Clip
var playBackwards:Boolean = false;
addEventListener(Event.ENTER_FRAME, playDirection);
function playDirection (e:Event):void
{
if (playBackwards == true)
{prevFrame();}
else
{play();}
}
--- LAST FRAME---
//Change Boolean Variable To Rewind Movie Clip (Place In Last Frame)
stop();
playBackwards = true;
[Updated Working Code]
Although i'm not sure why this works or if it's the best solution.
--- FIRST FRAME ---
//Automatically Rewind Movie Clip With Gradient Masking
maskedLayerMC.mask = maskingLayerMC;
var playBackwards:Boolean = false;
addEventListener(Event.ENTER_FRAME, playDirection);
function playDirection(e:Event):void
{
if (playBackwards == true)
{
prevFrame();
maskingLayerMC.cacheAsBitmap = true;
maskedLayerMC.cacheAsBitmap = true;
}
else
{
play();
maskingLayerMC.cacheAsBitmap = true;
maskedLayerMC.cacheAsBitmap = true;
}
}
--- LAST FRAME---
//Change Boolean Variable To Rewind Movie Clip (Place In Last Frame)
stop();
playBackwards = true;
it seems that the problem is with the prevFrame() function since simply adding the properties once inside the playDirection function isn't enough. so the following code, frustratingly, doesn't work.
addEventListener(Event.ENTER_FRAME, playDirection);
function playDirection(e:Event):void
{
maskingLayerMC.cacheAsBitmap = true;
maskedLayerMC.cacheAsBitmap = true;
if (playBackwards == true)
{prevFrame();}
else
{play();}
}