i have component being called within repeater. within call, i'm passing several variables component. of them work fine except 1 named totalspan... returning nan reason. here's code i'm working with:
parent:
<mx:repeater id="indpositions" dataprovider="{projectpositions}" startingindex="0" count="{projectpositions.length}"> <components:block height="28" id="thisblock" visible="true" horizontalscrollpolicy="off" width="{projectwidth}" oneday="{number(oneday)}" offset="{indpositions.currentitem[0]}" numdays="{indpositions.currentitem[1]}" position="{indpositions.currentitem[2]}" sname="{indpositions.currentitem[3]}" projectname="{projecttitle}" totalspan="{number(math.round(projectwidth.vl / oneday))}" /> </mx:repeater>
all of variables in there work fine , typeof() fine.
here's child code:
[bindable] public var totalspan:number;
and in init() function perform simple:
alert.show(string(totalspan));
the alert returns "nan".
on semi-related note, i'm getting warnings on following lines of parent:
offset="{indpositions.currentitem[0]}" numdays="{indpositions.currentitem[1]}" position="{indpositions.currentitem[2]}" sname="{indpositions.currentitem[3]}"
with message says "data binding not able detect chances when using square bracket operator. array, please use arraycollection.getitemat() instead.
can shed light on these warning errors? example appreciated.
first of assignment of totalspan
following:
totalspan="{number(math.round(projectwidth.vl / oneday))}"
but width="{projectwidth}"
can see projectwidth
number
or int
. hasn't vl
property. , number(math.round(projectwidth.vl / oneday))
nan
. please rewrite properly. maybe should following:
totalspan="{number(math.round(projectwidth / oneday))}"
about second part. if you're using {} in mxml stands data binding. data binding provides changes in target attributes changes of source. , message says array
primitive type , mxmlc
compiler can't generate code handle changes in array's values.
but obvious code have problems data structures. hard improve not having whole project's code should use custom data types required [bindable]
metadata data binding , arraycollection
instead of array
data used source of data binding.
try create like:
[bindable] class mydataobject { public var offset:int; public var numdays:int; public var position:int; public var sname:string; }
and put these items data provider of repeater. far can understand data provider repeater length in real life should provide repeater elements data. if pass repeater arraycollection
of custom mydataobject
objects can use following:
<mx:repeater id="indpositions" dataprovider="{projectpositions}"> <components:block height="28" id="thisblock" visible="true" horizontalscrollpolicy="off" width="{projectwidth}" oneday="{number(oneday)}" offset="{indpositions.currentitem.offset}" numdays="{indpositions.currentitem.numdays}" position="{indpositions.currentitem.position}" sname="{indpositions.currentitem.sname}" projectname="{projecttitle}" totalspan="{number(math.round(projectwidth / oneday))}" /> </mx:repeater>
and more. can pass whole object of mydataobject
type components:block
component:
<mx:repeater id="indpositions" dataprovider="{projectpositions}"> <components:block height="28" id="thisblock" visible="true" horizontalscrollpolicy="off" width="{projectwidth}" oneday="{number(oneday)}" mydata="{mydataobject(currentitem)}" projectname="{projecttitle}" totalspan="{number(math.round(projectwidth / oneday))}" /> </mx:repeater>
hope these thoughts help!
Comments
Post a Comment