螺旋测微器 flash_Flash 101-第5部分:螺旋式失控

螺旋测微器 flash

灯光,相机,动作! (Lights, Camera, Action!)

The last time out, I showed you how to create simple Flash buttons, and attach actions to them. But that’s just the tip of the iceberg – there’s a whole lot more you can do with the built-in Flash actions.

上一次 ,我向您展示了如何创建简单的Flash按钮以及如何将操作附加到它们。 但这只是冰山一角-内置的Flash操作还可以做更多的事情。

This week, I’m going to expand on that theme, with demonstrations and illustrations of how the various Flash actions can be used in your Flash movie; I’ll also be explaining the various mouse and keyboard events that can be used to trigger them. If you’re familiar with JavaScript, you’ll notice numerous similarities between that language and the Flash event model; if you’re not, don’t worry – all will become clear to you soon.

本周,我将围绕该主题进行扩展,并演示和说明如何在Flash电影中使用各种Flash动作。 我还将说明可用于触发它们的各种鼠标和键盘事件。 如果您熟悉JavaScript,您会注意到该语言与Flash事件模型之间的众多相似之处。 如果您不在,请不要担心-一切很快就会变得清晰起来。

First, though, it’s time to make a movie…

首先,是时候拍电影了……

回收站 (Recycle Bin)

Thus far, you’ve learnt how to use two types of symbols: buttons and graphic symbols. However, Flash also allows you to create a third type of symbol – the movie clip.

到目前为止,您已经学习了如何使用两种类型的符号:按钮和图形符号。 但是,Flash还允许您创建第三种符号-电影剪辑。

Unlike buttons and graphic symbols (which are largely static), movie clip symbols are reusable pieces of animation, each with its own Timeline, layers and objects. Think of a movie clip symbol as a mini-movie, which can be dropped into a larger movie and used over and over again.

与按钮和图形符号(基本上是静态的)不同,影片剪辑符号是可重用的动画片段,每个片段都有自己的时间轴,图层和对象。 将影片剪辑符号想像成微型电影,可以将其放到更大的电影中并反复使用。

This may sound a trifle confusing – after all, how can you place one animation clip within another? – but it’s not as complicated as it appears. Consider the following situation: you have a Flash clip which includes an object performing some repetitive motion (for example, a ball bouncing up and down, or a segment of blinking text). If your animation clip is a long one, it is tiresome to animate this repetitive movement for the entire length of the clip.

这听起来有点令人困惑-毕竟,如何将一个动画剪辑放置在另一个动画剪辑中? –但它并不像看起来那样复杂。 请考虑以下情况:您有一个Flash剪辑,其中包含一个执行重复动作的对象(例如,一个球上下弹跳,或一段闪烁的文本)。 如果您的动画剪辑很长,那么在剪辑的整个长度上为这种重复运动设置动画是很烦的。

A simpler alternative is to animate the repetitive sequence once, turn it into a movie clip symbol, and then insert this movie clip into the larger Flash movie, where it can play repetitively. And since this is now a symbol, you can reuse the animation sequence at different points in our movie without adding to file size – a significant advantage.

一种更简单的选择是对重复序列进行一次动画处理,将其变成影片剪辑元件,然后将此影片剪辑插入较大的Flash影片中,在该影片中可以重复播放。 而且,由于现在这是一个符号,您可以在影片的不同点重用动画序列,而无需增加文件大小,这是一个明显的优势。

An example might help to make this clearer. Open up a new Flash clip, and create a new movie clip symbol named "spiral-movie". Flash will drop you into symbol-editing mode (you’ll notice that this symbol has its own timeline and layers).

一个示例可能有助于使这一点更加清楚。 打开一个新的Flash剪辑,并创建一个名为“ spiral-movie”的新影片剪辑符号。 Flash将使您进入符号编辑模式(您会注意到该符号具有自己的时间轴和图层)。

736_image1

Next, create a simple spiral using the various drawing tools – it might look something like this:

接下来,使用各种绘图工具创建一个简单的螺旋线-看起来可能像这样:

736_image2

Still in symbol-editing mode, convert this spiral object into a graphic symbol, called "spiral-image". You should now see two symbols in your Library, one a movie clip and the other a graphic.

仍处于符号编辑模式,将此螺旋对象转换为图形符号,称为“螺旋图像”。 现在,您应该在媒体库中看到两个符号,一个是影片剪辑,另一个是图形。

Still in symbol-editing mode, insert a new keyframe at frame #30, and create a motion tween between the frames. On the Frame panel, set the symbol to rotate counter-clockwise as it tweens. You can have it rotate as many times as you like. When you play the clip, you’ll see something like this.

仍处于符号编辑模式,在第30帧处插入一个新的关键帧,并在两个帧之间创建补间动画。 在“框架”面板上,将符号设置为在补间时逆时针旋转。 您可以随意旋转它多次。 播放剪辑时,您会看到类似这样的内容。

Note that this animation sequence is actually a movie clip symbol – if you take a look at its entry in the Library, you’ll notice a tiny play/stop button in the preview window, which lets you play the movie clip symbol.

请注意,此动画序列实际上是一个影片剪辑符号–如果查看它在“库”中的条目,您会在预览窗口中注意到一个微小的播放/停止按钮,可用于播放影片剪辑符号。

736_image3

Now that your movie clip symbol has been created and is functioning as advertised, switch back to the Stage. Your Timeline should be empty, with no objects on the Stage.

现在,您的影片剪辑元件已经创建并且可以如所宣传的那样工作,请切换回舞台。 您的时间轴应该为空,舞台上没有任何对象。

Drop the movie clip symbol you just created from the Library on to the Stage, and use the Control -> Test Movie command to play the clip. You’ll notice that although your Flash clip contains only a single frame, the instance of the movie clip symbol in that frame will play continuously in a loop.

将刚从库中创建的影片剪辑元件拖放到舞台上,然后使用“控制”->“测试影片”命令来播放该剪辑。 您会注意到,尽管您的Flash剪辑仅包含一个帧,但该帧中的影片剪辑元件的实例将连续循环播放。

736_image4

Since the movie clip is a symbol, you can place multiple instances of it on the Stage, and manipulate the visible characteristics of each one – as the following example demonstrates.

由于影片剪辑是一个符号,因此您可以在舞台上放置它的多个实例,并操纵每个实例的可见特征-如以下示例所示。

Obviously, for repetitive animation, converting the sequence to a movie clip symbol offers numerous advantages: it reduces file size, improves performance, and makes changing object properties a simpler and more efficient process.

显然,对于重复动画而言,将序列转换为影片剪辑元件具有许多优点:它减小了文件大小,提高了性能,并使更改对象属性变得更加简单有效。

Copyright Melonfire, 2000. All rights reserved.

版权所有Melonfire ,2000。保留所有权利。

重生 (Rebirth)

The example you just saw demonstrates how to create a movie clip symbol from scratch. But what happens if you already have an existing animation sequence (which is not a symbol), and you’d now like to convert it to a symbol? Do you have to create the entire sequence anew?

您刚才看到的示例演示了如何从头开始创建影片剪辑元件。 但是,如果您已经有一个现有的动画序列(不是符号),现在又想将其转换为符号,会发生什么? 您是否需要重新创建整个序列?

Flash allows you to convert an existing animation sequence to a movie clip symbol via a simple copy-paste process. First, open up the file containing the animation sequence you plan to convert, and select all the frames containing the sequence. Use the Edit -> Copy Frames command to copy these frames.

Flash使您可以通过简单的复制粘贴过程将现有的动画序列转换为影片剪辑元件。 首先,打开包含要转换的动画序列的文件,然后选择包含该序列的所有帧。 使用“编辑”->“复制框架”命令复制这些框架。

Now, create a new movie clip symbol using the Insert -> New Symbol command. Flash will drop you into symbol-editing mode, as in the previous example. Select the first frame in the Timeline, and use the Paste Frames command on the shortcut menu to paste the copied frames into the movie clip symbol’s Timeline. You now have a movie clip symbol which you can re-use throughout your Flash movie.

现在,使用“插入”->“新符号”命令创建一个新的影片剪辑符号。 如上例所示,Flash将使您进入符号编辑模式。 选择时间轴中的第一帧,然后使用快捷菜单上的“粘贴帧”命令将复制的帧粘贴到影片剪辑元件的时间线中。 现在,您有了一个影片剪辑符号,可以在整个Flash影片中重复使用它。

To test the symbol, go back to the Stage, and delete the animation sequence from the Timeline of the main movie. Insert an instance of the symbol you just created, and use the Control -> Test Movie symbol to test whether the movie clip works correctly.

要测试符号,请返回舞台,然后从主电影的时间轴中删除动画序列。 插入刚刚创建的符号的实例,然后使用Control-> Test Movie符号来测试影片剪辑是否正常工作。

动态按钮 (Dynamic Buttons)

By allowing authors to separate animation sequences into separate movie clip symbols, Flash makes it possible to add animation and interactivity to buttons as well.

通过允许作者将动画序列分离为单独的影片剪辑符号,Flash还可为按钮添加动画和交互性。

In your existing Flash movie, create a new button symbol named "spiral-button", and insert an instance of the static graphic symbol "spiral-image" for the Up state (in symbol-editing mode). Next, insert instances of the rotating movie clip symbol "spiral-movie" for the Over and Down states. Finally, for the Hit state, draw a filled box which encloses the entire spiral – this identifies the active area of the button.

在现有的Flash电影中,创建一个名为“ spiral-button”的新按钮符号,并为Up状态(在符号编辑模式下)插入静态图形符号“ spiral-image”的实例。 接下来,为“过”和“下”状态插入旋转的影片剪辑元件“螺旋电影”的实例。 最后,对于“击中”状态,绘制一个填充框,该框将整个螺旋线包围起来–这标识了按钮的活动区域。

736_image5

Now, each time the button symbol receives a "hover" or "click" event, it will automatically activate and play the movie clip. Go back to the Stage, and insert an instance of your new button symbol "spiral-button". Use Control -> Test Movie to view the movie clip – you’ll see something like this:

现在,每次按钮符号收到“悬停”或“单击”事件时,它将自动激活并播放影片剪辑。 返回舞台,并插入新按钮符号“ spiral-button”的实例。 使用Control-> Test Movie查看影片剪辑–您会看到类似以下内容的内容:

Now, isn’t that just dandy?

现在,这不只是花花公子吗?

鼠标四处 (Mousing Around)

Next up, actions.

接下来,行动。

Actions allow you to add interactivity to a Flash movie, by executing specific commands in response to user actions. Flash comes with a full-featured scripting language, ActionScript, which is very similar to Javascript; you can either manually create scripts, or use Flash’s built-in Actions panel to insert actions through a point-and-click mode of operation.

通过执行特定的命令来响应用户的操作,操作使您可以向Flash电影添加交互性。 Flash带有功能齐全的脚本语言ActionScript,它与Javascript非常相似。 您可以手动创建脚本,也可以使用Flash的内置“动作”面板通过点击操作模式插入动作。

A number of pre-defined actions are available in Flash, which are more than sufficient for basic requirements; you’ve already seen one of them, the Get URL action, in last time’s article. Typically, these actions are triggered in response to either a mouse or keyboard event, or when a specific frame is reached in the animation sequence.

Flash中提供了许多预定义的动作,这些动作足以满足基本要求。 您已经在上一篇文章中看到了其中之一,即“获取URL”操作。 通常,响应于鼠标或键盘事件或在动画序列中达到特定帧时触发这些动作。

When you specify an action for a button, Flash automatically inserts an onMouseEvent handler to it – this specifies whether the action is to be triggered when the mouse button is pressed or released, when the mouse pointer rolls over the button or when it rolls outside it, or when the user drags the pointer over the button. Additionally, you can specify an action to be triggered when the user taps a specific key on the keyboard.

当您为按钮指定动作时,Flash会自动向其插入onMouseEvent处理函数–这指定是在按下或释放鼠标按钮时,鼠标指针滑过按钮时或在按钮外滚动时触发该动作。 ,或者当用户将指针拖动到按钮上时。 此外,您可以指定当用户点击键盘上的特定键时要触发的动作。

736_image6

For example, this code snippet specifies that the Flash player stop playing the animation sequence when the user releases the mouse button, or taps the X key on the keyboard.

例如,此代码段指定当用户释放鼠标按钮或点击键盘上的X键时,Flash Player停止播放动画序列。

on (release, keyPress "X") {
stop ();  
}

In a similar manner, you can assign actions to a movie clip – Flash automatically inserts an onClipEvent handler, which can trigger actions based on mouse movement, keyboard entry, or at specific positions in the clip.

以类似的方式,您可以将动作分配给影片剪辑– Flash自动插入onClipEvent处理函数,该处理函数可以根据鼠标移动,键盘输入或剪辑中的特定位置触发动作。

736_image7

Finally, you can also assign actions to a specific keyframe in the clip by right-clicking the frame and selecting the Actions command on the shortcut menu.

最后,还可以通过右键单击剪辑并在快捷菜单上选择“动作”命令,将动作分配给剪辑中的特定关键帧。

Note that you should use the Control -> Test Movie command to test whether or not your actions are working correctly.

请注意,您应该使用“控制”->“测试影片”命令来测试您的操作是否正常运行。

Copyright Melonfire, 2000. All rights reserved.

版权所有Melonfire ,2000。保留所有权利。

遥控 (Remote Control)

The basic actions available to you in the Actions panel allow you to add very simple interactivity to your movie. For example, the Go To action allows you to jump to a specific frame, while the Play and Stop actions allow you to pause and resume the animation sequence respectively. You can toggle the quality of the movie with the Toggle High Quality action, or send commands to the Flash player (assuming you’re using the standalone Flash player to play back the clip) with the FSCommand action.

通过“动作”面板中可用的基本动作,您可以为电影添加非常简单的交互性。 例如,“转到”动作允许您跳至特定的帧,而“播放”和“停止”动作则允许您分别暂停和恢复动画序列。 您可以使用“切换高品质”操作来切换影片的质量,也可以使用FSCommand操作将命令发送到Flash播放器(假设您使用的是独立Flash播放器播放剪辑)。

In order to illustrate these actions, I’ve put together a simple animation sequence (you may remember it from one of the previous articles) and added buttons to it in order to allow the user to control the movie. All actions are triggered when the user clicks a button, or hits the key corresponding to the first letter of the command.

为了说明这些动作,我整理了一个简单的动画序列(您可能从上一篇文章中还记得),并向其中添加了按钮,以允许用户控制电影。 当用户单击按钮或按下与命令第一个字母相对应的键时,将触发所有操作。

The first button uses the Play action, the second uses the Go To And Play action, the third uses the Stop action, and the last one uses the FSCommand action to send a quit message to the standalone player (if it exists).

第一个按钮使用Play动作,第二个按钮使用Go To And Play动作,第三个按钮使用Stop动作,最后一个使用FSCommand动作将退出消息发送到独立播放器(如果存在)。

You can also assign these actions to a specific keyframe – I’ll leave you to experiment with this on your own.

您还可以将这些操作分配给特定的关键帧-我让您自己尝试一下。

You can do a lot more with ActionScript, including writing your own scripts to alter the size, shape and appearance of the objects in your Flash movie; however, I’m not going to be covering ActionScript syntax in this tutorial. Keep an eye out for a separate tutorial on the subject, or take a look at the ActionScript reference guide which ships with Flash 5.

您可以使用ActionScript做更多的事情,包括编写自己的脚本来更改Flash电影中对象的大小,形状和外观。 但是,在本教程中,我将不介绍ActionScript语法。 请密切注意有关该主题的单独教程,或查看Flash 5附带的ActionScript参考指南。

投射影像 (Projecting Your Image)

Once you’ve created a Flash movie, it’s common to immediately export it as an SWF file and embed it into a Web page. However, Flash also allows you to export your movie in various other formats. For example, if you take a look at the File -> Export Movie command, you’ll see that Flash allows you to export your movie as a Windows AVI file, an animated GIF, a sequence of standalone GIF, JPEGs or bitmaps, an Adobe Illustrator document, an AutoCAD document, and a Windows Metafile.

创建Flash电影后,通常立即将其导出为SWF文件并将其嵌入到网页中。 但是,Flash还允许您以其他各种格式导出电影。 例如,如果您查看File-> Export Movie命令,您会看到Flash允许您将电影导出为Windows AVI文件,动画GIF,一系列独立GIF,JPEG或位图, Adobe Illustrator文档,一个AutoCAD文档和Windows图元文件。

Similarly, if all you want is a single still from the movie, you can select the frame and use the File -> Export Image command to export the selected frame as a GIF, JPEG, PNG or BMP image.

同样,如果您想要的只是电影中的一个静止图像,则可以选择该帧,然后使用“文件”->“导出图像”命令将选定的帧导出为GIF,JPEG,PNG或BMP图像。

And finally, you can also export your Flash movie to a standalone executable, which can be played back on any PC. In order to do this, you need to use something called a Projector, which provides a "wrapper" capable of playing back a Flash movie.

最后,您还可以将Flash影片导出到一个独立的可执行文件,该文件可以在任何PC上播放。 为此,您需要使用一种称为“投影仪”的东西,它提供了一个能够播放Flash电影的“包装器”。

To create a Flash projector, first export the movie as an SWF file, and then open the exported file in the standalone player which ships with Flash 5. Use the File -> Create Projector command to create a single executable which contains a stripped-down Flash player and your movie clip. You can then distribute this Projector to friends, clients and old girlfriends.

要创建Flash投影仪,首先将影片导出为SWF文件,然后在Flash 5附带的独立播放器中打开导出的文件。使用File-> Create Projector命令创建一个包含精简版的可执行文件。 Flash Player和影片剪辑。 然后,您可以将此投影机分发给朋友,客户和老女朋友。

And that’s about it for this week. Next week, I’ll be wrapping this tutorial up with a explanation of how you can add sound to your Flash movie, and use GIF, JPEG and other pixel-based images in your Flash movies. See you then!

这就是本周。 下周 ,我将对本教程进行总结,并说明如何在Flash电影中添加声音,以及如何在Flash电影中使用GIF,JPEG和其他基于像素的图像。 回头见!

Note: All examples in this article have been tested on Macromedia Flash 5.0. Examples are illustrative only, and are not meant for a production environment. YMMV!Copyright Melonfire, 2000. All rights reserved.

注意:本文中的所有示例均已在Macromedia Flash 5.0上进行了测试。 示例仅是说明性的,并不意味着用于生产环境。 YMMV! 版权所有Melonfire ,2000。保留所有权利。

翻译自: https://www.sitepoint.com/spiralling-control/

螺旋测微器 flash

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值