Connecting Tech Pros Worldwide Help | Site Map

dynamic movie clip from assets

Member
 
Join Date: Oct 2007
Posts: 112
#1: Jul 15 '09
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:


Expand|Select|Wrap|Line Numbers
  1. include('FolioItem.as');
  2. // here is where the code will go to load
  3. // the portfolio objects and then randomly
  4. // position trees with their info on it
  5. var c:LoadVars = new LoadVars();
  6. var itemArray:Array;
  7. //initialize values
  8. c.id = "";
  9. c.name = "";
  10. c.description = "";
  11. c.date = "";
  12. c.type = "";
  13. c.image = "";
  14. c.url = "";
  15. c.onLoad = function()
  16. {
  17.     //first get the count
  18.     var count = c['n'];
  19.     //initialize the array to hold all the info
  20.     itemArray = new Array(count);
  21.     //now loop to create the classs objects for each index in the array
  22.     for(var x =0; x < count; x++)
  23.     {
  24.         var f:FolioItem = new FolioItem(c['id'+x],
  25.                                         c['name'+x],
  26.                                         c['description'+x],
  27.                                         c['date_complete'+x],
  28.                                         c['type'+x],
  29.                                         c['image'+x],
  30.                                         c['url'+x]);
  31.         itemArray[x] = f;
  32.  
  33.     }
  34. }
  35. //send
  36. c.sendAndLoad("/conn/loadfolio.php", c, "POST");
  37.  


and the FolioItem class:

//define a class to manage each portfolio entry
Expand|Select|Wrap|Line Numbers
  1. class FolioItem
  2. {
  3.     public var id;
  4.     public var name;
  5.     public var desc;
  6.     public var date;
  7.     public var type;
  8.     public var imageurl;
  9.     public var url;
  10.     public function Song(i:String, n:String, de:String, da:String, t:String, iurl:String, u:String)
  11.     {
  12.         id = i;
  13.         name = n;
  14.         desc = de;
  15.         date = da;
  16.         type = t;
  17.         imageurl = iurl;
  18.         url = u;
  19.     }
  20. }
  21.  


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 programmer so i know techniques and concepts im just fuzzy on how i might do something like this in flash...



thanks alot,

ken
Reply