How to load external SWF files for Adobe Flash Player. From within a Flash SWF file, you can load other external SWF files as assets. A great advantage of AS3 is the possibility to use external ActionScript Files for your projects. So there is no need to use confusing timeline code anymore. This tutorial will teach you how to use an external actionscript files with Actionscript 2.0. External actionscript files are used to separate the code from the. You can use longer video clips without slowing down playback. External FLV or F4V files are played using cached memory, which means that large files are stored in. There are several reasons to load external SWF files: Because a project can be broken up into multiple movies, the individual SWF files are smaller in size. Smaller files load faster, and manage memory more efficiently. It lets you load only the content you need based on what the user is doing in your movie. Multiple SWF files can be played in succession without making the browser load another HTML page. The pages don't have the pause or refresh associated with reloading. If the external SWF file has been published with an older version of ActionScript, there are important limitations to consider. Unlike an ActionScript 3.0 SWF file. It gives you greater flexibility about the organization of your project assets. A complex user interface can be created that does not rely on a single SWF file. Many SWF files can be combined to create the interface. Combining SWF files simplifies editing, because an individual, smaller SWF file can be revised without affecting the other parts of the interface. Multiple authors can collaborate on the same project by working on separate FLA files. Placing content in a separate SWF file is similar to placing content in its own movie clip symbol. The difference is that the content exists outside the main SWF file. You can also load image files, such as JPG, PNG, GIF. To load an external SWF file from within another SWF file, use one of the following: The Action. Script 3. 0 Loader class. The Action. Script 2. Movie command. The Action. Script 2. 0 Movie. Clip. Loader class. The Loader class in Action. Script 3. 0 is a subclass of Display. Object that you use to load and display external content. To load the SWF file, you use the load method of the class. The load method has one required parameter, an URLRequest instance containing the URL address of the content to load. The following code example creates a Loader instance and loads an external SWF file named "my. External. Movie. swf."var my. Loader: Loader = new Loader(); // create a new instance of the Loader class. URLRequest = new URLRequest("External. SWF. swf"); // in this case both SWFs are in the same folder. Loader. load(url); // load the SWF file. Child(my. Loader); // add that instance to the display list, adding it to the Stage at 0,0. Loader. x = 1. 0; // move the loaded SWF 1. Loader. y = 1. 75; // move the loaded SWF 1. SWF file. var my. Loader: Loader = new Loader(). URLRequest = new URLRequest("External. SWF2. swf"). my. 2nd. Loader. load(url. Child(my. 2nd. Loader); // optionally, you could put the 2nd SWF beneath. Child. At(my. 2nd. Loading external swf file, Loading external Flash movie, Loader AS3 class, ActionScript 3 tutorials, load, URLRequest.Loader, 1). // displacing the 1st SWF from position 1 to 2 in the display list. SWF file. my. 2nd. Loader. scale. X = 2; // scale the SWF horizontally by 2. Loader. scale. Y = 2; // scale the SWF vertically by 2. The URL of the SWF file being loaded can be relative or absolute. See Relative Paths below for more information regarding how Flash Player handles URLs. For more information about the Loader class, see Loader in the Platform Action. Script Language Reference. References to root, when available, always reflect the top- most display object in the portion of the display list's tree structure that SWF file represents.
For images, root references the Bitmap object.)Note: In Action. Script 3. 0, there is no equivalent to the Action. Script 2. 0 _lockroot or _level property. See Basics of display programming in the Action. Script 3. 0 Developer's Guide. The load. Movie command loads an external SWF file or image into a Movie. Clip or another level of the parent movie in Action. Script 2. 0. The load. Movie command has two different forms: Movie. Clip. load. Movie method: The Movie. Clip method is used for loading external content into a specific movie clip instance. Global load. Movie function: The global load. Movie function can be used to load content into movies or levels. The global version also has two variations, load. Movie and load. Movie. Num. The first variation loads content into movies or levels and the second (load. Movie. Num) loads specifically into levels. When loading external content into movie clip instances, Adobe recommends that you use the Movie. Clip method version of load. Movie. This version is called directly from the movie clip that you want to load the content into and is passed the URL of the content. Movie. Clip. Instance. Movie("my. External. Movie. swf"); // here only the filename is given, indicating the SWF file. SWF. The URL of the content being loaded can be relative or absolute. See Relative Paths below for more information regarding how the Flash player handles URLs. When loaded, the content is displayed within the container movie clip. The location as well as other basic properties of the container movie clip are retained. However, any custom properties or functions defined within the container movie clip are no longer present. The new content replaces all previous content (including code and event handlers like on. Release). Therefore, any attempts at using a on. Load event handler for the movie clip can't work. In this case, use the Movie. Clip. Loader class instead (see below). For more information on Movie. Clip. load. Movie, see Movie. Clip. load. Movie in the Action. Script 2. 0 Language Reference. The load. Movie command also exists as a global function. This function has two required parameters, the URL of the external content and the target in which the content is loaded. The target parameter can be either a string or a reference. The following lines are equivalent to loading "my. External. Movie. swf" into the movie clip instance called my. Container: load. Movie("my. External. Movie. swf", my. Container); // the target my. Container is an object reference. Movie("my. External. Movie. swf", "my. Container"); // the target "my. Container" is a stringload. Movie can also load content into different levels of the Flash player. Levels in Flash player are like player layers. Multiple movies can be played in the same instance of Flash player without being nested inside one another. Each level represents a unique root where movies can play independently of movies within other levels (using _lockroot is unnecessary). You can reference levels in Action. Script using _level followed by a number representing the level number. The first movie loaded into Flash Player is on _level. Additional levels can be added on top of that level. The following call to load. Movie loads "my. External. Movie. swf" into level 1 on top of the current movie playing in the player. Movie("my. External. Movie. swf", "_level. A variation of the global load. Movie function is load. Movie. Num. This method is just like load. Movie except that it only targets levels and it targets them by number, not by name. To load an external SWF file into level 1 (_level. Movie. Num("my. External. Movie. swf", 1); When loading into levels, Adobe recommends that you use load. Movie. Num over load. Movie. For more information, see global load. Movie in the Action. Script 2. 0 Language Reference. When loading an external movie into another movie, the _root reference of the loaded movie clip changes from its main timeline to the timeline of the movie that loaded it. In other words, _root always references to the top- most timeline in the hierarchy. If you don't want _root to reference the top- most timeline, set the _lockroot property of the main timeline of the loaded movie clip to true. This property tells all children of that timeline that when they reference _root, to reference that timeline. SWF file that will be loaded into another SWFNote: The _lockroot property is only available when publishing to Flash Player 7 or later. The Movie. Clip. Loader class in Action. Script 2. 0 is designed to make the process of loading external content into Movie. Clip instances easier. As mentioned earlier, variables and functions defined in movie clips are removed when new content is loaded into those movie clips. Callbacks like on. Load aren't possible. However, the Movie. Clip. Loader circumvents this restriction by working as a surrogate to such events. You create separate Movie. Clip. Loader instances to manage the loading of content into another movie clip. Therefore, clearing of variables or functions within that movie clip doesn't occur. When loading content into a movie clip through the Movie. Clip. Loader class, first make a new instance of the class. Then use load. Clip to load content into a target movie clip. In the following example, the new content is being loaded into the movie clip my. Container. var my. Loader: Movie. Clip. Loader = new Movie. Clip. Loader(). my. Loader. load. Clip("my. External. Movie. swf", my. Container); If you want to know that the content is loaded, use an on. Load. Init event handler with your Movie. Clip. Loader instance. Loader: Movie. Clip. Loader = new Movie. Clip. Loader(). my. Loader. add. Listener(this). Loader. load. Clip("my. External. Movie. swf", my. Container). function on. Load. Init(mc: Movie. Clip). trace("content has been loaded into "+mc). When you want to have more control over the information regarding the loading of content into a movie clip, use the Movie. Clip. Loader class instead of Movie. Clip. load. Movie. For example, use this event handler when you want to be able to check for loading progress.) For more information on the Movie. Clip. Loader class, see Movie. Clip. Loader in the Action. Script 2. 0 Language Reference. Note: Movie. Clip. Loader class is only available when publishing to Flash Player 7 or later. Using relative paths with Loader and load. Movie can be confusing. Because the timeline of any SWF file or movie clip can perform a load. Movie action, ask "what timeline is the movie being loaded relative to"? Is it relative to the main timeline at _level. Or is it relative to the timeline that performed the movie- loading action? The answer is simple: Loaded movies are always relative to the timeline that loaded them. See Relative URLs not referenced correctly | Flash (tn_0. SWF files as well.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
October 2016
Categories |