Bonjour,

je cherche désespérément à "skiner" les boutons du composant ButtonBar. Chaque bouton doit avoir une image d'illustration différente.

je passe à la propriété dataProvider du composant ButtonBar les chemins des images :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx" width="1000" height="577"	   
			   skinClass="habillage.ApplicationSkin" xmlns:composants="composants.*"
			   color="#ff0000">
<fx:Script>
	<![CDATA[
	import habillage.ApplicationSkin;
	import mx.controls.Alert;
	import mx.collections.ArrayList;
 
	import spark.events.IndexChangeEvent;
 
	[Bindable]
	private var menuAssets:ArrayList = new ArrayList([
		{ label:"item1", icon:"@Embed('images/icone1.png')" },
		{ label:"item2", icon:"@Embed('images/icone2.png')" },
		{ label:"item3", icon:"@Embed('images/icone3.png')" },
		{ label:"item4", icon:"@Embed('images/icone4.png')" }
	]);
	]]>
</fx:Script>
 
 
	<s:ButtonBar dataProvider="{menuAssets}" 
			change="buttonbar_changeHandler(event)"  
			x="305" y="480" 
			height="85"
			skinClass="habillage.ButtonBarSkin" />
 
</s:Application>
Ensuite dans le fichier de skin du composant ButtonBarButton, je récupère le chemin des images. Le problème c'est que ça marche lorsque je mets le chemin en dur dans le mxml : <s:BitmapImage id="img1" source="@Embed('images/incone1.png')" /> mais pas si je veux le faire dynamiquement : img1.source = hostComponent.data.icon, bien que hostComponent.data.icon contient bien "@Embed('images/icone1.png')"......

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<?xml version="1.0" encoding="utf-8"?>
 
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" 
      xmlns:fb="http://ns.adobe.com/flashbuilder/2009" minWidth="21" minHeight="21"
      alpha.disabledStates="0.5" creationComplete="sparkskin_creationCompleteHandler(event)">
 
    <!-- host component -->
    <fx:Metadata>
        <![CDATA[ 
            [HostComponent("spark.components.ButtonBarButton")]
        ]]>
    </fx:Metadata>
 
    <fx:Script fb:purpose="styling">
 
	import mx.controls.Alert;
	import mx.events.FlexEvent;
	import mx.graphics.BitmapFillMode;
 
	protected function graphic1_creationCompleteHandler(event:FlexEvent):void
	{
	        img1.source = hostComponent.data.icon;
	}
 
    </fx:Script>
 
    <!-- states -->
    <s:states>
        <s:State name="up" />
        <s:State name="over" stateGroups="overStates" />
        <s:State name="down" stateGroups="downStates" />
        <s:State name="disabled" stateGroups="disabledStates" />
        <s:State name="upAndSelected" stateGroups="selectedStates, selectedUpStates" />
        <s:State name="overAndSelected" stateGroups="overStates, selectedStates" />
        <s:State name="downAndSelected" stateGroups="downStates, selectedStates" />
        <s:State name="disabledAndSelected" stateGroups="selectedUpStates, disabledStates, selectedStates" />
    </s:states>
 
<s:Graphic width="100" height="85" creationComplete="graphic1_creationCompleteHandler(event)">
	<s:BitmapImage id="img1" width="100" height="85" fillMode="{BitmapFillMode.SCALE}" />
</s:Graphic>
 
</s:SparkSkin>
Bref, je crois avoir tout essayé... si quelqu'un à une idée...

merci