简体   繁体   English

需要在Flash CS3 AS3中创建一个暂停/恢复切换按钮

[英]Need to create a pause/resume toggle button in Flash CS3 AS3

OK, I have seen a lot of questions and answers on how to code pause/resume buttons, but none of them fit my specific need. 好的,我已经看到了很多有关如何编码暂停/继续按钮的问题和答案,但是都没有满足我的特定需求。 First let me explain what I have: 首先让我解释一下我所拥有的:

I have made a tutorial video for my job. 我已经为我的工作制作了教学视频。 It consists of screens shots and sounds. 它由屏幕快照和声音组成。 I have a forward button that skips to the next section (usually the start of the next audio file) and a back button that goes to the previous section. 我有一个前进按钮可以跳到下一部分(通常是下一个音频文件的开头),而后退按钮可以跳到上一节。 However I need a pause button. 但是我需要一个暂停按钮。

Now let me explain how I have built it: 现在让我解释一下我是如何构建的:

I have made the movie at 1fps. 我以1fps的速度拍了电影。 I have a layer for Audio, a layer for the screen shots, a layer for each button, and various other layers for highlighting things in the screen shots. 我有一个用于音频的图层,一个用于屏幕截图的图层,一个用于每个按钮的图层以及用于突出显示屏幕截图中其他内容的其他各个图层。 On the Audio layer I placed my audio file on the stage and then dragged out the number of frames until the entire audio file could play uninterrupted. 在音频层上,我将音频文件放在舞台上,然后拖出帧数,直到整个音频文件可以连续播放。 So if the audio was 10 seconds long, it lives across 10 frames. 因此,如果音频的时长为10秒,则它可以跨越10帧。 I can then put my screenshot on its own layer and do the same so that the image displays the same length of time as the audio. 然后,我可以将屏幕截图放在自己的图层上,并执行相同的操作,以使图像显示与音频相同的时间长度。 When the frame ends, it automatically skips to the next frame and continues on until the end. 当帧结束时,它会自动跳到下一帧并继续直到结尾。 Since the audio is on the stage, the viewer doesn't need to do anything to get the audio to play. 由于音频在舞台上,因此观众无需执行任何操作即可播放音频。

After viewing many tutorials, it seems like most people use code to get the audio to play rather than putting it on the stage. 看完许多教程后,似乎大多数人都使用代码来播放音频,而不是将其放在舞台上。 I am not this skilled. 我不是这个技能。

So my question is, with my current set up, how can I make a toggle button that basically says "If audio is playing, stop the whole show when clicked- if audio is not playing, resume show from last position when clicked"? 因此,我的问题是,在当前设置下,如何制作一个基本显示为“如果正在播放音频,则在单击时停止整个节目的播放按钮-如果未播放音频,则在单击时从上一个位置恢复播放”?

Thank you so much if you can help! 非常感谢您的帮助! Also, this is my first time asking a technical question like this, please let me know if you need any other specific details. 另外,这是我第一次问这样的技术问题,如果您需要其他任何详细信息,请告诉我。

  1. First make sure all audios on your timeline are set to "Stream". 首先,确保时间线上的所有音频都设置为“流”。 To do this click on the frame where your audio lies, find the sound panel, change it from Event to Stream. 为此,请单击音频所在的帧,找到声音面板,将其从“事件”更改为“流”。 this will ensure that when the timeline is stopped the audio stops and resumes when the timeline is played. 这样可以确保在时间线停止时,音频停止播放,并在时间线播放时恢复。
  2. As for the buttons simply make one that calls stop() on the timeline and one that calls play(). 至于按钮,只需在时间轴上创建一个调用stop()的按钮,然后再创建一个调用play()的按钮。 This will stop the timeline wherever it is and resume it on play. 这将使时间表停止在任何地方,并在进行中继续播放。
var myTimeline:MovieClip;//link to the movieclip where your timeline animation lies
var btnPause:SimpleButton;//link to your pause button
btnPause.addEventListener(MouseEvent.CLICK,function(event:MouseEvent):void{
    myTimeline.stop();
});
var btnResume:SimpleButton;//link to your resume button
btnResume.addEventListener(MouseEvent.CLICK,function(event:MouseEvent):void{
    myTimeline.play();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM