4 Replies Latest reply on Jan 28, 2008 8:54 AM by zavoiu

    Component List

    zavoiu
      How can I work from an external file with a list that is sitting on the main timeline of a movie clip?

      I have given the component List an instance name of "userList". I defined the listener for the list in an external .as file. I'm now trying to load data into the list by using userList.addItem() method, but it doesn't seem to do anything. When the list is displayed on the screen, the list is empty, the length of it is undefined. Adding items to the list only works when the code sits on the movie clip timeline where the list is sitting. By searching for answers, I found this advice from http://livedocs.adobe.com/flash site:

      Components MUST load after classes otherwise you cannot control them (Using Action Script in Flash page 117). If you set an export frame other than 1 for your classes (most likely if you use a progress bar) you must deselect 'export on first frame' setting on your component library symbol from the Linkage menu. Component that loads on frame 1 will not retroactively find its associated class that loads afterwards on say frame 4.

      Taking their advice, I deselected the 'export on first frame' setting of my list component library symbol, saved and republished my .fla file. I tested again, and it still doesn't work. Any ideas?


        • 1. Re: Component List
          niki tsanov Level 1
          So bro look here
          this post
          i think your problem can be decide with dr_ross post to use mx.utils.Delegate. :)
          • 2. Component List
            zavoiu Level 1
            Thanks. I've implemented the code and it will take care of the list listener. How about when I try to add items to the list? It never adds them, and the list length is still 0. "userList" is my array of user names.

            for (var i=0; i < userList.length; i++) {
            trace(userList .userName);
            owner.bkgrd.userList_txt.addItem({label:userList
            .userName, data:i});
            }
            • 3. Re: Component List
              niki tsanov Level 1
              So when you define the function and define two variables one of them for path to your list box and one if you want to use array from the stage in code i mean this Add function is into your class.And from the stage where you define new class call with Add(Path.List1, UserArray);

              • 4. Re: Component List
                zavoiu Level 1
                Thanks. Everything works fine. Now, I expect the user to either double-click on a user name or click and press Enter when selecting his name. How do I check for a double click or a click and Enter key? or any two keys? I know how to check for a click or a key, but how about for two keys pressed one after the other?