2 Replies Latest reply on Mar 8, 2007 4:35 PM by ntsiii

    Help needed!

    MacKeith
      Hello.
      I have a problem. I wish you could help me with this.
      I have php script which returns me something like this:
      <groups>
      <group>
      <name>group1</name>
      </group>
      <group>
      <name>group2</name>
      </group>
      <group>
      <name>othergroup</name>
      </group>
      <group>
      <name>mygroup</name>
      </group>
      </groups>

      <contacts>
      <contact>
      <id>1</id>
      <name>Firstname Lastname</name>
      <gsm>+1234567890</gsm>
      <email>mail@mail.com</email>
      <group1>0</group1>
      <group2>0</group2>
      <othergroup>1</othergroup>
      <mygroup>0</mygroup>
      </contact>
      <contact>
      <id>2</id>
      <name>Firstname2 Lastname2</name>
      <gsm>+1234567890</gsm>
      <email>mail2@mail.com</email>
      <group1>1</group1>
      <group2>0</group2>
      <othergroup>0</othergroup>
      <mygroup>1</mygroup>
      </contact>
      </contacts>

      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:FormItem>
      <mx:CheckBox id="checkbox" label="{r.currentItem.name}"/>
      </mx:FormItem>
      </mx:Repeater>

      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?
      Example:
      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!
          ntsiii Level 3
          First, I almost ignored this question be cause the subject was not well crafted. I only read questions that I think I can help with, based on the subject. You will be well served to put a much intellignce in the subject of a question as you can.

          The easy question first:
          [Bindable]var myscript:String = "Test";
          <mx:Label id="testtext" text="{myscript}/>
          Will work just fine.

          The first question:
          1. don't use lastResult in AS, it is for binding expressions
          2. You can't use binding braces in AS:
          var something = myhttpservice.lastResult.contacts.contact.{groupname};
          will not work. But you can do:
          var sGroupName:String;
          _xmlContacts.contact.[sGroupName].(text()==1); //will return group nodes the have text value = 1
          3. If you are not using resultFormat="e4x" you should.
          4. In a resultHandler function, assign the data to a global bindable variable
          _xmlContacts = XML(event.result);

          You have a lot going on here, take it one step at a time, all is possible.

          Tracy
          • 2. Re: Help needed!
            ntsiii Level 3
            Also, it is up to you, but I spend most of my time on the General Discussion forum.