0 Replies Latest reply on Apr 25, 2012 5:41 AM by enPerdition

    Embed image into runtime skin (.swf)

    enPerdition

      Hi all,

       

      I'm trying to embed an image into a runtime skin but I have this error :

       

      Error: Skin for skinsRuntimeBase0.ApplicationSkin2._ApplicationSkin_Group1.contentGroup.BoutonPerso8.Bout onPersoSkinRed16._BoutonPersoSkinRed_Image1 cannot be found.

       

      when I access to my swf skin in my main application with styleManager.loadStyleDeclarations2().

       

      I'm working with FB4 and command line (compc + mxmlc) to compile resources and to compile swf with my swc resource bundle.

       

      Here is my process :

       

      1) Creation of a FB4 library project and copy of an image url.png in package assets.

      2) Creation of a swc asset with this library project. Here is my xml :

       

      <?xml version="1.0"?>
      <flex-config>
      
          <compiler>
      
               <source-path append="true">
                  <path-element>src</path-element>
              </source-path>
                
          </compiler>
      
          <include-file>
              <name>url.png</name>
              <path>src/assets/url.png</path>
          </include-file>
      
          <output>assets.swc</output>
      
      </flex-config>
      

       

      3) Creation of another FB4 library project in which I load into library path assets.swc

       

      4) Creation of a basic css file :

       

      @namespace s "library://ns.adobe.com/flex/spark";

      @namespace mx "library://ns.adobe.com/flex/mx";

      @namespace test "com.test.*";

       

      test|BoutonPerso{

          skinClass: ClassReference("skins.red.BoutonPersoSkinRed");

      }

       

      test|BoutonPerso #label {

          color: "0xFF0000";

      }

       

      My skin class is that :

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
              xmlns:s="library://ns.adobe.com/flex/spark" 
              xmlns:mx="library://ns.adobe.com/flex/mx">
          
          <fx:Metadata>
              [HostComponent("com.test.BoutonPerso")]
          </fx:Metadata>
          
          <fx:Script>
              <![CDATA[
                  
                  [Embed(source="url.png")]
                  [Bindable]
                  public var img:Class;
                  
              ]]>
          </fx:Script>
              
          <s:Label id="label" text="skinRed" />
          
          <s:Image source="{img}" />    
          
      </s:Skin>
      

       

      I notice here that if I change the source of Embed metadata, I have an error so my image in my assets.swc is correctly found.

       

      5) Creation of my swf runtime skin :

       

      <?xml version="1.0"?>
      <flex-config>
      
          <compiler>
      
              <source-path append="true">
                  <path-element>src/</path-element>
              </source-path>
      
              <include-libraries append="true">
                  <library>E:/workspaces/flex/assets/assets.swc</library>
              </include-libraries>
        
              <keep-as3-metadata append="true">
                  <name>Bindable</name>
                  <name>Managed</name>
                  <name>ChangeEvent</name>
                  <name>NonCommittingChangeEvent</name>
                  <name>Transient</name>
                  <name>Embed</name>
              </keep-as3-metadata>
      
          </compiler>
      
          <file-specs>
              <path-element>src/redStyle.css</path-element>
          </file-specs>
      
          <output>redSkin.swf</output>
      
      </flex-config>
      

       

      My redSkin.swf is created and Embed my image (verified with the size of my swf and a swf explorer in which I find my image).

       

      But when in my main application I try to load my skin with :

       

      styleManager.loadStyleDeclarations2("E:/workspaces/flex/skinsRuntimeRed/src/redStyle.swf", true, ApplicationDomain.currentDomain);
      

       

      I have error at top of message.

       

      what am I doing wrong please ?

       

      Thanks and sorry for my english