Create bindings with ActionScript

I want to make an application, that creates a XMLConnector, DataSet and DataGrid at runtime, and sets the right bindings so the xml data is displayed in the DataGrid.
I’ve tried this, but I can’t get it to work.

The steps I take if I create the bindings with the Flash IDE are:

  • Drag XMLConnector, DataSet and DataGrid to stage and give it an instance names
  • Select XMLConnector and load XML file in Schema tab
  • Select DataSet and create binding with XMLConnector
  • Select DataSet and create binding with DataGrid
  • Use the trigger() method of XMLConnector

This works so far. But now doing this at runtime.

Creating the instances isn’t a problem. But I can’t find how to load the XML file in the Schema tab using ActionScript only. And I’m also not sure how to create the bindings. In the bindings examples I’ve read I see an event property, but I don’t have an event property when doing this in the Flash IDE.

Because of my trouble with this, I created all the components and also imported the XML file in the Schema tab, and wanted to only create the bindings using actionscript, but that still doesn’t work.

My code:

var src1:EndPoint = new EndPoint();
src1.component = xmlConProducten;
src1.property = "results.products.product";
var dest1:EndPoint = new EndPoint();
dest1.component = dsProducten;
dest1.property = "dataProvider";
var bndXmlDs:Binding = new Binding(src1, dest1);

var src2:EndPoint = new EndPoint();
src2.component = dsProducten;
src2.property = "dataProvider";
var dest2:EndPoint = new EndPoint();
dest2.component = dgProducten;
dest2.property = "dataProvider";
var bndDsDg:Binding = new Binding(src2, dest2);

bndXmlDs.execute(false);
bndDsDg.execute(false); 

My questions are:
Is it possible?
How do I create those bindings?
What is the AS equivalent of loading the XML file in the Schema tab?