all groups > flash data integration > august 2005 >
You're in the

flash data integration

group:

bound index using actionscript


bound index using actionscript steeban
8/24/2005 12:34:39 PM
flash data integration:
hi everybody...
does anyone know how to do this ????

i am binding an xml connector with a textarea component and a combobox
component...
when an item in combobox changes the value changes in the textarea....

the general syntax to make a databinding using actionscript is this
---------------------------------------------
new mx.data.binding.Binding({component:, property:"", event:[""]},
{component:, property:""}, {cls:mx.data.formatters.Custom,
settings:{classname:"", classname_class:}});
--------------------------------------------

now the sample schema for the the xml connector is :

xml connector name: my_xml
results ; XML
----newdata : Object
--------data : Array
------------[n] : Object
------------a : String
------------b : String

so the syntax i need are :
1.binding between the my_xml array and the combo box (my_combo) dataprovider
2.binding between the my_xml--> a:String and the textarea (my_txt) text
3.binding between the index of the xml connector (my_xml) and the
selectedindex of the combobox (my_combo)


anyone can solve this problem ??????????????????
Re: bound index using actionscript steeban
9/8/2005 12:00:00 AM
what, no one is replying for this ???

Re: bound index using actionscript GeoffEly
9/8/2005 11:08:39 PM
Here is something that might help with #3. (It's probably more than you need,
but it's what I have handy.)

On a stage with a datagrid (dg), a dataset (ds) and 6 textinputs (tb0 - tb5)...

The data provider for dg is bound to the data provider for ds.

Each instance of the text input (will be) bound to a different item in the
dataset.
If you change a (bound) cell in the datagrid, the corresponding text input
changes, and vice versa.


The following actionscript (dynamically) binds the textinputs to ds.

//---------------

import mx.data.binding.Binding;
import mx.data.binding.EndPoint;
import mx.data.components.DataSet;
//
var boundElementName = "name"; // name of the ds element to bind to the text
boxes
var loop = 6; // number of items to put in the data grid (the text boxes are
static) - what? I was lazy
for (var ndx = 0; ndx < loop; ndx++)
{
//
// set the end points for the binding that moves data from the dataset to the
text boxes
var src = new EndPoint ();
var dest = new EndPoint ();
src.component = ds;
src.property = "items";
src.event = "modelChanged";
src.location = {path:["[n]", boundElementName], indices:[{constant:ndx}]};
dest.component = _root["tb" + ndx];
dest.property = "text";
new Binding (src, dest);
//
//set the end points for the binding that moves the data from the text boxes
to the dataset
// (note the different event)
src = new EndPoint ();
dest = new EndPoint ();
src.component = _root["tb" + ndx];
src.property = "text";
src.event = "change";
dest.location = {path:["[n]", boundElementName], indices:[{constant:ndx}]};
dest.component = ds;
dest.property = "items";
new Binding (src, dest);
}
//
// fill the data set with junk
for (var ndx = 0; ndx < loop; ndx++)
{
var to = new Object ();
to.name = "name" + ndx;
to.stuff = "timer: " + getTimer ();
to.number = ndx;
ds.addItem (to);
}
//
// this code is just to make the datagrid sync with the changes to the text
boxes.
// - the data set is already changing, but the changes will not show in the
datagrid without a little "help"
//
tbChangeObject = new Object ();
tbChangeObject.focusOut = function (eventObject)
{
ds.refreshDestinations ();
};
for (var ndx = 0; ndx < loop; ndx++)
{
_root["tb" + ndx].addEventListener ("focusOut", tbChangeObject);
}

//---------------

Hope this helps.
Re: bound index using actionscript steeban
10/17/2005 10:15:46 AM
Hi GeoffEly,
that's great....amazing.......it works....

but a small doubt....
whether is it possible to give dynamic value in the constant property

src.location = {path:["[n]", boundElementName], indices:[{constant:ndx}]};

here you had specified ndx, instead of ndx, I want to specify the
selectedIndex property of my combo box.....

is this possible..????

Please help
Re: bound index using actionscript DaOrangeMan
10/20/2005 12:00:00 AM
the tutorial you are looking for is the Bike tutorial, at
http://www.macromedia.com/devnet/flash/articles/xmlconnector.html

it shows steps to bind the description (text) field component and loader
component to the selected results of a combo box.

I have a related issue that might be in the area of what you are doing....i
have successfully created a similar app as the bike one, which walks through
images upon selection of a combo box value.

this is all fine, but what i really want to do is pass a variable to the movie
, such as "clipNumber" with a value, and have the selected description and
image change based on that information.

So right now, with the combo box providing the value, I have the "Index for
image" in the Component Inspector binding for the set to
selectbox_cb:selectedindex

How might one use a variable here? I have tried several formats (), {}, or on
its own, but to no avail. I want it to work off something like "Index for
image" being clipNumber

Scott B
Re: bound index using actionscript steeban
10/21/2005 4:14:40 AM
Hi Scott,
the bike tutorial is done using binding panel in the component inspector...
okay, i had asked how to bind the data in actionscript without using binding
panel....

okay, for your problem, check the dataholder component, you can get what you
want.....

bye
AddThis Social Bookmark Button