我正在尝试使用 AS3 在 Flash CS4 中使用渐变蒙版创建自动倒带电影。我遇到的唯一问题是当影片剪辑到达时间线的末尾时,maskingLayerMC 会失去它的渐变。所以当电影倒带时,maskingLayer 没有渐变。当播放头到达第一帧并再次开始播放时,它恢复了渐变。
我也尝试在最后一帧上添加 .cacheAsBitmap 布尔属性,但它没有任何效果,并且 maskingLayerMC 仍然失去它的渐变。
--- 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;
[更新工作代码]
虽然我不确定为什么会这样,或者它是否是最好的解决方案。
--- 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;
似乎问题出在 prevFrame() 函数上,因为在 playDirection 函数中简单地添加属性是不够的。因此,令人沮丧的是,以下代码不起作用。
addEventListener(Event.ENTER_FRAME, playDirection);
function playDirection(e:Event):void
{
maskingLayerMC.cacheAsBitmap = true;
maskedLayerMC.cacheAsBitmap = true;
if (playBackwards == true)
{prevFrame();}
else
{play();}
}