Long sequences of animation in Flash naturally require the preloading described in the previous section to guarantee smooth playback. But traditional information-based Web sites done in Flash require a different kind of download management. Suppose you’re building a Web site with three sections: products, staff, and company history. Each section is roughly 100KB in size. In a normal Flash movie, you’d place those sections in a sequential order on the main movie timeline. The last section you place on the timeline would, of course, be the last section to download. Might sound fine so far, but here’s the problem: What if the section that appears last on the timeline happens to be the first and only section the user wants to see? They’d have to wait for the other two sections to download before they could view the one they want but they don’t even want to see the other two sections, so really they’re waiting for nothing. The solution to this problem is the loadMovie action.
loadMovie provides a means of inserting one or more external .SWF files into a Flash movie (whether that movie resides in a browser or on its own in the standalone player). loadMovie can be used to replace the current movie with a different movie or to display multiple movies simultaneously. It can also be used, as in our company Web site example, to enable a parent movie to retrieve and display content kept in independent .SWF files on a need-to-retrieve basis (similar to the way a frame in an HTML frameset can call external pages into different frames).
Basic overview of Flash site architecture
There are two primary ways to produce and distribute straight Flash content on the Web: (a) create several small .SWF files, each one living within a standard HTML page on a Web site; or (b) create one HTML page that hosts one main .SWF file that loads additional content through the Flash Player plug-in. Figure below illustrates these alternatives.
The diagram on the left illustrates a Web site that uses multiple HTML pages, each with an individual .SWF file. The diagram on the right shows a Web site that uses one HTML page (or frameset) that has one primary .SWF file, which loads other .SWF files as needed.
If you decide to break up your Flash movies across several HTML pages, your Web visitors will experience:
Where are the multiple movies stored?
You may already be wondering how these newly loaded movies are managed relative to the original movie. Flash uses the metaphor of levels to describe where the movies are kept. Levels are something like drawers in a cabinet; they are stacked on top of each other, and can contain things; you can place things in any drawer you like, but once a drawer is full you have to take its contents out before you can put anything else in. Initially, the bottom level, referred to as _level0 (“Level 0”), contains the original movie. All movies subsequently loaded into the Flash Player must be placed explicitly into a target Level. If a movie is loaded into Level 1 or higher, it appears visually on top of the original movie in the Player. If a movie is loaded into Level 0, it replaces the original movie, removing all movies stored on Levels above it in the process. When a loaded movie replaces the original movie, it does not change the frame rate, movie dimensions, or movie background color of the original Flash stage. Those properties are permanently determined by the original movie and cannot be changed.
Loading an external .SWF file into a movie
A new movie is imported onto the main movie Stage when a loadMovie action is executed. Here’s how to make a button click load an external movie named movie2.swf:
With the Actions Panel in Normal Mode, you can clearly see the options and settings of the loadMovie action.
How Flash handles loaded movies of differing sizes
A movie loaded onto Level 1 or above that is smaller than the Level 0 movie is positioned in the top-left corner of the Stage. In this situation, elements on the Level 1 movie’s Stage are displayed even when they go beyond the bottom and right dimensions of the Level 1 movie. To prevent objects from being displayed off Stage you would have to create a curtain layer above all the other layers in the Level 1 movie that covers up the work area (the space outside the movie’s Stage). Movies loaded onto Level 0 that are smaller than the original Level 0 movie are automatically centered and scaled up to fit the size of the original movie (the manner in which they are scaled depends on the Scale setting in the Publish settings). Movies loaded onto Level 0 that are larger than the original Level 0 movie are cropped at the right and bottom boundaries defined by the original movie dimensions.
Placing, scaling, and rotating externally loaded .SWF files
Especially when your movies are different sizes, it’s not very convenient to have newly loaded movies dropped ingloriously in the top-left corner of the Stage. To give you more flexibility with the placement, rotation, and scale of your loaded movies, Flash provides the capability to load a movie into a Movie Clip instance.
So far, this may not make a whole lot of sense. Loading a movie into a Movie Clip instance seems like a strange feature at first, until you find out what it can do then it seems indispensable. The easiest way to understand what happens when you load a movie into a Movie Clip is to think of the loadMovie action as a Convert Loaded Movie-to-Movie Clip action. When a movie is loaded into a Movie Clip instance, many attributes of the original Movie Clip instance are applied to the newly loaded movie:
We like to refer to Movie Clips that are used to load other movies as Movie Clip holders. Usually, you will load movies into empty Movie Clips that don’t have any artwork or actions. However, because you’ll need a physical reference to the actual area your loaded movie will occupy on the Stage, it’s useful to create temporary guides or artwork that indicate this area. The following steps show you how to create a Movie Clip holder, and how to load an external .SWF file into it.
If you need to add functionality to the loaded movie, then use ActionScript to control the new loaded movie instance. The next section shows you how to communicate with loaded movies.
Communicating between multiple movies on different levels
After a movie or two are loaded onto different levels, you may want each timeline to control the other, just as Movie Clips can control each other. To communicate between different Levels, you simply need to address actions to the proper Level.
The method for addressing a Level that controls a timeline on a different Level is identical to the method for addressing a Movie Clip target that controls the timeline of another Movie Clip instance, except for one small change. You have to indicate the name of the Level you want target rather than the name of the Movie Clip. Level names are constructed like this: First, there’s an underscore (_), then there’s the word level, and then there’s the number of the Level that you want your Action to occur on.
This tells the movie loaded onto Level 1 to go to frame 50:_level1.gotoAndStop(50);
This tells the main movie timeline to go to frame 50:_level0.gotoAndStop(50);
You can also target Movie Clips that reside on the timelines of movies on other levels. Here’s an example:_level3.products.play();
This sends a play() action to the Movie Clip named products on the timeline of the movie loaded onto Level 3.
Even though a movie loaded into an occupied Level (one that already contains a loaded movie) will automatically be removed before the new movie is displayed, the transition can be choppy. To ensure a smooth transition between movies, or to lighten the memory required by the Flash player, you can explicitly unload movies in any Level or Movie Clip target by using the unloadMovie action. The only option for unloadMovie is the path to the desired location (for example, _level1, _root.instanceName).
loadMovie as a method or action for Movie Clip targets
Both loadMovie and unloadMovie can be used as either an ActionScript method or action for Movie Clip targets. What does this mean? You can apply actions in Flash 5 in two ways: as methods of a Movie Clip Object (or some other ActionScript Object), or as a stand-alone action.
As an action, loadMovie and unloadMovie start the ActionScript line of code. When you use actions in this manner, the target of the action is specified as an argument (option) within the action. In the following example, the file external_1.swf is loaded into Level 1:loadMovie (“external_1.swf”, “movieHolder”);
As a method, actions are written as an extension of the object using the action. Therefore, the target is already specified before the action is typed. The same example shown previously could be rewritten as a method of the movieHolder Movie Clip Object:movieHolder.loadMovie(“external_1.swf”); or _root.movieHolder.loadMovie(“external_1.swf”);
Because we have specifically referenced the movieHolder instance as an object, the loadMovie action (now a method) knows where to direct the loading of external_1.swf.
Flash Related Interview Questions
|Adv Java Interview Questions||J2EE Interview Questions|
|Adobe Flex 3 Interview Questions||Dreamweaver Interview Questions|
|3D Animation Interview Questions||Adobe Flash CS6 Interview Questions|
|Dreamweaver CS3 Interview Questions||Adobe Flex Interview Questions|
|Adobe Flex Actionscript Interview Questions||Gif Animation Interview Questions|
|Adobe Fireworks Interview Questions|
Understanding The Flash Framework
Exploring The Interface: Panels, Settings, And More
Using Tools For Navigation And Viewing
Working With Selections And The Pen Tool
Working With The Drawing And Painting Tools
Working With Text
Exploring The Timeline
Checking Out The Library: Symbols And Instances
Drawing In Flash
Animating In Flash
Using Bitmaps And Other Media With Flash
Designing Interfaces And Interface Elements
Understanding Sound For Flash
Importing And Editing Sounds In Flash
Optimizing Flash Sound For Export
Understanding Actions And Event Handlers
Navigating Flash Timelines
Controlling Movie Clips
Sharing And Loading Assets
Planning Code Structures
Creating Subroutines And Manipulating Data
Understanding Movie Clips As Complex Objects
Sending Data In And Out Of Flash
Understanding Html And Text Field Functions In Flash
What Is Generator?
Revving Up Generator
Working With Third-party, Server-side Applications
Working With Raster Graphics
Working With Vector Graphics
Working With Audio Applications
Working With 3d Graphics
Working With Quicktime
Working With Realplayer
Creating Full-motion Video With Flash
Creating Cartoon Animation With Flash
Planning Flash Production With Flowcharting Software
Working With Authoring Applications
Publishing Flash Movies
Integrating Flash Content With Html
Using Players, Projectors, And Screensaver Utilities
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.