Hi there

I managed to get Ralf's version to work & half got mine to work by
applying the [Bindable] tag to my MyClassObject. I am working on
something different at the moment, and again have run into trouble
with binding on an ArrayCollection in a model class.

I would like to run my ArrayCollection value through a formatter
function in my view. This method works with a string, but performs
strangely for a collection, where:
1) The format function is never called on update
2) The bound control reflects the update if I return the
ArrayCollection reference from the function, and doesn't reflect the
update if I return a reference to a different object (even though the
function is never called)

Model class:
-------------------- snip ---------------------------
public var tempMoveList:ArrayCollection = new ArrayCollection();
public var tempText:String  = "start";
-------------------- /snip ---------------------------
View:
-------------------- snip ---------------------------
<mx:Script>
 <![CDATA[
 public function updateModel() {
  model.tempText = "Text" + Math.random().toString();
  model.tempMoveList.addItem({val:Math.random()});
 }
 public function formatVal(t:String):Object {
  trace("Format Text");
  return t+= "_formatted";
 }
 public function formatList(l:ArrayCollection) {
  trace("Format List")
  l.addItem({val:100});
  return l;     
 }              
 [Bindable]
 public var model:Model = Model.getInstance(); 
]]>
</mx:Script>
<mx:Button label="click" click="updateModel()" />
<mx:Label text="{formatVal(model.tempText)}" />
<mx:Tree id="moveTree" x="189" y="0"
dataProvider="{formatList(model.tempMoveList)}" labelField="val"
height="190" width="193" />
-------------------- /snip ---------------------------

I have also tried using a <mx:Binding> tag to perform the operation,
as well as Paul Williams 'smallest tag'*, both of which do not reflect
an update to the ArrayCollection value. Trying to follow up on this in
the documentation I found the following, which seems to imply that the
formatting function should work: 

"You can use ActionScript functions as the source of binding
expressions. You usually do this when using a bindable property as an
argument of a function. When the bindable property changes, the
function executes, and the result is used in the binding destination ..."

Regards
Tracy

*http://weblogs.macromedia.com/paulw/archives/2006/05/the_worlds_smal.cfm






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Great things are happening at Yahoo! Groups.  See the new email design.
http://us.click.yahoo.com/SktRrD/hOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to