Help with a function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn Northrop
    New Member
    • Jan 2007
    • 67

    Help with a function

    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.jeannefligh t.com/greg

    Code:
    stop();
    import fl.controls.ProgressBar;
    
    var thumbs:Array = new Array();
    var i = 0;
    
    function loadThumb(){
    	var mc:thumbnail=new thumbnail();
    	thumbs[i] = mc;
    	if(i % 2 == 0){
    		thumbs[i].x = 550;
    		thumbs[i].y = 100 + (i * 57);
    	} else{
    		thumbs[i].x = 633;
    		thumbs[i].y = 100 + ((i - 1) * 57);
    	}
    	thumbs[i].loader.load(new URLRequest("images/" + (i + 1) + ".jpg"));
    	addChild(thumbs[i]);
    	if(i < 9){
    		thumbs[i].pb.addEventListener(Event.COMPLETE, another);
    	} else {
    		thumbs[i].pb.addEventListener(Event.COMPLETE, function(evt:Event):void { thumbs[i].pb.visible = false; });
    	}
    	thumbs[i].addEventListener(MouseEvent.MOUSE_OVER, loadpic);
    }
    
    //loadpic(1);
    
    function loadpic(e:Event){
    var j = 1;
    mainImg_mc.pb.visible = true;	
    mainImg_mc.loader.load(new URLRequest("images/"+j+".jpg"));
    mainImg_mc.pb.addEventListener(Event.COMPLETE, function(evt:Event):void { mainImg_mc.pb.visible = false; });
    }
    
    function another(evt:Event){ 
    	thumbs[i].pb.visible = false;
    	i++;
    	loadThumb();
    }
    
    loadThumb();
Working...