No, that's not what I'm looking for, but thanks anyway.
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
________________________________
From: [email protected]
[mailto:[EMAIL PROTECTED] On Behalf Of Sherif Abdou
Sent: Monday, February 04, 2008 3:33 PM
To: [email protected]
Subject: Re: [flexcoders] Databinding in component
you could always just do nameOfComponent.dataProvider = fakedata
and that work but i dont know if that is what you are looking for.
----- Original Message ----
From: "Merrill, Jason" <[EMAIL PROTECTED]>
To: [email protected]
Sent: Monday, February 4, 2008 1:50:32 PM
Subject: [flexcoders] Databinding in component
Why does the button click below not trigger databinding in the
component (i.e. automatic call of set dataprovider) ?
Here is my test case:
//MXML:
<?xml version="1.0" encoding="utf- 8"?>
<mx:Application
xmlns:mx="http://www.adobe. com/2006/ mxml
<http://www.adobe.com/2006/mxml> " xmlns:c="components .*"
layout="absolute"
applicationComplete ="init()" >
<mx:Script>
<![CDATA[
import mx.collections. ArrayCollection;
[Bindable]
public var fakeData:ArrayColle ction;
private function init():void
{
fakeData = setFakeData( );
}
private function setFakeData( ):ArrayCollectio n
{
var fd:ArrayCollection = new ArrayCollection( );
fd.addItem({ firstName: "David", lastName:"Branson" });
fd.addItem({ firstName: "Ned", lastName:"Davidson" });
fd.addItem({ firstName: "Sally", lastName:"Peterson" });
return fd;
}
private function changeData() :void
{
fakeData.addItem( {firstName: "Jason", lastName:"Merrill" });
}
]]>
</mx:Script>
<c:BindableListText dataProvider= "{fakeData} " />
<mx:Button x="100" label="change data" click="changeData( )"/>
</mx:Application>
/*========== ========= ========= ========= ========= ========* /
//Component:
package components
{
import flash.events. Event;
import mx.controls. TextArea;
import mx.collections. ArrayCollection
import mx.core.UIComponent ;
public class BindableListText extends UIComponent
{
[Bindable]
private var _dataProvider: ArrayCollection;
private var tf:TextArea;
public function BindableListText( )
{
tf = new TextArea();
tf.height = 400;
tf.width = 400;
addChild(tf)
}
public function set dataProvider (_dp:ArrayCollectio n) :void
{
_dataProvider = _dp;
showData();
trace("databinding triggered")
}
private function showData():void
{
var dpLen:int = _dataProvider. length;
tf.text = "";
for(var i:int = 0; i<dpLen; i++)
{
tf.text += _dataProvider. getItemAt( i).firstName+ "\n";
}
}
}
}
Jason Merrill
Bank of America
GT&O L&LD Solutions Design & Development
eTools & Multimedia
Bank of America Flash Platform Developer Community
________________________________
Be a better friend, newshound, and know-it-all with Yahoo!
Mobile. Try it now.
<http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i6
2sR8HDtDypao8Wcj9tAcJ>