1 Reply Latest reply on Aug 10, 2009 10:40 AM by Flex harUI

    Embedding SWF causes it to be downloaded multiple times

    Hillel Coren Level 1

      I'm trying to add a loading spinner to my application. I'm using a Flash SWF to accomplish this. The issue I'm having is it looks like if I use the component which contains the spinner in multiple places each one downloads a copy of the SWF.

       

      I've created a static Assets class as follows: (I've attached the spinner.swf file to this post)

       

      package
      {
          [Bindable]
          public class Assets
          {
              [Embed("spinner.swf")]
              public static var spinner:Class;
          }
      }

       

       

      Here's an example where I use this class:

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application
          xmlns:mx="http://www.adobe.com/2006/mxml"
          verticalAlign="middle" horizontalAlign="center">
         
          <mx:Image source="{ Assets.spinner }"/>
          <mx:Image source="{ Assets.spinner }"/>

      </mx:Application>

       

       

      The output in the console is:

       

      [SWF] Users:hillel:Code:Test.swf - 676,864 bytes after decompression
      warning: unable to bind to property 'spinner' on class 'Assets' (class is not an IEventDispatcher)
      [SWF] Users:hillel:Code:Test.swf - 4,517 bytes after decompression
      [SWF] Users:hillel:Code:Test.swf - 4,517 bytes after decompression

       

      As a side question, how do I clear up the warning. The Assets class is marked as Bindable which I believe should make it an IEventDispatcher.

       

      Thanks for your help,

      Hillel