Assets

Previous pageReturn to chapter overviewNext page



 

Background

As part of the Adobe Flash file format (SWF) "definition tags" are used to define the content of the Flash (SWF) movie i.e. the shapes, text, bitmaps,  sounds, videos etc. that are used in the movie. Each definition tag assigns a unique ID called a character to the content it defines. The Flash player then stores the character is a repository called the dictionary. Normally objects, and definition tags are not available to other SWFs during runtime. SWiSH Max allows the author to set an Object as an asset and enable it for export, or import. This Object is then said to be an "asset".

 

An Asset can be used for:

·scripting. Movie Clips etc. can be dynamically created using the asset name.
·shared assets. Named assets can be used from one SWF file in other SWF files.

 

The Object Attribute panel for Objects (stage and library) includes an assets tab with options to:

·enable asset: enables the object to be an assets. the asset MUST have a name.
·Define in frame: sets the export frame for the asset. For example, when using a preloader it is preferrable to define all the assets AFTER the preloader is complete.
·Class name: Classes can be created using prototypes (see Custom Classes). The 'Class Name' is used to associate a class with the asset. The class can extend the behavior of the built-in object. Whenever an instance of the asset is created, the properties and behaviors of the instance are defined by the class assigned to it.

 

·enable import: imports an asset from another SWF (during runtime). Options include:
·Import name: Enter the name of the asset to be imported
·From SWF file: Enter the absolute or relative path of the SWF containing the asset (as named above). Relative path e.g. "subfolder\assets.swf", "..\..\subfolder\assets.swf" or same folder "assets.swf". Absolute path e.g. "http:\\www.mysite.com\files\assets.swf".  where mysite.com is the same domain.

 

 

assets

 

 

An asset can be imported from other SWF and also (re-)named (for export). When both options are set the definition is stripped form the SWF, and instead an  import tag is included at authoring time as a placeholder for the object/symbol/resource defined in the SWI.

 

Note: to import an asset from another SWF

·that SWF also MUST to have Assets defined
·that SWF MUST be present at runtime

If a SWF is not available to import the asset the Flash player will simply pass over the problem without explicitly reporting the error.

 

 

Objects Supporting Asset naming

Some objects can not be used as assets.

 

Can be an Asset:

·Any Object other than Embedded video or scenes.

 

Can NOT be an Asset:

·Embedded Video
·Scenes
·Soundtracks
·Gradients

 

 

Example

 

onSelfEvent(load)
{
       attachMovie("library_video", "myvideo", 1);
}

 

The example links an instance of a symbol with asset name "library_video" from the library and attaches it to the movieclip. The instance has the name "myvideo".