Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Data Integration / October 2005



Tip: Looking for answers? Try searching our database.

bound index using actionscript

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steeban - 24 Aug 2005 13:34 GMT
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 ??????????????????
steeban - 08 Sep 2005 05:11 GMT
what, no one is replying for this ???

atleast, is there are any tutorials in this..........
GeoffEly - 09 Sep 2005 00:08 GMT
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.
steeban - 17 Oct 2005 11:15 GMT
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
DaOrangeMan - 20 Oct 2005 18:24 GMT
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
steeban - 21 Oct 2005 05:14 GMT
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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.