Doug, thanks for weighing in, it's appreciated.
I'm sorry - don't understand the VO class reference - I'm assuming
that you're just making up a class named VO, right?
So I should create this Class that has the properties I want and push
them into the array?
It gets hairier actually - originally I had one xml object (here's the
actual xml):
<item id="00002" date="2007-03-15T06:14:23Z">
<info>
<circleText><![CDATA[Could there by styles? How about <i>italic</
i>. <b>Boldness</b>? Why, yes, there is. This is stll more example
text regarding the circle data. Typing is fun. It will be full html
text at when finished and saved to the database when finished. The
editor itself will be full html control]]></circleText>
<workingText><![CDATA[I could write all day about example text
regarding the 'what I'm working on' section. It will be full html
text at when finished and saved to the database when finished. The
editor itself will be full html control]]></workingText>
<needText><![CDATA[This could very well be <bold>still</bold>
more example text regarding what I need from you. It will be full
html text at when finished and saved to the database when finished.
The editor itself will be full html control]]></needText>
</info>
<circle type="work" x="100" y="300" percent="25" />
<circle type="home" x="10" y="120" percent="40" />
<circle type="community" x="150" y="10" percent="10" />
<circle type="self" x="200" y="100" percent="25" />
</item>
Originally I had a class called CircleData that was a singleton, and
binding to the currentData variable; of course everytime I loaded in a
new xml, everything would change properly, but the minute I'd try
changing the data of one circle's percent, nothing on stage would be
updated. Same problem as above it seems.
So you think creating a new Circle class and binding the buttons to
each circle in an array, when changing the array(circle1.percent)
(yeah, fake) -- should be enough.
By the way, love the blog. 2 thumbs up.
On Apr 20, 2008, at 11:45 PM, Doug McCune wrote:
You're creating a bindable Array that is full of non-bindable Objects.
Since your Array is bindable you would be able to bind to the Array
itself, and bindings would get fired when the Array changes (ir you
do something like objs = new Array()). But inside that Array are
simple Objects that are not bindable. So no bindings will ever fire
when: a) objects are added and removed from the array, if you wanted
that you should use ArrayCollection and getItemAt(), and b) no
bindings fire when properties of those Objects get updated.
So one way to change your example is to use a VO class to hold the
data that is in those objects, and make the entire class, or certain
properties, bindable. So if you had a VO class that had x, y,
percent, and type properties that were all bindable then your
example would work. If you want a quick but pretty dirty solution
try just wrapping your objects in the ObjectProxy class, so your
Array creation line might look like this:
public var objs:Array = new Array(new ObjectProxy({x:30, y:22,
percent:20, type:"community"}) ... );
But it's worth having a proper undertanding of how binding really
works, so I'd advise against using ObjectProxy to force binding to
work.
Doug
On Sun, Apr 20, 2008 at 7:18 PM, grimmwerks <[EMAIL PROTECTED]>
wrote:
Could someone PLEASE point out what I'm doing wrong in the
following? I want to bind a numeric stepper to a certain size and
have it changed live; I'm trying to change the scale of these
buttons to the numeric steppers; here's a test:
-------
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%" horizontalScrollPolicy="off"
verticalScrollPolicy="off" >
<mx:Repeater id="rep" dataProvider="{objs}">
<mx:Button x="{Number(rep.currentItem.x)}"
y="{Number(rep.currentItem.y)}"
width="{(Number(rep.currentItem.percent)*defaultSize)}"
height="{(Number(rep.currentItem.percent)*defaultSize)}"
styleName="{String(rep.currentItem.type)}"
label="{String(rep.currentItem.type).toUpperCase()}"
toolTip="{'At the moment '+ String(rep.currentItem.type)+' is
'+rep.currentItem.percent+'% of my life at the moment'}" />
</mx:Repeater >
<mx:NumericStepper id="tmp"
change="{objs.getItemAt(0).percent=tmp.value}"
value="{objs[0].percent}" maximum="100" />
<mx:Script>
<![CDATA[
import mx.controls.Button;
import mx.core.BitmapAsset;
import mx.managers.DragManager;
import mx.core.DragSource;
import mx.events.DragEvent;
import flash.events.MouseEvent;
import mx.effects.easing.*;
import mx.binding.utils.BindingUtils;
import mx.collections.ArrayCollection;
import mx.controls.Alert;
import mx.utils.ObjectUtil;
import mx.core.Application;
private var offX:Number;
private var offY:Number;
[Bindable]
public var objs:Array = new Array({x:30, y:22, percent:20,
type:"community"},{x:90, y:22, percent:25, type:"work"},{x:110, y:
72, percent:45, type:"self"},{x:70, y:120, percent:15, type:"faily"});
[Bindable]
private var defaultSize:Number = new Number(6);
]]>
</mx:Script>
</mx:Application>