3 Replies Latest reply on Feb 12, 2010 8:06 AM by yoav@cyteam.com

    embedded images

    vindictive27 Level 1

      Is there something wrong with this?  It doesn't work.  The image becomes a broken link (the asset is found and brought into the swf, however).  Using the normal way of designating an image source (img1.source="assets/abc.png") works fine.  But using the embedded method seems to break it.  Any ideas?  Thank you!

       

      [

       

      Embed(source="/assets/some_image.png")] [Bindable] public var someImage:Class;

       

       

       

      if (this._iconSize == "something")

      {

      img1.source=

      "{someImage}";}

       

       

       

       

        • 1. Re: embedded images
          Gregory Lafrance Level 6

          Remove the initial   /  ?

           

          "assets/some_image.png"

           

           

          If this post answers your question or helps, please mark it as such.


          Greg Lafrance - Flex 2 and 3 ACE certified

          www.ChikaraDev.com

          Flex / AIR Development, Training, and Support Services

          • 2. Re: embedded images
            vindictive27 Level 1

            Thank you, I have tried that however.  I've actually tried the path several ways.  Without embedding it works both with and without the slash, but doesn't work either way embedded.  Can I not assign an embedded image to an image source property in actionscript?  It seems to work fine in the mxml, but I don't want to do it at that level.  Should I be maybe doing it at the function scope and setting the image source (like it would be in the mxml to "@Embed" etc)?

            • 3. Re: embedded images
              yoav@cyteam.com

              hey,

               

              I think you need to instantiate the embedded image class, and then assign it:

              e.g.

              [Embed(source='/assets/images/someImage.png')] private var MyImageClass:Class;

               

              then,

              var img:Image = new Image();

              ......

               

              img.source = new MyImageClass();