Problema col tag Image in Skin di Flex

Flex oscar Commenta l'articolo

Se creiamo uno Skin da Adobe CS (3 o superiore), lo pubblichiamo come SWC e poi lo importiamo in FLex tramite il wizard guidato “Import ArtWork” abbiamo un problema col tag Image. Infatti otteniamo un file CSS del tipo:

Button { skin: Embed(skinClass="Button_skin"); }
Canvas { backgroundImage: Embed(skinClass="Canvas_backgroundImage"); }
Image  { source: Embed(skinClass="Image_source"); }

che inserito in un file MXML:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:com="com.*">
    <mx:Style source="skins.css"/>

    <!--- Canvas background is set from the CSS --->
    <Canvas>    
        <!--- Button skin is set from the CSS  --->
        <mx:Button />  
        <!--- Image does not displayed --->
        <mx:Image />   
    </Canvas>
</mx:Application>

otteniamo un file swf in cui l’immagine non viene visualizzata. Per risolvere il problema dobbiamo inserire un ClassReference:

Button { skin: Embed(skinClass="Button_skin"); }
Canvas { backgroundImage: Embed(skinClass="Canvas_backgroundImage"); }
Image  { source: ClassReference("Image_source"); }
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:com="com.*">
    <mx:Style source="skins.css"/>
    <!--- Canvas background is set from the CSS --->
    <Canvas>    
        <!--- Button skin is set from the CSS  --->
        <mx:Button />  
        <!--- Now the image works --->
        <mx:Image source="{Image_source}"/>   
    </Canvas>
</mx:Application>

Trovate un interessante articolo sulla differenza tra SkinClass e ClassReference qui

Scrivi un Commento

Home | Graffiti e Disegni | Educazione | Chi siamo | Blog | Progetti | Contatti
RSS Feed Comments RSS Accedi