Menu Home

Embed

osbo.com | Flash | ActionScript | Embed

Embedded assets are assets (images, sound, ...) compiled with the application.

These assets load when the application is loaded. Because they load with the application, they are available at run-time.

Example

Embed

Adobe Flash Builder

package
{
    import flash.display.Bitmap;
    import flash.display.Sprite;

    public class ActionScriptEmbedBuilder extends Sprite
    {
        [Embed(source="HappyFace.jpg")]
        private var Asset :Class;

        public function ActionScriptEmbedBuilder()
        {
            var bitmap :Bitmap = new Asset();
            addChild(bitmap);
        }
    }
}

Download

Adobe Flash Professional

Adobe Flash Professional uses a library to embed assets.

Instructions

  1. Open Adobe Flash Professional
  2. Create .fla
  3. Click File
  4. Click Import
  5. Click Import to Library...
  6. Select asset
  7. Click Open
  8. Click Window
  9. Click Library
  10. Right-click asset
  11. Click Linkage...
  12. Check Export for ActionScript
  13. After Class:, type Asset
  14. Click OK
  15. Create .as
  16. Publish

Code

package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;

    public class ActionScriptEmbedProfessional extends Sprite
    {
        public function ActionScriptEmbedProfessional()
        {
            var bitmapData :BitmapData = new Asset(0, 0);
            var bitmap     :Bitmap     = new Bitmap(bitmapData);
            addChild(bitmap);
        }
    }
}

Download