我一直在尝试使用不同的影片剪辑在Flash中创建一个库。
Timeline
-back button
-next button
-stop button
-play button
-Main Movie
(these are inside Main Movie)
--Animation 1
--Animation 2
--Animation 3
我在主电影中设置了动画,实例名称和帧名称如“动画1”。我让它玩和停止,但我无法通过后面和下一个按钮来回穿过每个动画。什么是正确的方法,我可以把它拉下来?
---更新8-20-2010
我得到了它的工作,但有一个小虫子。每当我点击下一个或后退按钮时,它会转到第一个帧名称,然后转到另一个帧名称。我做了一个跟踪,我发现它计为“ad-1,ad-2,ad-3等......”或“ad1,ad2,ad3等......”
var currentAnimationIndex:int;
var currentAnimation:int;
var animeOstart:Number = 1;
var animeOend:Number = 3;
function playAnimation(frameIndex:int):void
{
var frameName:String = "ad" + frameIndex.toString();
trace(frameName)
ads.gotoAndPlay(frameName);
ads.movie.gotoAndPlay(1);
currentAnimationIndex = frameIndex;
}
function playBack(event:MouseEvent):void
{
--currentAnimationIndex;
if(currentAnimationIndex < animeOstart)
currentAnimation == 1;
playAnimation(currentAnimationIndex);
}
function playNext(event:MouseEvent):void
{
++currentAnimationIndex;
if(currentAnimationIndex > animeOend)
currentAnimation == 3;
playAnimation(currentAnimationIndex);
}
答案 0 :(得分:1)
您应将以下代码放在按钮所在的主时间轴上。我已将实例名称“main”指定给您的Main MovieClip。
var currentAnimationIndex:int;
public function playAnimation(frameIndex:int):void
{
var frameName:String = "Animation " + frameIndex.toString();
main.gotoAndStop(frameName);
currentAnimationIndex = frameIndex;
}
public function playBack(event:MouseEvent):void
{
--currentAnimationIndex;
if(currentAnimationIndex < 1)
currentAnimation == 3;
playAnimation(currentAnimationIndex);
}
public function playNext(event:MouseEvent):void
{
++currentAnimationIndex;
if(currentAnimationIndex > 3)
currentAnimation == 1;
playAnimation(currentAnimationIndex);
}
创建一个变量,用于注册当前动画并递减它或增加它以返回或播放下一个动画。使用MouseEvent侦听器将相关功能分配给按钮。我在这里用过1&amp; 3你可以有几个变量,minAnimIndex&amp; maxAnimIndex。
希望这有帮助!
答案 1 :(得分:0)
在AS3中找到了如何做到这一点!!!!
b_back.addEventListener(MouseEvent.CLICK, prevSection);
b_next.addEventListener(MouseEvent.CLICK, nextSection);
function nextSection(event:MouseEvent):void {
var thisLabel:String = ads.currentLabel; // gets current frame label as string
var thisLabelNum:String = thisLabel.replace("ad", ""); // cuts the leading letters off of the number
var curNumber:Number = Number(thisLabelNum); // converts that string number to a real number
if (curNumber < 3) {
var nextNum:Number = curNumber + 1; // adds 1 to the number so we can go to next frame label
ads.gotoAndPlay("ad" + nextNum); // This allows us to go to the next frame label
}else if(curNumber >= 3){
ads.gotoAndPlay("ad" + 1); // This allows us to go to the next frame label
}
}
function prevSection(event:MouseEvent):void {
var thisLabel:String = ads.currentLabel; // gets current frame label as string
var thisLabelNum:String = thisLabel.replace("ad", ""); // cuts the leading letters off of the number
var curNumber:Number = Number(thisLabelNum); // converts that string number to a real number
var prevNum:Number = curNumber - 1; // subtracts 1 from the number so we can go to next frame label
ads.gotoAndPlay("ad" + prevNum); // This allows us to go to the previous frame label*/
if (curNumber == 1) {
ads.gotoAndPlay("ad" + 3); // This allows us to go to the next frame label
}
}
从这个网站找到它。 http://www.developphp.com/Flash_tutorials/show_tutorial.php?tid=161