0 Replies Latest reply on May 7, 2014 1:38 AM by martin-mi

    xmlui object doesnt seem to work properly. What am I doing wrong?

    martin-mi

      Hi,

       

      I created a javascript which loads up an UI in Flash. I would like to make a dropdown menu or a list, with a variable set of members. The items this dropdown list should depend on the selection made in another dropdown list.

       

      I can call functions in the ui on create and when the focus was changed, but I cannot edit the control elements in the ui because I can't get the fl.xmlui.getControlElement method to work as described in the API:

       

      To reproduce this I created the following XML exampleUI.xml:

      <dialog title="testDlg!" buttons="accept, cancel">
          <script>
              function fillList(){
                  var elem = new Object(); 
                  elem = fl.xmlui.getControlItemElement("menuItem0");
                  fl.trace("menuItem0 label = " + elem.label + " value = " + elem.value);
                  
                  var elem = new Object(); 
                  elem = fl.xmlui.getControlItemElement("testList");
                  fl.trace("testList label = " + elem.label + " value = " + elem.value);
                  
                  var elem = new Object(); 
                  elem = fl.xmlui.getControlItemElement("testLabel");
                  fl.trace("testLabel label = " + elem.label + " value = " + elem.value);
                  
                  var a = fl.xmlui.get("testLabel");
                  var b = fl.xmlui.get("menuItem0");
                  var c = fl.xmlui.get("testList");
                  fl.trace("testLabel = " + a + " menuItem0 = " + b + " testList = " + c);
              }
              
          </script>
          <grid>
              <columns>
                  <column />
                  <column />
                  <column />
              </columns>
              <rows>
                  <row align="center">
                      <menulist id="testList" control="testlist" label="bla" editable="true" oncreate="fillList()">
                          <menupopup>
                              <menuitem id="menuItem0" label="herp" value="derp"/>
                          </menupopup>
                      </menulist>
                      <textbox id="testLabel" value="John"/>
                  </row>
              </rows>
          </grid>
      </dialog>
      

       

      and the following javascript exampleJS.jsfl:

      var xmlUi = fl.getDocumentDOM().xmlPanel(fl.scriptURI + "/../exampleUI.xml");
      

       

      If I execute exampleJS

      the ui is started and the callback oncreate of the menulist is launched. This is the output of the fillList() function:

      menuItem0 label =  value = 
      testList label =  value = 
      testLabel label =  value = 
      testLabel = John menuItem0 = undefined testList = 
      

       

      I would have expected something like this:

      menuItem0 label = herp  value = derp
      testList label = bla value = derp//currently selected item
      testLabel label = testLabel value = John
      testLabel = John menuItem0 = derp testList = derp/*currently selected item*/
      

       

      I have no idea what I'm doing wrong. I would be very grateful for any kind of clue.

       

      cheers,

       

      Martin