Skip to content

Instantly share code, notes, and snippets.

@louisbl
Created June 6, 2012 07:05
Show Gist options
  • Save louisbl/2880362 to your computer and use it in GitHub Desktop.
Save louisbl/2880362 to your computer and use it in GitHub Desktop.
Nested dataprovider - binding
public class BasicScoreModule implements IScoreModule
{
[Bindable]
public var score : int;
private var _nom : String;
private var _viewClass : Class;
public function BasicScoreModule()
{
_nom = 'basic score';
score = 4;
}
public function calcul() : void
{
}
public function get nom() : String
{
return _nom;
}
public function set nom(s : String) : void
{
_nom = s;
}
public function set viewClass(c : Class) : void
{
_viewClass = c;
}
public function get viewClass() : Class
{
return _viewClass;
}
}
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:Label id="nom"/>
<s:Button label="-"/>
<s:TextInput id="valeur" text="{data.score}"/>
<s:Button label="+"/>
</s:ItemRenderer>
<?xml version="1.0" encoding="utf-8"?>
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" xmlns:components="spark.components.*">
<fx:Script>
<![CDATA[
private function scoresViewRendererFunction( item : Object ) : ClassFactory
{
return new ClassFactory(item.viewClass);
}
]]>
</fx:Script>
<s:layout>
<s:HorizontalLayout/>
</s:layout>
<s:Label text="{data.pseudo}"/>
<s:List id="joueurModules" itemRendererFunction="scoresViewRendererFunction" dataProvider="{data.scoreModules}" />
</s:ItemRenderer>
public class ItemJoueurModulesVO
{
[Bindable]
public var pseudo : String;
[Bindable]
public var scoreModules : ArrayCollection;
public function ItemJoueurModulesVO()
{
pseudo = "";
scoreModules = new ArrayCollection(); // collection de BasicScoreModule
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment