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

    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!
          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.

          • 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.