当我单击下一帧时如何停止播放电影 - FLASH CS4?
我在带有观看按钮的电影中的 4 帧中有四个影片剪辑 (.f4v)。这些 f4v 已导入到具有下一个和上一个按钮的主电影容器中。但是,如果我播放电影然后点击下一帧,电影将继续在后台播放。我怎样才能购买这个?下面的代码显示了其中一个影片剪辑的动作脚本,然后显示了主影片中的动作脚本。我是一个闪存新手,所以感谢所有帮助。 非常感谢。
stop();
watch1_btn.addEventListener(MouseEvent.CLICK, playMovie1);
function playMovie1(event:MouseEvent):void
{
movie1_mc.play();
}
// Button Listeners
next_btn.addEventListener(MouseEvent.CLICK, nextSection);
prev_btn.addEventListener(MouseEvent.CLICK, prevSection);
function nextSection(event:MouseEvent):void {
var thisLabel:String = pages_mc.currentLabel; // gets current frame label as string
var thisLabelNum:String = thisLabel.replace("sct", ""); // cuts the leading letters off of the number
var curNumber:Number = Number(thisLabelNum); // converts that string number to a real number
if (curNumber < 5){
var nextNum:Number = curNumber + 1; // adds 1 to the number so we can go to next frame label
pages_mc.gotoAndStop("sct" + nextNum); // This allows us to go to the next frame label
}
}
///////////////////////////////////////////////////////////////////////////
function prevSection(event:MouseEvent):void {
var thisLabel:String = pages_mc.currentLabel; // gets current frame label as string
var thisLabelNum:String = thisLabel.replace("sct", ""); // 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
pages_mc.gotoAndStop("sct" + prevNum); // This allows us to go to the previous frame label
}
I have four movie clips (.f4v) in 4 frames in a movie with watch buttons.. These f4vs have been imported into a main movie container that has next and previous buttons. However if i play a movie then hit next frame, the movie continues to play in the background. How can I shop this? The code below shows the actionscript for one of the movie clips and then the actionscript in the main movie. I am a flash newbie, so all help appreciated.
Many thanks.
stop();
watch1_btn.addEventListener(MouseEvent.CLICK, playMovie1);
function playMovie1(event:MouseEvent):void
{
movie1_mc.play();
}
// Button Listeners
next_btn.addEventListener(MouseEvent.CLICK, nextSection);
prev_btn.addEventListener(MouseEvent.CLICK, prevSection);
function nextSection(event:MouseEvent):void {
var thisLabel:String = pages_mc.currentLabel; // gets current frame label as string
var thisLabelNum:String = thisLabel.replace("sct", ""); // cuts the leading letters off of the number
var curNumber:Number = Number(thisLabelNum); // converts that string number to a real number
if (curNumber < 5){
var nextNum:Number = curNumber + 1; // adds 1 to the number so we can go to next frame label
pages_mc.gotoAndStop("sct" + nextNum); // This allows us to go to the next frame label
}
}
///////////////////////////////////////////////////////////////////////////
function prevSection(event:MouseEvent):void {
var thisLabel:String = pages_mc.currentLabel; // gets current frame label as string
var thisLabelNum:String = thisLabel.replace("sct", ""); // 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
pages_mc.gotoAndStop("sct" + prevNum); // This allows us to go to the previous frame label
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 gotoAndStop() 函数之前,放入 movie1_mc.stop();命令,这将在更改帧之前停止剪辑。
只是在开发方面,如果您只更改视频,请考虑仅使用一帧并使用 addChild() 和 removeChild() 从舞台添加/删除视频。事情通常更容易控制整体绕过这样的框架,并且是一个很好的学习工具。
just before the gotoAndStop() function, just put in a movie1_mc.stop(); command, this will stop the clip before changing the frame.
just on a developmental side of things, if you are only changing the video think about using just the one frame and adding/taking away the video from the stage using addChild() and removeChild(). things are usually so much easier to control overall getting around frames like this and is a good tool to learn.
您有一些很好的逻辑可以在帧之间移动,但有很多是不必要的。使用
currentFrame
。这可以帮助清理您的代码,因为您不再需要拆分字符串然后转换为数字。这些函数将移动到上一帧和下一帧,但不具备您想要的所有功能(例如停在第 5 帧或第 1 帧(未包含在您的原始代码中))...我会让如果你想使用它们,你可以添加它。
但还有一种更简单的方法可以在帧之间切换。 AS3 具有
nextFrame()
和prevFrame()
函数,它们的功能正如它们听起来的那样(分别前进到下一帧和后退到上一帧)。啊。太清爽了。简单、实用的代码。
现在,谈谈你的实际问题。
mc.stop();
,(其中 mc 是实际影片剪辑的占位符)将“停止”影片剪辑。但“停止”并不是这里使用的最佳词。 AS3 中的stop()
函数更像是一个暂停按钮,在调用该函数时将影片剪辑“暂停”在正在播放的帧处。当您返回到任何“暂停”影片剪辑的帧时,根据您的代码,您将只能从暂停点开始播放它。
我建议使用 Flash 的一些内置功能来播放 .f4v/.flv 文件。查看 FLVPlayback,并查看 这个答案查看如何使用它的示例。
FLVPlayback 会将文件中的影片剪辑替换为对计算机(或服务器)上文件的引用,从而使 Flash 文件小得多。它还有自己的电影控件,因此暂停、停止、播放和其他操作都可以立即使用,无需侦听器事件。
玩得开心并尝试!
我希望这有帮助!
You have some great logic to move between frames, but there is a lot that is unnecessary. It is possible to get the integer value of the current frame in one step by using
currentFrame
. This can help clean up your code a bit since you no longer need to split a string and then convert to a number.These functions will move to the previous and next frames, but don't have all the functionality you want (such as stopping at frame 5 or frame 1 (which isn't included in your original code))... I'll let you add that if you want to use them.
But there's an even simpler way to go between frames. AS3 has
nextFrame()
andprevFrame()
functions which do exactly what they sound like (advance to the next frame and reverse to the previous frame respectively).Ah. So refreshing. Simple, functional code.
Now, on to your actual question.
mc.stop();
, (where mc is a placeholder for your actual movie clip) will "stop" the movie clip. But "stop" isn't really the best word to use here. Thestop()
function in AS3 works more like a pause button, "pausing" the movie clip at the frame that was playing when the function is called.When you return to the frame of any "paused" movie clip, based on your code, you will only be able to play it from the point it was paused.
I would recommend using some of flash's built in functionality for playing .f4v/.flv files. Check out the adobe docs on FLVPlayback, and check out this answer to see an example of how to use it.
FLVPlayback would replace the movie clips in your file with references to files on your computer (or a server) making your flash file much smaller. It also has its own movie controls, so pausing, stopping, playing, and others are all immediately available no listener events necessary.
Have fun and experiment!
I hope this helps!