A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: OOP troubles: Delegate with Iteration

Threaded View

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Posts
    237

    OOP troubles: Delegate with Iteration

    Hi there.

    I'm using iteration within a class method to attach a series of button instances from the library to mc in my fla. So far so good, but when I try to use Delegate to give them an onRelease handler, it only works on the last button. Here is the rellevent code:

    Code:
    	//CREATE BUTTONS FROM XML
    	public function attachButtons (buttonLabel:Array, totalButtons:Number, buttons:Number):Void {
    		
    		//SET ITEM VARS
    		numVisibleItems = buttons;
    		numOfItems = totalButtons;
    		
    		var thisLb:XmlListBox = this;
    		var i;
    		
    		//ITTERATE THROUGH ARRAY TO PLACE BUTTONS
    		for (i = 0; i < numOfItems; i++) {
    			buttonContainer_mc = listBoxContainer_mc.background_mc.attachMovie ("listBoxButton", "button" + i, listBoxContainer_mc.background_mc.getNextHighestDepth ());
    			buttonContainer_mc._y = buttonContainer_mc._height * i;
    			buttonContainer_mc.title_txt.text = [i + 1] + " " + buttonLabel[i];
    			buttonContainer_mc.onRelease = buttonContainer_mc.onReleaseOutside = Delegate.create(this, setButtons, i);
    			
    			buttonContainer_mc.thisSelected_mc._alpha = 0;
    				
    		}
    		
    		sizeMask ();
    	}
    	
    	function setButtons(i:Number):Void {
    		
    		buttonContainer_mc._alpha = 100;
    		trace("IDENT"+buttonContainer_mc.thisSelected_mc._alpha);
    		trace("I IS:"+ i);
    		//current_track_number = i;
    		//stopmusic();
    		//playmusic();
    		
    	}
    Thanks a lot.
    Last edited by arkum; 07-10-2006 at 05:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center