2 Replies Latest reply on Mar 4, 2007 5:49 PM by MacKeith

    Help needed!

      I have a problem. I wish you could help me with this.
      I have php script which returns me something like this:

      <name>Firstname Lastname</name>
      <name>Firstname2 Lastname2</name>

      Ok.. so there are some columns which are always there (id,name,gsm,email), but there are also those groups and there can be any amount of them. Groups can have any name.
      I need to know who is in which group (1 means person is in the group, 0 means he/she isn't).
      I could get the contents of group easily if I knew it's name. But because name can be anything, it's problematic.
      For example this would be way to do it (If I knew the name of it): myhttpservice.lastResult.contacts.contact.group1;
      Can I somehow make this dynamic? If there would be variable called "groupname" and if would be used instead of .group1. Like this?
      var groupname:String = "group1";
      var something = myhttpservice.lastResult.contacts.contact.{groupname};

      This doesn't work but I hope you get the point what I am trying to say.
      I made repeater which makes me checkbox for each group.
      <mx:Repeater id="r" dataProvider="{myhttpservice.lastResult.groups.group}">
      <mx:CheckBox id="checkbox" label="{r.currentItem.name}"/>

      So... If I select a row from datagrid, textboxes should show me which groups the person have signed in.

      Second question: can I somehow pass variables to mx-code from actionscript.
      If I have varible mytext, can i use it in mx-environment?
      var myscript:String = "Test";

      <mx:Label id="testtext" text="{myscript}/>
      Anyhow possible to do that? I know I could use testtext.text = myscript; but If I want to make it this way I showed to you, would it be possible?

        • 1. Re: Help needed!
          peterent Level 2
          Once you've used E4X to get the parent of your group, contact (I think), you can use the children() method of the XML node and then loop on them:

          var c:Array = contactNode.children();
          for(var i:int=0; i < c.length; i++)
          var groupname:String = c .nodeName;

          You'll have to double-check the Flex docs on children and nodeName because I can't remember off the top of my head which is a function and which is a property.
          • 2. Re: Help needed!
            MacKeith Level 1
            I must somehow get the value of that particular cell.
            If there is person called Michael and he is signed in to group named mygroup1, I must get that number one from there.