快闪视频快影

tech2024-05-22  71

快闪视频快影

So you want your Flash Website to load faster? Of course you do!

因此,您希望Flash网站加载速度更快吗? 当然可以!

This article will share a raft of useful techniques that can be implemented to decrease the file size of your Flash movies, and thus have them load faster.

本文将分享大量有用的技术,这些技术可用来减少Flash电影的文件大小,从而使它们加载更快。

This is not intended to be a ‘how-to’ article, but rather, to provide information about what you can do to decrease the size of your Flash movies. Once you’re aware of the available techniques, you can then pursue their implementation yourself.

本文并非旨在作为“入门指南”文章,而是提供有关如何减少Flash电影尺寸的信息。 一旦知道了可用的技术,就可以自己进行实现。

1. Use symbols, animated or otherwise, for every element that appears more than once in your movie.

1.对于动画中出现多次的每个元素,请使用动画或其他符号。

A symbol is a reusable element found in the library of your movie. When you place a symbol on the stage or inside another symbol, you’re working with an instance of that symbol. Unlike using individual graphics, you can use many instances of a given symbol, with almost no addition to the file size of your movie.

符号是在电影库中找到的可重用元素。 当您将符号放置在舞台上或另一个符号内部时,您正在使用该符号的实例。 与使用单个图形不同,可以使用给定符号的许多实例,而几乎不增加影片的文件大小。

Converting all artwork to symbols will ultimately save you bandwidth. Because Flash refers to a singular symbol to generate multiple instances, the user only has to download the graphic once, even if you use it a hundred times in your site.

将所有图稿转换为符号最终将节省您的带宽。 由于Flash引用单个符号来生成多个实例,因此即使您在站点中使用了一百次,用户也只需下载一次即可。

In addition, symbols can save you time and trouble when it comes to making changes to your movie. This is because the changes you make to a symbol are reflected in each instance of that symbol throughout your movie.

此外,在更改电影时,符号可以节省您的时间和麻烦。 这是因为您对符号所做的更改会反映在整个电影中该符号的每个实例中。

2. Use very few — if any — raster graphics.

2.使用很少的栅格图形(如果有)。

Although Flash has no problem allowing you to add raster graphics to your movies, it really isn’t the preferred graphic choice. Flash would be much happier if you used vector graphics.

尽管Flash没问题,可以将光栅图形添加到影片中,但它实际上并不是首选图形选择。 如果使用矢量图形,Flash会更加快乐。

A very brief definition of vector vs. raster graphics for those who are not familiar: vector graphics are simply mathematical definitions of shapes and lines that are used to construct your graphic. Because your graphics are created from numbers and equations, you maintain a completely scalable image. Raster file formats like BMP, JPEG, and GIF, on the other hand, are defined not by mathematics, but by a series of pixels lined up in rows with color values applied to each individual pixel (or dot).

对于不熟悉的人来说,矢量与栅格图形的定义非常简短:矢量图形只是用于构造图形的形状和线的数学定义。 由于您的图形是根据数字和方程式创建的,因此您可以维护一个完全可缩放的图像。 另一方面,光栅文件格式(例如BMP,JPEG和GIF)不是由数学定义的,而是由一系列按行排列的像素定义的,这些像素的颜色值应用于每个像素(或点)。

Because vector graphics are essentially just mathematical equations that, when formulated, produce a graphic they take up very little storage space, and add little to the overall file size of your movie.

因为矢量图形本质上只是数学方程式,公式化后生成的图形它们占用的存储空间很小,并且几乎不增加影片的整体文件大小。

While this may be old news to some, hopefully this information will help the new Flash user avoid making that grave mistake of taking their honed Photoshop skills and trying to drop all those raster graphics into Flash. In short, a nice raster graphic used occasionally is probably ok, just don’t try and build your entire Flash site from raster graphics.

尽管这对于某些人来说可能是个老新闻,但希望这些信息将帮助新的Flash用户避免犯下严重的错误,因为他们需要磨练自己的Photoshop技能,并尝试将所有这些光栅图形放入Flash中。 简而言之,偶尔使用一个不错的栅格图形可能是可以的,只是不要尝试从栅格图形构建整个Flash网站。

3. Change the quality of jpg images.

3.更改jpg图像的质量。

So you totally disregarded the statement above, and went ahead and added that .jpg to your Flash movie? Well, let’s at least trim it down.

因此,您完全无视上述声明,而是继续将.jpg添加到Flash电影中? 好吧,至少让它修剪一下。

Open up your library by hitting CTRL + L, and locate your imported .jpg. Right-click on it and go to properties. Uncheck ‘use imported JPEG data’ and you’ll find that you can adjust the image quality. You will have to play with the quality setting until you find a happy medium of appearance vs. file size. I always adjust this setting — it alone can make a huge difference to your file size.

通过按CTRL + L打开您的库,然后找到导入的.jpg。 右键单击它,然后转到属性。 取消选中“使用导入的JPEG数据”,您会发现可以调整图像质量。 您将不得不使用质量设置,直到找到满意的外观与文件大小之间的平衡。 我会一直调整此设置-仅此一项就可以对您的文件大小产生巨大的影响。

4. Load images dynamically.

4.动态加载图像。

A great new feature of MX is that it gives you the ability to load .jpg graphics dynamically. This is achieved in the same way you would load an external .swf — using the loadMovie() action. Add a MovieClip to the stage and give it and instance name of "imageholder". Then add the following actionscript to a keyframe:

MX的一项重大新功能是,它使您能够动态加载.jpg图形。 这可以通过与加载外部.swf相同的方式来实现-使用loadMovie()操作。 将MovieClip添加到舞台上,并为其指定名称和“ imageholder”的实例。 然后将以下动作脚本添加到关键帧:

loadMovie("name_of_jpg.jpg","imageholder");

Warning! Progressive JPEG images do not appear when loaded dynamically using the loadMovie action.

警告! 使用loadMovie操作动态加载时,渐进JPEG图像不会出现。

5. Other useful tips to optimize images.

5.优化图像的其他有用技巧。

Using the Modify — Smooth, Straighten and Optimize commands found on the menu bar to refine shapes and lines may also help to reduce the overall size of your swf. You can use these commands repeatedly on a shape until you are satisfied with the level of optimization, or the look of the graphic.

使用菜单栏上的“修改—平滑,拉直和优化”命令来细化形状和线条也可能有助于减小swf的整体大小。 您可以在形状上重复使用这些命令,直到对优化级别或图形外观感到满意为止。

Also in the Modify menu is the Trace Bitmap command. This command will convert a bitmap to a vector image, and often does a good job — though, usually, the quality of conversion depends on the complexity of the image. Typically .gifs convert better than .jpgs. You may want to play with this command and see how it affects different graphics.

在“修改”菜单中还有“跟踪位图”命令。 此命令会将位图转换为矢量图像,并且通常做得很好-尽管通常转换的质量取决于图像的复杂性。 通常,.gif的转换效果好于.jpgs。 您可能要使用此命令,看看它如何影响不同的图形。

6. Limit the number of special line types such as dashed, dotted, ragged, and so on.

6.限制特殊线型的数量,例如虚线,点线,参差不齐等等。

Solid lines are smaller. Lines created with the pencil tool require less memory than brush strokes.

实线较小。 用铅笔工具创建的线比画笔描边需要更少的内存。

7. Use layers to separate elements that change over the course of the animation from those that don’t.

7.使用图层将在动画过程中更改的元素与未更改的元素分开。

A nice feature of Flash is that, no matter how many layers you use, this won’t have any impact on the size of your Flash movie. Therefore, it’s good practice to place non-animated objects on their own layer, separating them from animated objects.

Flash的一个不错的功能是,无论您使用多少层,这都不会对Flash电影的大小产生任何影响。 因此,优良作法是将非动画对象放置在它们自己的图层上,将它们与动画对象分开。

8. Limit the number of fonts and font styles.

8.限制字体和字体样式的数量。

The more fonts you use, the more fonts Flash has to save in your .swf — and the more fonts saved in your .swf, the bigger the file size will be. Pretty simple right?

您使用的字体越多,Flash必须在.swf中保存的字体就越多-.swf中保存的字体越多,文件的大小将越大。 很简单吧?

Here’s a useful tip, though. Let’s say you just got this really nifty font, and you want to use it on a few buttons. In order for that font to be seen by people that don’t have the font installed, you’ll have to embed it. This is pretty easy — just go to the character options for that font, and there you’ll be the option to embed the entire font, uppercase characters, lowercase characters, numerals and punctuation.

不过,这里有个有用的提示。 假设您刚刚得到了这种非常漂亮的字体,并且想要在几个按钮上使用它。 为了使未安装该字体的人看到该字体,您必须将其嵌入。 这非常简单-只需转到该字体的字符选项,即可选择嵌入整个字体,大写字母,小写字母,数字和标点符号。

If all you want is the button to say "home" or something this simple, then there’s no use in embedding the entire alphabet, just go to the input box that says, "and these characters" and type in "home" This way you’re only storing 4 characters in your .swf file.

如果您只需要按钮说“ home”或类似的简单内容,那么嵌入整个字母就没有用,只需转到输入框,输入“和这些字符”,然后键入“ home”即可。在.swf文件中仅存储4个字符。

9. Import text into your Flash movie.

9.将文本导入Flash电影。

You may want to decide to keep your text separate from your Flash movie. This allows you to easily make modifications without having to open up Flash — and can make it easy for someone who doesn’t have Flash or Flash knowledge to make changes. They can simply edit a .txt file. In addition, your .swf file will be smaller because Flash will no longer be responsible for storing your text.

您可能需要决定使文本与Flash电影分开。 这样一来,您无需打开Flash即可轻松进行修改-并使不具备Flash或Flash知识的人可以轻松进行更改。 他们可以简单地编辑.txt文件。 此外,由于Flash将不再负责存储文本,因此.swf文件将更小。

How can you create the external text file and import it into Flash?

如何创建外部文本文件并将其导入Flash?

Open up notepad and follow this pattern:

打开记事本,并遵循以下模式:

variable_name=content&variable_name2=content&

The content is attached to each variable, and will soon be loaded into Flash.

内容附加到每个变量,并将很快加载到Flash中。

The "&" is the delimiter. Save your .txt file with the name "content.txt".

“ & ”是分隔符。 用名称“ content.txt”保存您的.txt文件。

Next, add this script to a keyframe in Flash:

接下来,将此脚本添加到Flash中的关键帧:

loadVariablesNum("content.txt", "0")

This loads the content.txt file into level0 of your movie. You could also use:

这会将content.txt文件加载到电影的level0中。 您还可以使用:

loadVariables("content.txt","MovieClip")

which would load the content into the MovieClip with the given instance name.

它将使用给定的实例名称将内容加载到MovieClip中。

Lastly, add your dynamic text fields to your scene, and assign them the variable names that you used in content.txt.

最后,将动态文本字段添加到场景中,并为它们分配您在content.txt中使用的变量名称。

Because your text no longer resides in your Flash movie, you decrease the file size, and your main Flash movie will now load more quickly: instead of having to preload a 150K swf, you may only have to preload a 100K swf.

由于您的文本不再驻留在Flash电影中,因此可以减小文件大小,并且主Flash电影现在可以更快地加载:不必预先加载150K瑞士法郎,而只需预加载100K瑞士法郎。

10. Optimizing Sound in Flash.

10.优化Flash中的声音。

Use MP3 compression, the smallest sound form when possible.

使用MP3压缩,这是最小的声音形式。

Once you’ve imported in your MP3 file, open your library with CTRL+L and right-click to bring up properties. You may want to uncheck "use imported MP3 quality" — with this option unchecked, you can change both the Bit Rate and Quality. You may find that a lower Bit Rate and Quality reduces file size while producing a sound that’s still fine for use.

导入MP3文件后,请使用CTRL + L打开库,然后单击鼠标右键以显示属性。 您可能要取消选中“使用导入的MP3质量”,如果不选中此选项,则可以更改“比特率”和“质量”。 您可能会发现较低的“比特率和质量”会减小文件的大小,同时产生仍适合使用的声音。

11. Use the Color Effects menu in the Instance properties dialog box to create many different colored Instances of a single symbol.

11.使用“实例属性”对话框中的“颜色效果”菜单创建单个符号的许多不同颜色的实例。

Every instance of a symbol has specific properties that can be modified. These properties apply only to the specific instance — not the original symbol.

符号的每个实例都有可以修改的特定属性。 这些属性仅适用于特定实例,而不适用于原始符号。

You can, for instance, use the tint option in the color properties of the selected object to change its color, instead of creating another symbol. Other properties include brightness, and alpha. By using a single instance of an object multiple times, you again re the overall file size.

例如,您可以在所选对象的颜色属性中使用“色调”选项来更改其颜色,而不用创建另一个符号。 其他属性包括亮度和alpha。 通过多次使用一个对象的单个实例,您再次重新确定了整个文件的大小。

12. Modularize your movies.

12.模块化电影。

Modularization is the process of breaking up a single large Flash movie into multiple smaller .swf files in an effort to decrease the load time, and make your movie easier to manage. You can learn more about modularization by reading SitePoint’s article titled Modularize Flash.

模块化是将单个大型Flash电影分成多个较小的.swf文件的过程,以减少加载时间并使电影更易于管理。 您可以阅读SitePoint标题为Modularize Flash的文章,以了解有关模块化的更多信息。

Remember the words of Stan Lee: "With great power comes great responsibility." The responsible Flash user will take great steps to ensure that their Flash site loads as quickly as possible, even if that means sacrificing a little eye-candy.

记住斯坦·李(Stan Lee)的话:“能力越大,责任就越大”。 负责任的Flash用户将采取重要措施,以确保尽快加载其Flash网站,即使这意味着要牺牲一点眼力。

翻译自: https://www.sitepoint.com/steps-faster-flash/

快闪视频快影

相关资源:jdk-8u281-windows-x64.exe
最新回复(0)