0 Replies Latest reply: Jul 14, 2009 9:04 PM by drsmooth6 RSS

    creating dynamic movieclips from remote data

    drsmooth6 Community Member

      im not totally sure if this is a remoting question or more of a flash question but what i have is a portfolio site for my design company and i use a loadvars object to get a list of jobs we've done and some info about them.

       

      next we made this movieclip in flash that represents a small tree, what i want to do is create a tree for each entry in the database and have each one display unique data on it. so far what i have is:

       

      <code>

      include('FolioItem.as');
      // here is where the code will go to load
      // the portfolio objects and then randomly
      // position trees with their info on it
      var c:LoadVars = new LoadVars();
      var itemArray:Array;
      //initialize values
      c.id = "";
      c.name = "";
      c.description = "";
      c.date = "";
      c.type = "";
      c.image = "";
      c.url = "";
      c.onLoad = function()
      {
          //first get the count
          var count = c['n'];
          //initialize the array to hold all the info
          itemArray = new Array(count);
          //now loop to create the classs objects for each index in the array
          for(var x =0; x < count; x++)
          {
              var f:FolioItem = new FolioItem(c['id'+x],
                                              c['name'+x],
                                              c['description'+x],
                                              c['date_complete'+x],
                                              c['type'+x],
                                              c['image'+x],
                                              c['url'+x]);
              itemArray[x] = f;
             
          }
      }
      //send
      c.sendAndLoad("/conn/loadfolio.php", c, "POST");

      </code>

       

      and the FolioItem class:

       

      <code>

      //define a class to manage each portfolio entry
      class FolioItem
      {
          public var id;
          public var name;
          public var desc;
          public var date;
          public var type;
          public var imageurl;
          public var url;
          public function Song(i:String, n:String, de:String, da:String, t:String, iurl:String, u:String)
          {
              id = i;
              name = n;
              desc = de;
              date = da;
              type = t;
              imageurl = iurl;
              url = u;
          }
      }

      </code>

       

      now what my problem is is how do i create instances of the tree movieclip and dynamically add them to the stage and then know which one is clicked on so i can load the appropriate information to a larger display.

       

      im new to flash but i am a programming so i know techniques and concepts im just fuzzy on how i might do seomthing like this in flash...

       

      thanks alot,

      ken