Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Help with a function

Question posted by: Shawn Northrop (Member) on May 1st, 2008 12:13 AM
I am in the process of building an Image Gallery. I have created an array "thumbs" and also a mc in my library called thumbnail (this has a UILoader and ProgressBar); I have sucessfully loaded the small images by creating a new thumbnail instance and storing it into an array. I have also created a Mouse Over EventListener onto each array element. My next goal is to have the mouse over call a specific picture. Right now it calls the image 1.jpg everytime.

The relevent functions are the loadThumb()
and loadPic()

does anyone have any suggestions/comments? This page can be viewed at www.jeanneflight.com/greg

Code: ( text )
  1. stop();
  2. import fl.controls.ProgressBar;
  3.  
  4. var thumbs:Array = new Array();
  5. var i = 0;
  6.  
  7. function loadThumb(){
  8.     var mc:thumbnail=new thumbnail();
  9.     thumbs[i] = mc;
  10.     if(i % 2 == 0){
  11.         thumbs[i].x = 550;
  12.         thumbs[i].y = 100 + (i * 57);
  13.     } else{
  14.         thumbs[i].x = 633;
  15.         thumbs[i].y = 100 + ((i - 1) * 57);
  16.     }
  17.     thumbs[i].loader.load(new URLRequest("images/" + (i + 1) + ".jpg"));
  18.     addChild(thumbs[i]);
  19.     if(i < 9){
  20.         thumbs[i].pb.addEventListener(Event.COMPLETE, another);
  21.     } else {
  22.         thumbs[i].pb.addEventListener(Event.COMPLETE, function(evt:Event):void { thumbs[i].pb.visible = false; });
  23.     }
  24.     thumbs[i].addEventListener(MouseEvent.MOUSE_OVER, loadpic);
  25. }
  26.  
  27. //loadpic(1);
  28.  
  29. function loadpic(e:Event){
  30. var j = 1;
  31. mainImg_mc.pb.visible = true;   
  32. mainImg_mc.loader.load(new URLRequest("images/"+j+".jpg"));
  33. mainImg_mc.pb.addEventListener(Event.COMPLETE, function(evt:Event):void { mainImg_mc.pb.visible = false; });
  34. }
  35.  
  36. function another(evt:Event){
  37.     thumbs[i].pb.visible = false;
  38.     i++;
  39.     loadThumb();
  40. }
  41.  
  42. loadThumb();
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Reply
Not the answer you were looking for? Post your question . . .
170,099 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Flash / Actionscript Forum Contributors