AS2 change the XML node button

Hello

I'm a training designer ACE. I would be grateful if someone can help me solve this code.  I need my flash application in order to move nodes for certain text fields and a movieclip that load images, when I click on one of the 6 simple buttons. Everything works except the part. How to change nodes? Can not find anywhere in websearch buttons change nodes, maybe it's called something else and not "switching nodes? Here is a part of the code that I can't solve, he begins to / / part of the PROBLEM. Thank you!

//-----------AS2

function loadXML(loaded) {
    if (loaded) {
    
        _root.locationX = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
        _root.nameX = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
        _root.emailX = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
        _root.image = this.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;

//loads text
        location_txt.text = _root.locationX;
        name_txt.text = _root.nameX;
        email_txt.text = _root.emailX;
//loads image   
        var url:String = _root.image;
        var movieClip:MovieClip = createEmptyMovieClip("movieClip", 0);
        movieClip.loadMovie(url);
        
    
// PROBLEM:  this BUTTON has to switch values to next node
  
menu1.onPress = function() {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
        _root.locationX = loadXML.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue;
        _root.nameX = loadXML.firstChild.childNodes[1].childNodes[1].firstChild.nodeValue;
        _root.emailX = loadXML.firstChild.childNodes[1].childNodes[2].firstChild.nodeValue;
        _root.image = loadXML.firstChild.childNodes[1].childNodes[3].firstChild.nodeValue;
}
menu2.onPress = function() {
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
        _root.locationX = loadXML.firstChild.childNodes[2].childNodes[0].firstChild.nodeValue;
        _root.nameX = loadXML.firstChild.childNodes[2].childNodes[1].firstChild.nodeValue;
        _root.emailX = loadXML.firstChild.childNodes[2].childNodes[2].firstChild.nodeValue;
        _root.image = loadXML.firstChild.childNodes[2].childNodes[3].firstChild.nodeValue;
}
/// ...etc. --- 6 simple buttons, so far it is not working


} else {
content = "file not loaded!";
}
}

+++ XML file: CDA to CDA, PLM button for button PLM, etc..

<?xml version="1.0" encoding="utf-8" ?>
<dots>
    <DATA>
          <location>Empty location</location>
          <name>Empty Name</name>
          <email>Empty email address</email>
          <image>Contacts/img/empty.jpg</image>

    </DATA>
    <CDA>
          <location>Annemasse - CDA M&T Team</location>
          <name>John Doe CDA</name>
          <email>[email protected]</email>
          <image>Contacts/img/img1.jpg</image>

    </CDA>
    <PLM>
          <location>Annemasse - PLM key user</location>
          <name>John Doe PLM</name>
          <email>[email protected]</email>
                    <img>Contacts/img/img2.jpg</img>

    </PLM>
    <CAD>
          <location>Annemasse - CAD key user</location>
          <name>John Doe CAD</name>
          <email>[email protected]</email>
                    <img>Contacts/img/img3.jpg</img>

    </CAD>
    <CAE>
          <location>Annemasse - CAE key user</location>
          <name>John Doe CAE</name>
          <email>[email protected]</email>
                    <img>Contacts/img/aimg4.jpg</img>

    </CAE>
    <PMT>
          <location>Annemasse - PMT key user</location>
          <name>John Doe PMT</name>
          <email>[email protected]</email>
                    <img>Contacts/img/img5.jpg</img>

    </PMT>
    <engineering>
          <location>Annemasse - ENGINEERING IS CONTACTS</location>
          <name>John Doe ENG</name>
          <email>[email protected]</email>
                    <img>Contacts/img/img6.jpg</img>

    </engineering>
</dots>

Use the movieclip buttons and load your xml only once file:

var movieClip:MovieClip = createEmptyMovieClip("movieClip", 0);

var xmlData:XML;
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;

xmlData.load (whatever.xml);

function loadXML() {
xmlData=this;

}

for(var i:Number=0;i<6;i++){  // assuming you have menu0,menu1,...,menu5

this["menu"+i].ivar=i;

this["menu"+i].onRelease=changeF;


function changeF(){


        _root.locationX = xmlData.firstChild.childNodes[this.ivar].childNodes[0].firstChild.nodeValue;
        _root.nameX = this.firstChild.childNodes[this.ivar].childNodes[1].firstChild.nodeValue;
        _root.emailX = this.firstChild.childNodes[this.ivar].childNodes[2].firstChild.nodeValue;
        _root.image = this.firstChild.childNodes[this.ivar].childNodes[3].firstChild.nodeValue;

//loads text
        location_txt.text = _root.locationX;
        name_txt.text = _root.nameX;
        email_txt.text = _root.emailX;
//loads image  
        var url:String = _root.image;
       
        movieClip.loadMovie(url);

}    

Tags: Adobe Animate

Similar Questions

  • How to change the Rectangles with buttons

    I'm working on this example that does not work correctly:

    public class test extends Application
    {
    
        private void init(Stage primaryStage)
        {
    
            Group root = new Group();
            primaryStage.setScene(new Scene(root));
    
            String pillButtonCss = DX57DC.class.getResource("PillButton.css").toExternalForm();
    
            // create 3 toggle buttons and a toogle group for them
            ToggleButton tb1 = new ToggleButton("Left Button");
            tb1.setId("pill-left");
            ToggleButton tb2 = new ToggleButton("Center Button");
            tb2.setId("pill-center");
            ToggleButton tb3 = new ToggleButton("Right Button");
            tb3.setId("pill-right");
    
            final ToggleGroup group = new ToggleGroup();
            tb1.setToggleGroup(group);
            tb2.setToggleGroup(group);
            tb3.setToggleGroup(group);
            // select the first button to start with
            group.selectToggle(tb1);
    
            //////////////////////////////////////////
    
            final VBox vbox = new VBox();
    
            final Rectangle rect1 = new Rectangle(300, 300);
            rect1.setFill(Color.ALICEBLUE);
            final Rectangle rect2 = new Rectangle(300, 300);
            rect2.setFill(Color.AQUA);
            final Rectangle rect3 = new Rectangle(300, 300);
            rect3.setFill(Color.AZURE);
    
            tb1.setUserData(rect1);
            tb2.setUserData(rect2);
            tb3.setUserData(rect3);
    
            group.selectedToggleProperty().addListener(new ChangeListener<Toggle>()
            {
                @Override
                public void changed(ObservableValue<? extends Toggle> ov, Toggle toggle, Toggle new_toggle)
                {
                    if (new_toggle == null)
                    {
                        //rect.setFill(Color.WHITE);
                    }
                    else
                    {
                        vbox.getChildren().addAll((Node[]) group.getSelectedToggle().getUserData());
                        //rect.setFill((Color) group.getSelectedToggle().getUserData());
                    }
                }
            });
    
    
            ///////////////////////////////////////////
    
    
            HBox hBox = new HBox();
            hBox.getChildren().addAll(tb1, tb2, tb3);
            hBox.setPadding(new Insets(20, 20, 260, 20));
            hBox.getStylesheets().add(pillButtonCss);
    
    
    
            vbox.getChildren().add(hBox);
            //vbox.getChildren().add(rect);
    
            root.getChildren().add(vbox);
        }
    
        @Override
        public void start(Stage primaryStage) throws Exception
        {
            init(primaryStage);
            primaryStage.show();
        }
    
        public static void main(String[] args)
        {
            launch(args);
        }
    }
    
    
    

    I want to create several Rectangles (or in which object or object) in which I want to store data. I want to spend the Rectangles (objects) that appear in front of the user by using the buttons. The example that I put in place does not work correctly. Can you tell me what is the right way to implement this?

    REF javafx 2 - How to change the Rectangles with buttons - stack overflow

    You have two problems:

    User data that assign you to each button switches are a node, not a [Node]. Thus, the cast will fail on line 43.

    When the selected toggle changes, you add another Rectangle to the vbox. You want to replace the rectangle that is in the vbox.

    Try

    vbox.getChildren () .setAll ((Node) group.getSelectedToggle () .getUserData ());

  • No idea how to loop and add the value to the attribute of the xml node?

    I work on a lot of flattening of project using a watched folder.

    I have a process parent to locate the directory and call a sub-process to flatten PDF files.

    I want to write the directory failed to XML.

    If there are several directory failed locations and if I want to add it to the node, he doesn't let me do.

    If I set the Xpath location like/process_data/outputXML/flattenDirectoryRequestMessage/failureFileLocation[x]/@path it gives me invalid character exception. I use 'x' for looping and incrementing.

    If I do not use the [x]. The directory is overwritten.

    No idea how loop and add all the directories failed to attribute of the xml node?

    I understand that you can not browse the xml code to assign the value at each node. Rather you can assign only one time to the node.

    I realized that it is not possible to do it this way. Then concatenate it as strings, and then attach to the xml once.

  • How to set the value of the xml node.

    Hello

    I have the PDF application can be entered by the user using the key. When sending

    I use following code to set the value of the xml node.

    XFA. Data.assignnode ("Employee.ID", "123", 0):

    If its generators of xml as below.

    < employee >.

    < id > 123 / < ID >.

    < / name >

    < / employee >

    Now, I need to generate xml as below.

    < employee id = '123' >

    < / name >

    < / employee >

    So, how together create the id of node as above?

    Thanks in advance.

    Kind regards

    Dhiyane

    Hi Dhiyane,

    You must set contains the property if the node id to "metadata", i.e.;

    xfa.data.assignNode ("employee.id", "123", 0);
    XFA. Data.Employee.ID.Contains = 'metadata ';

    Very awkward, if you have a number of them, in which case you might want to look at using E4X.

    Good luck

    Bruce

  • Downsaving to CS2 to CS4 - how to change the XML declaration

    I am under CS4 and am trying to downsave a CS4 CS2 file.  After a Google search, I found this page http://indesignsecrets.com/double-downsave.php that recommend this following:

    "I open the INX file and changed the XML declaration: .

    <? using style = "33″ type is 'document' DOMVersion is" 6.0 readerVersion = "5.0″ featureSet =" product = 257″ "6.0 (352)" "?" >

    TO:

    <? using style = "33″ type is 'document' DOMVersion is" 5.0″ readerVersion = "4.0″ featureSet =" product = 257″ "5.0 (662)" "?" >

    In other words, I have said my file from version 5 (aka CS3) CS2 and that can be read by version 4 (CS2). I changed the attribute 'product' to start, just in case CS2 sought also to this. »

    If I understand his instructions, I am to export the CS4 document in INX CS3 document, and then open that INX doc with a text editing program and edit the text as shown above.  After exporting to INX, I opened in Word and looked for ' <? aid' and it is nowhere in the many pages of text.

    I have also exported the CS4 one doc XML, but have had no success in finding this specific line.  What mistake I have done?


    Thanks in advance for helping this newbie!

    -Laura

    Word is not a text editor, it is processing. Open it in Notepad.

    Bob

  • How to change the xml link?

    First a few words about my background:

    I got a page on a version of InDesign CS3 layout. Now, I'm creating a procedure to automate the production of several pdf based on this provision. Manually process would be to open the page layout; change the xml with each xml source link and create a file pdf corresponding...

    First question:

    In CS4 when I want to manually edit the xml link, the open dialog box prevents me (xml files are grey) to select xml files, it is a well known problem? How can I avoid it?

    Second question:

    How to change the script xml link?

    Last question - applescript question -:

    How to skip application dialog boxes? As "this document is missing a few links, would continue you?

    If you want to be able to help me, thanks in advance!

    There is a piece of code found on the net:

    tell document 1 of application "Adobe InDesign CS3"relink thisItemLink to someFileReferenceupdate thisItemLinkend
    
  • change the color to buttons

    Hello

    I have a series of buttons placed side by side. I'm changing the focus from one button to another using the navigation keys. Now the problem is the update is not clearly visible. Is there a possibility to do?

    I had an idea to use the option of color change, when the focus is on a button changes color to some specific color and the rest in a few other specific colors. But I am not able to implement clearly. so please give me an idea...

    Thanking you,

    sushmith

    If you want to change the color of a button, you must watch what kind of button that you use.  Not all the buttons can have their changed colort.

    If you are looking for a professional to look at it, you don't want to do a colorbook either by changing each button in a different color.

    What you can do is put behind each button an LED indicator that is slightly larger then the button itself.

    When the button has the focus, set the indicator.  And it will turn on.

    It's a little more work, but it looks so much nicer.

    Personally, I don't like to mess with colors.  I like the simplicity.  That's why I use systembuttons, who already have a blue surface when they have developed

    Hope this helps

  • change the vista sleep button to stop the function

    I use win vista and I want to change the button to stop the sleep function

    Please help me in this matter.

    Thanks to you all

    I use win vista and I want to change the button to stop the sleep function

    Please help me in this matter.

    Thanks to you all

    They are 2 different applications. You do not change them. Just add what you don't have.
    Here is the tutorial to show you how to add the option stop. Use method 2. It is easier.
    http://www.Vistax64.com/tutorials/105003-shutdown-options-start-menu.html

    t-4-2

  • How can I change the mouse selection button?

    Until you tell me to go to start > Control Panel > mouse > change main selection button, let me tell you that this version of Windows 7 Home Premium doesn't have this option. I'm left-handed. I want to change the home button, so I can use my wireless logitech left-handed mouse. When I go into the properties of the mouse settings, see tabs that say "pointer, wheel, material, activities, Dell Touchpad Options (I have an Inspiron N5110), mouse and keyboard Center.» On any of these, are at - it button to select or deselect "Change primary mouse button", as it is on all other versions of Windows. It's so frustrating.

    I'm the original poster. I solved my problem by buying a new Microsoft wireless mouse. Of course the old wireless mouse Logitech I was using was incompatible with Windows 7.

  • How to change the color of button

    I can create a newBrush to change the backgroundColor container, but I want to know how to change the color of the button?

    I posted here an example on how to change the color of the button here:

    Re: ScriptUI resource string: EditText: color

  • Remove the XML node

    Dear adobe experts,

    I have a requirement to remove a node in the XML interface of a form of adobe (not only by removing a subform in the form). It must be a deletion, an empty node does not work (I read this in another post).

    The XML structure looks like this:

    < ITEM >

    < DATA >

    < ROW_IID > 0 < / ROW_IID >

    < PARENT > 0 < / PARENT >

    < CHILD > 0 < / CHILD >

    < / DATA >

    < DATA >

    < ROW_IID > 1 < / ROW_IID >

    < PARENT > 0 < / PARENT >

    < CHILD > 0 < / CHILD >

    < / DATA >

    < / ITEM >

    I want to, for example, to remove the second node of data including the underlying elements: row_iid, parent & child. Already tried: xfa.record.nodes.remove (oRemoveNode); I got it from http://partners.adobe.com/public/developer/en/xml/Adobe_XML_Form_Object_Model_Reference.pd f and several messages in this forum, but I get the following message appears in the error console: remove failed. I know that the somexpression is correct.

    Here's the code I used to try to remove the node.

    var node_loc;

    var del_node;

    [node_loc = ' xfa.record.ELEMENT.DATA [1 '];

    del_node = xfa.resolveNode (node_loc);

    xfa.record.Nodes.Remove (del_node);

    Anyone know what I am doing wrong?

    Kind regards

    Niels

    Hi Steve,.

    I fixed it myself. I adjusted my code a little, so the node, including the elements is successfully deleted.

    Here is the way that I fixed it:

    var node_loc;

    var del_node;

    [node_loc = ' xfa.record.ELEMENT.DATA [1 '];

    del_node = xfa.resolveNode (node_loc);

    xfa.record.ELEMENT.nodes.remove (del_node);

    Thanks for the help!

    Kind regards

    Niels

  • Change the color of button in the Page of the OFA

    Hello

    I need to change the button color for a specific custom OPS page.
    Can someone please provide me with step by step instructions on the same.

    Thank you
    Arun...

    Arun,

    Using custom Css, you can get your condition.

    See http://gyanoracleapps.blogspot.com/2011/02/using-inline-custom-css.html of use of it.

    Kind regards
    GYAN

  • CS3 AS2 - changing the fill color

    Hello!

    I don't know how to change the color of the movieclip but I can't find a way to change just the fill color of the movieclip and no hits... is this possible?

    I guess that there are several ways to do so.  I could change just the filling of an MC is to select only the filling and convert it to a symbol.  After giving your new symbol to an instance name, you can reference it in AS2 to change its color. I hope this helps.

  • CSS is not change the XML file

    I'm working on the example attached when trying to get my css to change the color of my xml links. Despite making it than the forums, you should say, this isn't working. What I am doing wrong? Thank you

    <? XML version = "1.0" encoding = "ISO-8859-1? >
    <? XML-stylesheet type = "text/css" href = "style.css"? >

    This should be:

    function loadXML (loaded) {}
    If {(responsible)
    _root. Inventor = this.firstChild.childNodes [0] Sublst.ChildNodes(1).ChildNodes(0) [0].firstChild.nodeValue;
    _root.comments = this.firstChild.childNodes [0] Sublst.ChildNodes(1).ChildNodes(0) [1].firstChild.nodeValue;
    name_txt. Text = _root.inventor;
    comment_txt.htmlText = _root.comments;
    } else {}
    trace ("file not loaded!");
    }
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;

    var myCSS = new TextField.StyleSheet ();

    myCSS.load ("style.css");

    Set the onLoad handler
    myCSS.onLoad = {function (success)}
    If (success) {}

    name_txt. StyleSheet = myCSS;
    xmlData.load ("inventors.xml");

    } else {}
    name_txt. Text = "failed to load CSS file!"
    }
    }

  • Problem with to access the XML nodes whose namespace

    Hello
    I have a XML file with the following format;

    "" "" "< graphml version ="1.3"xmlns =" http://graphml.graphdrawing.org/xmlns/graphml ' xmlns:y = ' http://www.yworks.com/xml/graphml ' xmlns: xsi = " http://www.w3.org/2001/XMLSchema-instance" > "

    < graph id = 'G' edgedefault 'ordered' = >

    < key data 'd11' = >
    < y: SharedData >
    < name there: Brush = "SolidBrush" color = "Black" id = "1" / >
    < / y: SharedData >
    < / data >

    < node id = "G:n0" >
    < y: Labels >
    < y: Text > <! [CDATA [start]] > < / Text: y >
    < / y: Labels >
    < / node >

    < node id = "G:n1" >
    < y: Labels >
    < y: Text > <! [CDATA [end]] > < / Text: y >
    < / y: Labels >
    < / node >

    < / chart >

    < / graphml >


    I access this file as < mx:XML id = "layoutXml" source = "tmp.xml" / > "

    I have no application debugging and found that the layoutXml object contains the xml file as it is. Now when I try to access any child node of layoutXml, every time I found null. Same instruction layoutXml.graph.toXMLString () or layoutXml.graph.toString () returns null.

    I have tryied the following approach as well, but did not work,
    var nameSpace:Namespace = new Namespace (" http://www.yworks.com/xml/graphml");
    var str:String = layoutXml.graph.node. (@id == ' G:n0").nameSpace::Labels.nameSpace::Text.toXMLString();")
    also, this property returns null.

    If anyone has the solution, please answer.

    Thank you.

    Namespace var sets default namespace:
    lack of namespace xml = nameSpace;

    You should then be able to reference nodes normally.

    Tracy

Maybe you are looking for