2 Replies Latest reply on Jun 11, 2007 10:29 AM by Greg Dove

    List Component doesnt update dynamically?

    studmanho
      Hi everyone,

      Im very new at flash, only been writing stuff for a couple weeks, so maybe there is a simple solution. I have a List component that i use, and it doesnt seem to update its labels dynamically when i change an object in the dataprovider. The code goes like this:

      I use a dataprodiver.

      var dp:DataProvider = new DataProvider();
      mylist.dataProvider = dp;

      var myObj:testObj = new testObj("name");
      dp.addItem(myObj);

      mylist.labelFunction = setLabel;

      function setLabel(Obj:Object):String{
      return Obj.name;
      }

      then if I change the object name, it doesnt update the label.

      myObj.name = "test 2";

      I have even dispatched an event in the in myObj and added a listener so
      I can explicitly make the List update label, but I cant find any
      function call to make it do that. Driving me insane :)

      Please let me know if youve experienced that same., TIA
        • 1. Re: List Component doesnt update dynamically?
          studmanho Level 1
          Can someone at least let me know if its impossible to do? If it is, Ill look for another way to do listboxes.
          • 2. Re: List Component doesnt update dynamically?
            Greg Dove Level 4
            I haven't played with as3 yet, so I'm thinking in as2 - and I see some differences (the dataprovider stuff looks good). But it does also mean that is advice may be way off track. Please ignore this post if it looks that way.

            I have no idea what you're doing here, I assume testObj is a class you created:

            var myObj:testObj = new testObj("name");

            if not, then just use:

            var myObj:Object = {name:"nameless"}

            Otherwise... name must be a property accessible from your testObj instance (ie. defined in your testObj class as public ) to return a value from labelFunction. If your class of testObj has a name property then what is it initialised to? the value "name"? Without knowing whether testObj instances have a name property I can't understand how it would work. But like I said... I don't know as3 and maybe I'm missing something.