Ultrashock Forums > Flash > Components
Runtime binding XMLConnector to DataSet

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
Runtime binding XMLConnector to DataSet
Old 2004-02-16

Hi there, can anyone help me to get this work? I have an XMLConnector (myXMLConnector) and a dataSet (myDataSet_ds). I can't get the data from the XMLConnector into myDataSet_ds, when I bind it at runtime? Nothing appears... if I bind it visually using the component inspector it works, but I need to be able to control it via actionscript. Thanks for any help, I am completely stuck!! Cheers, Matt.

XML SOURCE
PHP Code:
<?xml version="1.0" encoding="UTF-8"?>
<trips>
<trip name="Napa Valley">
        <description>The incredible variety of Napa Valley...</description>
        <cost>1095</cost>
        <tapes>2</tapes>
        <image>images/napa.jpg</image>
    </trip>
    <trip name="Big Sur">
        <description>From beaches to mountains...</description>
        <cost>1395</cost>
        <tapes>2</tapes>
        <image>images/bigsur.jpg</image>
    </trip>
    <trip name="Grand Canyon">
        <description>Located entirely in northern Arizona...</description>
        <cost>1111</cost>
        <tapes>1</tapes>
        <image>images/grandcanyon.jpg</image>
    </trip>
</trips>

FLASH SOURCE

ActionScript Code:
  1. import mx.data.binding.*;
  2.  
  3. myXMLConnector.URL = "data/trips2.xml";
  4. myXMLConnector.trigger();
  5.  
  6. var myResult = function (ev) {
  7.     dataBind();
  8. };
  9.  
  10. myXMLConnector.addEventListener("result", myResult);
  11.  
  12. function dataBind() {
  13.    
  14.    
  15.     var srcEndPoint = new mx.data.binding.EndPoint();
  16.     var destEndPoint = new mx.data.binding.EndPoint();
  17.    
  18.     // source
  19.     srcEndPoint.component = myXMLConnector;
  20.     srcEndPoint.property = "results";
  21.     srcEndPoint.event = "result";
  22.     srcEndPoint.location = "/trips/trip";
  23.    
  24.     // destination
  25.     destEndPoint.component = myDataSet_ds;
  26.     destEndPoint.property = "dataProvider";
  27.    
  28.     // create new binding
  29.     var myBinding:Binding = new Binding(srcEndPoint, destEndPoint);
  30.     myBinding.execute();
  31.    
  32. };
postbit arrow 5 comments | 964 views postbit arrow Reply: with Quote   
Registered User
matt247 is offline
seperator
Posts: 5
2003-10-02
seperator

Ultrashock Member Comments:
quest4 quest4 is offline 2004-02-18 #2 Old  
Did you find a solution matt?

I am having great difficulty trying to get Datagrid to refresh to bound xml connector during runtime also. Not much info at MM or elsewhere on net for this issue.

I have set up listener on the bound xml connector which broadcasts when connector receives new data from URL + trigger, but still unsuccessful in updating bound components.

Have also tried Binding.execute() without any success.

Anyone have any ideas? Any help will be much appreciated.
Reply With Quote  
matt247 matt247 is offline 2004-02-19 #3 Old  
Binding
No real luck yet! But, my location was not quite right and should have been:

srcEndPoint.location = "trips/trip";

This at least gets the data into the DataSet, but it goes in as a string (XML) rather than as an array. So I can't access the dataSet. It's frustrating enough to make me want to change jobs, right now...

I cannot find anything anywhere to help. The MM help files are all very well, but they don't take you through a proper and useful example from start to finish, if you want to script it.

I think I need to apply a custom formatter of some sort, but try following the help files to make it work! Impossible...

Matt
Reply With Quote  
quest4 quest4 is offline 2004-02-19 #4 Old  
Hi Again Matt,

I have resolved my problem and may be able to help you out.
In my situation I have used the component inspector to bind components. Then change the URL address (actually add var to php call) and trigger the xml connector. It all updates automatically.

As you are binding your components with actionscript only you may need to use the ComponentMixins class which will enable you to use the refreshDestinations or refreshFromSources methods which update all bindings from a source or to a destination. You may need to include the DataBindingClasses SWC from your Classes Library into your .fla Library if not present to enable the class code to compile.

Hope this helps.
Reply With Quote  
matt247 matt247 is offline 2004-02-19 #5 Old  
Hello chap,

You wouldn't believe it, but that's exactly what I was just working on! Exactly the very same thing - visually bind the DataSet to the XMLConnector, because as you say, we both know it works. Then change the URL to the Connector...

I haven't fully tested this yet, but I think it's probably the way to go - the more I think about it the more I like it.

The DataSet can sit on _level0 with all my script and everything that needs to can be bound to from anywhere else. I just need to make sure that I can get to the right data from myXML within the DataSet.

Let me know how you get on with this - you're dataGrid should be pretty good now? I'm going to work on this method over the next few days to test a few scenarios, and I'll let you know how it goes on this thread.

Nice work fella... it's good to have some feedback from someone! ;-)
Reply With Quote  
matt247 matt247 is offline 2004-02-22 #6 Old  
Hi quest4,

Do you know how to extract a complete XML file out of a DataSet object? I'm beginning to make some progress with all of the bindings, but I'd like to be able to export a complete XMl file rather than a deltapacket... any ideas?

Cheers,

Matt
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: