flash+外部flash_协调您的Flash网站

flash+外部flash

Flash Websites load more quickly when they’re broken into smaller movies (i.e. "modularized"). While the idea seems obvious enough, it’s still worth mentioning! But what’s less obvious is that, once you’ve started along that road, issues of "coordination" take precedent; and, whether the developer is a seasoned professional or a relative newbie (like me), they’d do well to recognize these issues up front.

Flash网站被分解成较小的电影(即“模块化”)时,加载速度更快。 尽管这个主意似乎很明显,但仍然值得一提! 但是不太明显的是,一旦您沿着这条道路开始,“协调”问题便成为了先例。 而且,无论开发人员是经验丰富的专业人员还是相对较新的人员(如我),他们都很好地预先识别了这些问题。

This article hopes to accomplish three things: first, to underscore the value of modularization. Second, to clarify some of its important, though previously underreported, repercussions. Finally, to offer remedy to these repercussions by explaining how the task of "coordination" can be accomplished systematically.

本文希望完成三件事:首先,强调模块化的价值。 第二,澄清其一些重要的影响,尽管先前并未报道。 最后,通过解释如何系统地完成“协调”任务来对这些影响提供补救。

References are made to a few Websites I’ve designed for others and to a bulleted check list of questions that Flash developers (particularly those hoping to decrease load times) should consider before they break up their Websites into little bitty pieces.

引用了我为别人设计的一些网站,以及项目符号清单,这些问题是Flash开发人员(尤其是那些希望减少加载时间的开发人员)在将网站分解成小块之前应该考虑的问题。

案例分析 (Case Study)

I had previously broken up a few sections of one of my favorite Websites into smaller swfs and loaded them into different levels of the main movie. In fact, this seemed pretty logical for things like MP3 or music selectors, clocks and such. And I’d grown accustomed to the inordinate size that my main movie had grown to. So, when I came across a recent SitePoint article on modularizing the main movie (otherwise known as putting it on a diet), I studied it with great interest.

以前,我曾将我最喜欢的网站之一的几个部分分解成较小的swf,然后将它们加载到主电影的不同级别中。 实际上,对于MP3或音乐选择器,时钟等而言,这似乎很合乎逻辑。 我已经习惯了我的主要电影所达到的超大尺寸。 所以,当我遇到一个最近的 我在SitePoint上发表了有关将主要电影模块化的文章 (也称为节食),我对此非常感兴趣。

Indeed, it worked! In fact, it worked so seamlessly, I went through my entire Website and modularized 6-8 additional sections! Great, I thought! Now, the main movie was much smaller in size — at least, it was after I deleted all remaining unused items from its library. With that, I noticed the site took less time to load, and that I could more easily isolate any remaining areas of concern. Unexpectedly, by breaking up the main movie into smaller pieces, it became easier to identify those sections of the Website that could be re-used!

确实,它起作用了! 实际上,它是如此无缝地工作,我浏览了整个网站并模块化了6-8个附加部分! 太好了,我想! 现在,主要电影的尺寸要小得多-至少是在我从其资料库中删除所有剩余的未使用项目之后。 这样一来,我注意到该站点花费了更少的时间来加载,并且我可以更轻松地分离出任何其他值得关注的领域。 出乎意料的是,通过将主要电影分割成较小的片段,可以更轻松地识别网站中可以重复使用的部分!

For instance, when the Website initially loads, a set of doors open to reveal an image centered on the screen, which sits right above four main navigational buttons. Before modularization, this "door-opening routine" would occur only once — the first time the site was loaded. This was the first thing I modularized, and, after I did, it became obvious to me that I could re-use or "coordinate" the door-opening routine to execute every time my users clicked on one of the main navigation buttons! All I had to do was call the door-opening routine from inside each one of the buttons. Simple!

例如,当网站最初加载时,一组门打开以显示位于屏幕中央的图像,该图像位于四个主要导航按钮的正上方。 在模块化之前,此“开门例程”仅会发生一次-站点首次加载。 这是我模块化的第一件事,当我这样做之后,对我来说很明显,我可以在用户每次点击一个主导航按钮时重新使用或“协调”开门程序来执行! 我要做的就是从每个按钮内部调用开门例程。 简单!

What I had not yet realized was that the task of coordination would eventually become anything but simple. Try coordinating anywhere from 25-50 different sub-movies so that they interact as users expect, both with the main movie and with one another! Let me tell you, it can get a little unwieldy!

我还没有意识到,协调的任务最终将变得很简单。 尝试协调25-50个不同子电影中的任何地方,以便它们按照用户的期望与主要电影以及彼此互动。 让我告诉你,它可能有点笨拙!

Just how Unwieldy Can it Be?

到底有多笨拙?

Well, let me just say that, despite its obvious benefits, modularization raises important questions of coordination (which, in turn, raise questions of time and effort — e.g. how much time do you have and how much effort are you willing to expend?). However, the first question asks: "how much modularization is enough, and how much is too much?" Is there a point of optimality? Consider this.

好吧,我只想说,尽管模块化有明显的好处,但它提出了重要的协调问题(反过来又提出了时间和精力的问题,例如,您有多少时间,您愿意花费多少精力?) 。 但是,第一个问题问:“ 多少模块化就足够了,多少模块化就太多了? ”是否有最优点? 考虑一下。

You’ve got four navigational buttons, all programmed into your main .swf. Each is associated with a different sub-menu item or selection, and each has a different background image (see Image 1). Modularize these four buttons into four smaller, faster-loading .swfs and you’ve got problems. Check this:

您有四个导航按钮,所有这些按钮都已编程到主.swf中。 每个都有一个不同的子菜单项或选择,并且每个都有不同的背景图像(请参见图1)。 将这四个按钮模块化为四个较小的,加载速度更快的.swfs,您就会遇到问题。 检查一下:

  • the sub-menu selections and/or background image for the first button need to be turned off when any other main navigational buttons is selected;

    当选择任何其他主导航按钮时,需要关闭第一个按钮的子菜单选择和/或背景图像;
  • the same for the second button the user selects — its related information needs to be turned on; and, while all of this is happening,

    用户选择的第二个按钮相同–需要打开其相关信息; 并且,尽管所有这些都在发生,
  • the first button is not supposed to disappear or become inoperative.

    第一个按钮不应消失或不起作用。
  • the background music should not be affected by the button selection, but the images of musicians that appear when the music begins should disappear when certain buttons (but not all) are selected.

    背景音乐不应受到按钮选择的影响,但是当选择某些按钮(但不是全部)时,音乐开始播放时出现的音乐家的图像应消失。

For a seasoned Flash designer or developer, none of this is particularly disturbing; everything is as it should be. But for the rest of us, aspiring to become a seasoned Flash "something or other," this all comes from out of the blue.

对于经验丰富的Flash设计师或开发人员来说,这没有什么特别令人不安的。 一切都应该如此。 但是对于我们其余的人来说,他们渴望成为经验丰富的Flash“某物”,这一切都是从天而降的。

It means we need to program each of the navigational buttons to issue a series of commands that will make certain characteristics of the remaining buttons roll-up, slide out, or otherwise disappear — to allow the other buttons to display their information without interfering with one another. In plain English, the buttons need to evaluate and interact with their "environment" before they execute.

这意味着我们需要对每个导航按钮进行编程,以发出一系列命令,这些命令将使其余按钮的某些特性上滚,滑出或消失(使其他按钮在不干扰一个的情况下即可显示其信息)另一个。 用简单的英语来说,按钮在执行之前需要评估并与其“环境”进行交互。

This, then, raises a second question: "how do I get the smaller .swfs to exchange commands between one another, as well as to and from the main movie?"

然后,这引起了第二个问题:“ 我如何获得较小的.swfs以便彼此之间以及与主电影之间来回交换命令?

协调任务 (The Coordinative Task)

Say, for instance, the Website loads and the user clicks one of the main navigation buttons. As they expect, the button displays its submenus:

例如,假设网站已加载,用户单击了主导航按钮之一。 正如他们期望的那样,该按钮显示其子菜单:

949_image1

And, as the user rolls over each one of the submenu items, the text for that item highlights and an image is displayed in the main "display area" — an image that visually conveys the main idea of the current (rolled-over) item.

并且,当用户将鼠标移到每个子菜单项上时,该项目的文本将突出显示,并且图像显示在主“显示区域”中-该图像直观地传达了当前(滚动)项的主要思想。

Then (since we’ve all got these really intelligent users) — with the first menu still in its "down" position, but without selecting anything from its submenu — the user decides to click a second navigation button, one which comes with its own menus and (you guessed it) an image that would effectively cover the same display area:

然后(因为我们所有人都有这些真正聪明的用户)–第一个菜单仍处于“向下”位置, 但未从其子菜单中选择任何内容 –用户决定单击第二个导航按钮,该按钮自带菜单和(您猜对了)可以有效覆盖同一显示区域的图像:

949_image2

Well, if the two buttons are modularized (which is to say they exist as separate .swfs) — and are not coordinated — both sub-menus and/or background images will be displayed on top of one another, rendering both buttons ineffective:

好吧,如果这两个按钮是模块化的(也就是说,它们作为独立的.swfs存在)并且不协调,则子菜单和/或背景图像会一并显示,从而使两个按钮均无效:

949_image3

Enough!

足够!

For some projects, this may produce the desired effect(s). But, if that’s not quite what you had in mind, you may want to read further.

对于某些项目,这可能会产生所需的效果。 但是,如果这与您的想法不符,则可能需要进一步阅读。

Though I’ve learned a lot about Flash by modularizing my Website, I’ve learned twice as much by taking the time to coordinate the buttons and other routines I had so happily dismantled. After all, what good is a movie that loads quickly and is easy to repair if it doesn’t operate as expected? Not much.

尽管通过模块化网站使我对Flash有了很多了解,但花些时间协调按钮和其他我很高兴拆除的例程,使我学到了两倍的知识。 毕竟,如果电影无法按预期运行,那么可以快速加载并且易于修复的电影有什么好处? 不多。

Anyway, to give you an idea of the kind of interactivity involved in coordinating your buttons with one another, here’s a list of the commands that are now issued from my "Home" button:

无论如何,要让您了解按钮之间相互协调所涉及的交互性,以下是现在从我的“主页”按钮发出的命令列表:

on(release) {
\ 1. these commands turn off the music, if it's already been turned on.  
_root.music_holder. unloadMovie("miles_and_john.swf");  
_root.music_holder. unloadMovie("love_supreme.swf");  
_root.music_holder. unloadMovie("cannonball_adderley.swf");  
_root.music_holder. unloadMovie("finding_forrester.swf");  
_root.music_holder. unloadMovie("tribute_to_miles.swf");  
_root.music_holder.music.gotoAndStop("back");    
\ 2. these commands make the images, which are designed to automatically    
\ pop-up for certain songs (above), invisible.  
_root.music_holder.music.miles._visible = false;  
_root.music_holder.music.herbie._visible = false;  
_root.music_holder.music.john._visible = false;  
_root.music_holder.music.jazzfestival._visible = false;  
_root.music_holder.music.sax._visible = false;  
\ 3. if any of the navigational buttons are currently in their "display"    
\ positions, these commands will bring them back to their    
\ original positions.    
_root.movieholder.button_rack.gotoAndStop("start");  
_root.movieholder.button_rack.teaching.gotoAndStop("start");  
_root.movieholder.button_rack.research.gotoAndStop("start");  
_root.movieholder.button_rack.info.gotoAndStop("start");  
_root.movieholder.button_rack.contact.textAnimation.gotoAndStop("start");  
\ 4. these commands turn off the background images that are associated    
\ with each one of the (above) navigational buttons.    
_root.movieholder.mc_button_1_holder.unloadMovie();  
_root.movieholder.mc_button_2_holder.unloadMovie();  
_root.movieholder.mc_button_3_holder.unloadMovie();  
_root.movieholder.mc_button_4_holder.unloadMovie();  
\ 5. this command turns on the background image that comes up    
\ when the website initially loads.  
_root.movieholder.mc_picture_base._visible = true;  
\ 6. in case the user had previously clicked "credits," this command    
\ makes the credits display go to its initial (off) position.  
_root.clock_holder.credits.gotoAndStop("off");  
\ 7. this command unloads any previously loaded movie, in case it    
\ had been displayed.    
_root.wipe1_holder.unloadMovie();    
\ 8. this command unloads yet another sub-movie, in case it    
\ had been displayed.  
_root.movieholder._level1.unloadMovie();  
\ 9. finally, this command loads a very small movie that appears    
\  when the website initially loaded, telling the user that    
\ they are now "back home."  
loadMovie("wipe1.swf", "wipe1_holder");  
}

As you can see, there’s a lot going on — at least potentially — which is why you have to issue so many commands. Keep in mind that a similar slate of commands will need to be issued to other buttons so that they are similarly informed on how they should operate in a given situation. Again, the buttons need to interact with their "environment" — however that environment might be configured when the user decides to do whatever it is they do.

如您所见,发生了很多事情-至少有可能-这就是为什么您必须发出这么多命令的原因。 请记住,将需要向其他按钮发出相似的命令,以便类似地告知它们在给定情况下应如何操作。 同样,按钮需要与其“环境”进行交互-但是,当用户决定执行其所要执行的操作时,可以配置该环境。

As you might imagine, several of the above commands will probably go nowhere, but that’s alright. Effective coordination is all about thinking through, and addressing up-front, the various possible interactions. You constantly need to ask yourself "what if?"

就像您想象的那样,上面的几个命令可能什么也没用,但这没关系。 有效的协调就是考虑并预先解决各种可能的相互作用。 您经常需要问自己“是否?”。

While several commands will probably go "unused," it’s important that they’re there so the user can do what they want to do, when they want to do it, "without the water going on every time they turn on the gas."

尽管有几个命令可能会“不使用”,但重要的是它们在那里,以便用户可以按自己的意愿做他们想做的事,“每次打开煤气时都不会积水”。

模块化之前 (Before You Modularize)

That said, here are a few instructions that may be of benefit to other newbies. These are things that should be determined before you modularize your Website.

也就是说,这里有一些说明可能会对其他新手有所帮助。 这些是在模块化网站之前应该确定的事情。

  1. Make a list of all the intended interactions that could take place between the buttons/routines that you plan to modularize and their "environment." For navigation buttons, you might want to consider whether their (intended) operation should be constrained by, or subject to the operation of other buttons.

    列出您计划进行模块化的按钮/例程及其“环境”之间可能发生的所有预期的交互的列表 。 对于导航按钮,您可能需要考虑其(预期)操作是否应受其他按钮的约束或受其约束。

  2. Determine which commands will be necessary for the modularized buttons/ routines to interact with their "environments" once they are modularized. While absolute references to the _root. may help considerably (see above), other techniques (e.g., loading smaller .swfs into different levels of a given movie) may work even better in certain instances.

    确定将模块化按钮/例程与它们的“环境”进行交互后, 将需要哪些命令 。 而绝对引用_root。 可能有很大帮助(请参阅上文),其他技术(例如,将较小的.swfs加载到给定电影的不同级别中)在某些情况下甚至可以更好地工作。

  3. Determine where these commands will need to be issued from. If you want to include a quiz on your Website, Macromedia provides a few quiz templates in Flash MX, under the File menu. If you want to modularize the completed quiz and have it load in your main movie, it may have problems reporting its results. Answer: load it as a stand-alone program and call it (from a button on the main movie) into its own browser window.

    确定需要从何处发出这些命令 。 如果要在您的网站上包括测验,Macromedia会在Flash MX的“文件”菜单下提供一些测验模板。 如果要模块化已完成的测验并将其加载到主影片中,则可能无法报告结果。 答:将其作为独立程序加载,并(通过主电影上的按钮)将其调用到其自己的浏览器窗口中。

  4. Determine when these commands will need to be issued. When coordinating actions, you’ll find several places to load commands so that the website will operate as you intend. Sometimes, you’ll want to issue commands from a button, sometimes from a movie, sometimes from a frame, sometimes from a browser window, sometimes from a JavaScript, etc, etc. Don’t be afraid to think outside the box!

    确定何时需要发出这些命令 。 协调动作时,您会找到几个加载命令的位置,以便网站可以按预期运行。 有时,您会希望通过按钮,有时是电影,有时是帧,有时是浏览器窗口,有时是JavaScript等发出命令。不要害怕在框外思考!

  5. Finally, determine (for yourself) how much time and effort you are able and willing to expend on a given project before you modularize it. As I hope to have shown here, each newly-created module brings with itself the additional requirement that it interact effectively with the rest of the Website. Alas, very little in life is automatic, and even less in Flash!

    最后,在对项目进行模块化之前,确定(自己)要花多少时间和精力才能花在给定的项目上。 正如我希望在这里所示,每个新创建的模块都带有附加要求,即它必须与网站的其余部分有效交互。 ,生活中很少有什么是自动的,而在Flash中则更少!

Bottom line: modularization is worthwhile, and should be done more often. But, since it’s only half the equation — you should know what it costs!

最重要的模块化是值得的,应该更经常地进行。 但是,由于它只是等式的一半,因此您应该知道它的成本!

翻译自: https://www.sitepoint.com/co-ordinate-flash-site/

flash+外部flash

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值