Load and Send XML values

I am new to ActionScript 3 and have a project I would like to get some help on. I have an XML file on a server that has two types of parent nodes... an example is below:
<bodytypesuggestions>
<ID1>36</ID1>
<ID2>34</ID2>
<ID3>37</ID3>
</bodytype>
<bodytypes>
<ID1>34</ID1>
<ID2>32</ID2>
<ID3>35</ID3>
</bodytype>
The AS code below connects my flash to the URL:
import flash.net.*;
import flash.events.*;
var myXML:XMLList;
var url:URLRequest = new URLRequest("MYSERVER.COM");
var XMLLoader:URLLoader = new URLLoader(url);
XMLLoader.addEventListener(Event.COMPLETE, GetRecommendations);
XMLLoader.addEventListener(Event.CHANGE, updateAndGetRecommendations);
function GetSuggestions(event:Event):void {
if (XMLLoader.data) {
myXML = XMLList(XMLLoader.data);
var myDev:XMLList = new XMLList(XMLLoader.data)
var bodytypelist:XMLList = myDev..bodytypes
var bydytypesugglist:XMLList = myDev..bodytypesuggestions
trace(bodytypelist);
this["ID1"].text = bodytypelist.ID1;
this["ID1"].restrict = "0-9.";
this["ID1"].maxChars = 5;
this["ID2"].text = bodytypelist.ID2;
this["ID2"].restrict = "0-9.";
this["ID2"].maxChars = 5;
this["ID3"].text = bodytypelist.ID3;
this["ID3"].restrict = "0-9.";
this["ID3"].maxChars = 5;
Now in my flash file, I have 3 textInput fields that are populated with the above XML values from the bodytype child values.
My question is - how can I write a function that when a user changes a value in any one of the text fields, the data returned is from the bodytypesuggestions node value instantly, i.e. once a field value is changed, the other two will change accordingly. The actual XML on the server already handles those calculations. I hope this makes sense, I really need some help on this one.

I am not 100% certain what you're asking for here...
I would tend to send XML rather than an XMLList string. I can't get the e4x filtering to work for an XMLList like that, which means (I assume) that you would need to iterate the list and using filtering on each XML object in the list. Perhaps I've missed something as you don't seem to be expressing a problem with loading the xml data and getting it into the textfields initially. I've not tried using the filtering on an XMLList directly before but could not get it working the way you have it. So in the following simulation I have wrapped the list in a top level tag to get it working the way I wanted.
Here is a non-loading simulation of what you seem to want. The difference here is that the GetSuggestions 'listener' is called manually with the data string rather than by the URLLoader's listener with the data attached to the URLLoader's dispatched event.
Hope that helps some.
var xStr:String="<bodytypesuggestions><ID1>36</ID1><ID2>34</ID2><ID3>37</ID3></bodytypesuggestions><bodytypes><ID1>34</ID1><ID2>32</ID2><ID3>35</ID3></bodytypes>";
var myXML:XML;
var suggestions:XMLList;
//requires 3 input textfields on the stage named ID1, ID2, ID3
function GetSuggestions(data:String):void {
if (data) {
var myXML:XML = XML("<wrapper>"+XMLList(data).toXMLString()+"</wrapper>");
var bodytypelist:XMLList = myXML..bodytypes;
suggestions = myXML..bodytypesuggestions;
ID1.text = bodytypelist.ID1;
ID1.restrict = "0-9.";
ID1.maxChars = 5;
ID2.text = bodytypelist.ID2;
ID2.restrict = "0-9.";
ID2.maxChars = 5;
ID3.text = bodytypelist.ID3;
ID3.restrict = "0-9.";
ID3.maxChars = 5;
GetSuggestions(xStr)
ID1.addEventListener(Event.CHANGE,myTextListener)
ID2.addEventListener(Event.CHANGE,myTextListener)
ID3.addEventListener(Event.CHANGE,myTextListener)
function myTextListener(e:Event):void{
     var updates:Array = ['ID1','ID2','ID3'];
     //check to see if current value is recognized
     if (TextField(e.currentTarget).text == suggestions.elements(TextField(e.currentTarget).name).text()){
          trace('found match')
          for each(var fieldName:String in updates){
               if (TextField(e.currentTarget).name==fieldName) continue;
               TextField(this[fieldName]).text = suggestions.elements(fieldName).text();
               trace(' set '+fieldName + ' to '+TextField(this[fieldName]).text)

Similar Messages

  • Problem with  whitespace  then loading and saving xml

    i do not know how to handle this problem. i modifed a texteditor to send XML to a server and load XML back to the container.
    but then i do changes to the Textlayout it shows up like this --->
    Text in Container not modifed
    Text in Container modifed ---> with space beween the colorchanged string
    Text inContainersend and loaded ---> i think this has something to to with the
    TextFilter.export(_textFlow,TextFilter.TEXT_LAYOUT_FORMAT,ConversionType.XML_TYPE)
    can someone give me a hint...

    Hi,
    the link is --->
    http://www.horstmann-architekten.de/contentmanagment/SimpleEditor.html
    its a modified example of the texteditor provided by Adobe. You can send a xml to the server. and also read it from the server. You just use the xml identifer to give the xml a name.
    Try it out:
    1.  change the text and
    2.  give a XML-Identifer
         and then send it to the server. --> send to server
    3.  type in the XML-Identifer you have used and
    4.   load it from the server ---> Load from Server Button
    evering works ok exept the columns formating.
    I Think the colums Formating is not embeded in the XML as it should be. I attached the Files. (Newbie programmer)
    With best regards
    Michael Sprinzl
    --- robin.briggs <[email protected]> schrieb am Do, 17.9.2009:
    Von: robin.briggs <[email protected]>
    Betreff: Problem with  whitespace  then loading and saving xml
    An: "Michael sprinzl" <[email protected]>
    Datum: Donnerstag, 17. September 2009, 2:12
    Sounds like you have two different issues going on: (1) inline graphics aren't coming out correctly when you use the TextLineFactory, and (2) columns aren't working correctly. It's difficult for me to tell by looking at the application you link what is going wrong. One of the examples does seem to have columns working -- can you be more specific about what you're doing, and what results you are seeing? As for the inline graphics, there is a timing issue involved with using URLs, due to the asynchronous loading. See this comment in the docs for TextFlowTextLineFactory:
    Note: When using inline graphics, the source property of the InlineGraphicElement object   must either be an instance of a DisplayObject or a Class object representing an embedded asset.   URLRequest objects cannot be used. The width and height of the inline graphic at the time the line   is created is used to compose the flow.
    - robin

  • Loading and viewing XML when a class object is created..Help Please

    Hello,
    I have writing a simple class which has a method that gets invoke when the object of the class is created. I am able to view the loaded XML content when I trace it with in my class method, but cannot assign the content to a instance variable using the mutator method. So the process goes like this:
    Class object is instantiated
    Class construtor then calls the loadXML method which laods the XML
    And then assigns the XML to a class instance variable.
    So now if I would like to access the loaded XML through class object, I should be able to see the loaded xml content which I am not able to see. I have spent over few hours and cannot get the class object to display the loaded XML content. I would highly appreciate it if someone can help in the right direction, please.
    [code]
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        public class Cars extends MovieClip {
               public var _CarList:Object;
               public function Quiz()
                  super();
                  loadCars();
    // ===========================================================
    //           CARS GETTER SETTER
    // ===========================================================
            public function set Cars(val:XML):void
                this._CarList = val;
            public function get Cars():XML
                return this._CarList;
    // ===========================================================
    //            LOAD QUESTIONS FROM XML
    // ===========================================================
            public function loadcars()
                var myXML:XML;
                var myLoader:URLLoader = new URLLoader();
                myLoader.load(new URLRequest("xml/cars.xml"));
                myLoader.addEventListener(Event.COMPLETE, processXML);
                function processXML(e:Event):void
                    myXML = new XML(e.target.data);  
                    Cars = myXML;                 // Assigning the loaded xml data via mutator method to the _CarList;
    //=============================================================  
                                  INSTANTIATING THE CLASS OBJECT
    //=============================================================
    package com.as3.app
        import flash.display.*;
        import flash.events.*;
        import flash.text.*;
        import flash.net.*;
        import com.as3.app.*;
        public class DocumentClass extends MovieClip {
            public var c:Car;
            public function DocumentClass()
                super();
                c = new Cars();  
                trace(c.Cars);
    [/code

    where you have:
                super();
                c = new Cars();  
                trace(c.Cars);
    c.Cars will not trace as the loaded xml, because it will not have loaded in time. After some time it should presumably have the correct value.
    loading operations in actionscript are asynchronous, so your nested function which is acting as the listener ( function processXML(e:Event):void) only ever executes when the raw xml data has loaded and that is (I believe, not 100% sure) always at least one frame subsequent to the current one.
    In general I would consider it bad practise to use nested functions like that, but I don't think its contributing to your issues here. I think its just a timing issue given how things work in flash....
    Additional observation:
    your Cars constructor calls loadCars() and your loadCars method is defined as:
    public function loadcars()
    I assume its just a typo in the forum that the uppercase is missing in the function name....

  • Loading and parsing XML files

    I am currently working on an application in which I have a XML file that is 1.5 mb and has 1100 records that I need to load and parse. Loading takes less than a minute, but when I try to parse it with the DOM parser it's taking too much time. I am trying to put it into an array and then display it as if I'm tied to a database. I need a different approach. Does anyone have any experience and insight with the DOM parser? Would the SAX parser be a better way to go, why and how?

    You can use SAX... but SAX is good only if you want to read the data once.
    If you want to use the same data again and again then you might have to parse the file again... which prooves expensive.
    DOM will take too much of memory and CPU time.
    Have you tried using JDOM ? it is a new kind of a XML parsing utility that is quite lightweight and has good api to recurse the JDOM tree also.
    check it out at
    http://www.jdom.org.
    hope this helps.
    regards,
    Abhishek.

  • Adobe LiveCycle Designer and send XML

    Dear all,
    I have developped a PDF with Adobe LiveCycle Designer  that send an XML file to BW using a button Submit. But this PDF works when executed from the Adobe LiveCycle Designer software (tabpstrip PDF preview) but does not work when it is executed standalone (no logon asked.. )
    Do you have some ideas to solve this problem ?
    Regards,
    Vince

    Hi Nitesh,
    I have installed ADL standalone on my pc.
    When I execute my PDF from ADL it works : I click on a button and a logon screen on a SAP system is shown (like access on web report), I fill it and the XML file is sent and shown through RSA3 transaction.
    But when I launch the PDF alone, I get an error message when I clik on the same button : 'HTTP 401 - Unauthorized'.
    Do you have another clue ?
    Regards,
    Vince

  • Loading and unloading xml galleries

    I have a several galleries that I will be loading via several xml files.  Gallery1 will load on start and the other galleries will load through buttons using their instance names (i.e. "gallery3" button will load "gallery3.xml").  Currently I have a function + listener (called "home") to initiate gallery1 on start, a function + listener (called "goSection") to initiate the other galleries via button instance name, and a function that loads the gallery (called "fileLoaded") with the listener located in the "home" and "goSection" functions.  There is a lot more code in the fileLoaded function that controls the thumbnail and full size images functionality that I am excluding because its probably not necessary for my problem.  Im not sure the most efficient way to set this all up so I unload the existing gallery before I load a new gallery.  Ive tried to use removeChild and removeEventListener on urlLoader without much success.  Any suggestions?  ...
    //BUTTONS
    var sButtons:Array = [gallery1,gallery2,gallery3,gallery4];
    function sButtonsListeners():void {
         for (var i:uint = 0; i < sButtons.length; i++) {
         sButtons[i].addEventListener(MouseEvent.CLICK, goSection);
    sButtonsListeners();
    var urlLoader:URLLoader = new URLLoader();
    //INIT HOME
    function home():void {
         trace("gallery1 loaded");
         //load external xml
         var urlRequest:URLRequest = new URLRequest("gallery1.xml");
         urlLoader.load(urlRequest);
         urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    home();
    //GO SECTION
    function goSection(event:Event):void {
         trace(instanceName + " loaded");
         var instanceName:String = event.currentTarget.name;
         //load external xml
         var urlRequest:URLRequest = new URLRequest(instanceName + ".xml");
         urlLoader.load(urlRequest);
         urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
    function fileLoaded(event:Event):void {
         var myXML:XML = new XML();
         var xmlList:XMLList;
         myXML.ignoreWhitespace = true;
         var arrayURL:Array = new Array();     //thumbnails
         var arrayName:Array = new Array();     //large photos
         var holderArray:Array = new Array();     //thumbnail holder
         var thumb:Thumbnail;     //represents Thumbnail.AS
         //represents the gallery container
         var sprite:Sprite = new Sprite();
         addChild(sprite);
         //thumbnail container
         var thumbsHolder:Sprite = new Sprite();
         sprite.addChild(thumbsHolder);
         //image container
         var imageHolder:Sprite = new Sprite();
         sprite.addChild(imageHolder);
         //load image
         var imageLoader:UILoader = new UILoader();
         imageLoader.buttonMode = true;
         imageHolder.addChild(imageLoader);
         myXML = XML(event.target.data);
         xmlList = myXML.children();
         for (var i:int=0; i<xmlList.length(); i++) {
         var picURL:String = xmlList[i].url;
         var picName:String = xmlList[i].big_url;
         arrayURL.push(picURL);
         arrayName.push(picName);
         holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
         holderArray[i].name = arrayName[i];
         holderArray[i].buttonMode = true;
         holderArray[i].y = 25;
         holderArray[i].x = i * 87 + 142;
         thumbsHolder.addChild(holderArray[i]);

    Anyone?  My biggest concern is unloading the existing gallery before I load a new one.  Currently they load on top of each other.

  • Loading and parsing XML

    what is the best method for loading external XML (with
    inherent HTML) content into Flash and into the TextArea component?
    here is the requirement:
    i have an image loader and a TextArea together on the screen.
    a "story" is loaded which will present a series of images (in the
    image loading) associated with a corresponding text (in the
    TextArea). a "story" has multiple image/text sections that are
    navigatied through with FRWD/BACK buttons. any given section can
    also have multiple sub-sections or "frames".
    here is a diagram of the flow (in this case there would be 5
    click throughs: 5 text/image sequences, but all contained only
    within 4 sections):
    http://jalaka.com/lab/ia/story_nav.jpg
    below is my proposed sample XML structure. i want Flash to
    recognize how many sections and frames within sections there are in
    each story XML document - in order to generate a corresponding
    navigation structure (a tab for each section). HTML content will be
    immediate availble to loadinto TextArea as user move forward in
    sequence with nav. and images references can also be preloaded into
    available MC containers to be swapped into place as user navigates
    forward in sequence. also need to read and store attributes for
    each node in the XML to come up in MCs in sequence. and must also
    be able to parse XML in a way to place simple HTML formatted
    content (within XML) into the TextArea.
    would Arrays be used?
    <story title = "Story Title">
    <section num = "1" title = "Section One Title" >
    <frame image = "1.jpg" caption = "caption text
    here"><b>Content</b><br><br>content
    content content</frame>
    </section>
    <section num = "2" title = "Section Two Title" >
    <frame image = "1.jpg" caption = "caption text
    here"><b>Content</b><br><br>content
    content content</frame>
    <frame image = "2.jpg" caption = "caption text
    here"><b>Content</b><br><br>content
    content content</frame>
    </section>
    </story>

    Placing the XML into an array is a great plan. What you want
    is each array element to be an object containing the section data.
    Another plan is to use a List or Combox component. Again each
    data property element would be an object containing the section
    data.

  • How to create and send clob value to SP?

    Hi,
    Does any one of an example of how to create and send
    a clob value(as a IN parameter to storedprocedure) from JAVA to
    the StoredProcedure. I need the JAVA code.
    null

    Hi 
    Following is sample code you can use.
    DECLARE @testID Int
    DECLARE @year int 
    DECLARE @testtype datatype
    SELECT @testtype=testtype from yourTable Where Your condition
    SELECT  @year= year from yourTable Where your conditon (you need to make sure you assign or get @year variable )
    SELECT @testid=id from test where  year=@year and testtype=@testtype)
    Hope this helps
    Regards

  • Receive and Send XML files

    I have a requirement, to receive XML files from a Vendor, process them and send them back an XML file.
    What are the different way I can receive the files from the Vendor ?
    They do not support File Transfer Protocol and They do not want to access any web-service that we create for them to post the XML's ?
    What technology do I use to get the files, I was told we can use HTTP.
    Please let me know
    Thanks

    Timo,
    Thanks for your reply, the technology stack we are using is Oracle Middleware,
    The process of uploading the documents should be automatic , so I need to give the Vendor an URL, where they can post the XML documents.
    If I use a web-service, will that be having any URL for the vendor to post ? and I suppose I have to make that web-service open in the internet. ?

  • Load and Read XML file size more than 4GB

    Hi All
    My environment is Oracle 10.2.0.4 on Solaris and I have processes to work with XML file as below detail by PL/SQL
    1. I read XML file over HTTP port into XMLTYPE column in table.
    2. I read value no.1 from table and extract to insert into another table
    On test db, everything is work but I got below error when I use production XML file
         ORA-31186: Document contains too many nodes
    Current XML size about 100MB but the procedure must support XML file size more than 4GB in the future.
    Belows are some part of my code for your info.
    1. Read XML by line into variable and insert into table
    LOOP
    UTL_HTTP.read_text(http_resp, v_resptext, 32767);
    DBMS_LOB.writeappend (v_clob, LENGTH(v_resptext), v_resptext);
        END LOOP;
        INSERT INTO XMLTAB VALUES (XMLTYPE(v_clob));
    2. Read cell value from XML column and extract to insert into another table
    DECLARE
    CURSOR c_xml IS
    (SELECT  trim(y.cvalue)
    FROM XMLTAB xt,
    XMLTable('/Table/Rows/Cells/Cell' PASSING xt.XMLDoc
    COLUMNS
    cvalue
    VARCHAR(50)
    PATH '/') y;
        BEGIN
    OPEN c_xml;
    FETCH c_xml INTO v_TempValue;
    <Generate insert statement into another table>
    EXIT WHEN c_xml%NOTFOUND;
    CLOSE c_xml;
        END
    And one more problem is performance issue when XML file is big, first step to load XML content to XMLTYPE column slowly.
    Could you please suggest any solution to read large XML file and improve performance?
    Thank you in advance.
    Hiko      

    See Mark Drake's (Product Manager Oracle XMLDB, Oracle US) response in this old post: ORA-31167: 64k size limit for XML node
    The "in a future release" reference, means that this boundary 64K / node issue, was lifted in 11g and onwards...
    So first of all, if not only due to performance improvements, I would strongly suggest to upgrade to a database version which is supported by Oracle, see My Oracle Support... In short Oracle 10.2.x was in extended support up to summer 2013, if I am not mistaken and is currently not supported anymore...
    If you are able to able to upgrade, please use the much, much more performing XMLType Securefile Binary XML storage option, instead of the XMLType (Basicfile) CLOB storage option.
    HTH

  • Loading and saving xml in coldfusion

    I'm pretty new to Flex and am trying to save a modified xml
    file to disk using coldfusion. I have figured out how to load the
    xml file into a Flex and modify it with various components, have
    tried to save it back to the server using <cffile>, but the
    file is empty. How do I extract the xml object that is sent back to
    CF from httpservice so I can save the flat xml file again?
    I'm sure the answer is simple but I just haven't found an
    easy tutorial to follow....

    I'm pretty new to Flex and am trying to save a modified xml
    file to disk using coldfusion. I have figured out how to load the
    xml file into a Flex and modify it with various components, have
    tried to save it back to the server using <cffile>, but the
    file is empty. How do I extract the xml object that is sent back to
    CF from httpservice so I can save the flat xml file again?
    I'm sure the answer is simple but I just haven't found an
    easy tutorial to follow....

  • AS 2.0 class  to load and access xml

    I am trying to use a Flash actionscript File to load a xml
    document and to then be able to use functions with in the class to
    access the xml. I tried using a hack found here
    http://www.bit-101.com/blog/?p=496
    but with no joy. any thoughts ?

    Well, it's pseudo code. You need to change your own class to
    implement the example. What it boils down to is:
    //use the Delegate class
    import mx.utils.Delegate;
    //assign a function (class member) to the onLoad event of
    your xml object
    your_xml_object.onLoad=Delegate.create(this,onLoad);
    //write a function (in the pseudo code I simply use onLoad
    for the name of the function)
    private function onLoad(success:Boolean):Void{
    if(success){
    //do stuff here with the xml data
    } else {
    trace("Something went wong");
    That's it.

  • Creating a filter and Sending default value to it using designer on SAP BW

    Hi All,
    Data Source: SAP BW
    BI Layer: BO 3.1
    Here goes my question:
    We have a cube which contains HR related data. I want to query data in such a way that it gets me data for the current month and year. The time dimension contains a hierarchy called Calendar Year/Month which has values u201CFEB 2009u201D, u201CMAR 2009u201D and so on. I want to create a WebI Report which should take Current month as MAR (since current month is March) and Current Year as 2009 and pass u201CMAR 2009u201D to the query without useru2019s intervention so basically itu2019s a default value. Similarly, when the month and year changes, this value should reflect the new values (i.e. APR 2009 when April 2009 arrives).The final outcome should be a dashboard displaying information using WebI Report.
    Kindly guide me step by step if there is a possible way to achieve it on SAP BW (OLAP datasource) using BO Universe designer/WebI and by using MDX wherever necessary.
    Otherwise, is there a possibility of creating Filter in Universe which takes something like Month(Current Date) and Year(Current Date), append them and pass it as a parameter to BW cube;  If yes, how?
    Kindly guide

    Couple of things, first you need to make sure you assign navigation for the buttons, which is why the remote control on the DVD Player did not work, yet you can mouse over in the computer [Assign Navigation|http://dvdstepbystep.com/buttons07.php] and [a thread|http://discussions.apple.com/thread.jspa?messageID=9134310&#9134310]
    As to overlays, buttons will not appear (the highlights) until the loop point of the menu, but if ellements are in the background (video) then they will appear. If you do not want those items (in the background) to appear to the loop point you need to fade it in or otherwise do whatever effect you want in the background video. [Motion Example|http://dvdstepbystep.com/motion.php]

  • Is it possible to load and send variables to php at the same time?

    Hello, with this line:
    request.method = URLRequestMethod.GET; you can receive
    variables from php.
    and with request.method = URLRequestMethod.POST you can send
    variables.
    But is it possible to do this simultaniously ?

    they both send and receive data sequentially. ie, data is
    sent (if there is any) and then data is received (if there is
    any).

  • Load  and save multi value checkbox value  dynamically to the table

    How to retrieve data for multi value checkbox ?

    See this example for handling of any multiselection item in APEX:
    https://apex.oracle.com/pls/apex/f?p=31517:84
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.apress.com/9781430235125
    https://apex.oracle.com/pls/apex/f?p=31517:1
    http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
    -------------------------------------------------------------------

Maybe you are looking for