A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] how do i give a member of an array a numerical value?

  1. #1
    Member
    Join Date
    Jul 2009
    Posts
    88

    resolved [RESOLVED] how do i give a member of an array a numerical value?

    k, so i have a custom class in which an array of movie clips (buttons) is loaded into. once in there, each member of that array is given a buttonmode property,an event listener etc.

    basically, what happens is that when the user clicks on one, it fades and becomes inactive until a different button in the array is pushed. then that one is faded and inactive, etc.... the process toggles depending on which button is pushed.

    and that all works fine. what i want to do though is give each movieclip/button an association of a numerical value, so that when form is submitted on the main i can pull that number back into the main class and process the information based on what number was pulled.

    for example the grey ball = 1, red = 2.... if i clicked on the red ball and then submit, i can pull "2", the number associated with that movieclip.

    here's what i have and i've commented where i need help.

    PHP Code:
     private var currentButton:MovieClip;
         private var 
    lastClicked:MovieClip;
         private var 
    theButtons:Array = new Array();
         public var 
    arrayLocationCount:Number 0;
            
         public function 
    ButtonDisablerClass (_theButtons:Array)
         {
              
    theButtons _theButtons;
              
    addListeners();
         }
    //end constructor
            
         
    private function addListeners():void
         
    {
              
    //trace("addListeners ran");
               
    for(var i:int 0theButtons.lengthi++)
               {
                   
    theButtons[i].addEventListener(MouseEvent.CLICKclickHandler);
                   
    theButtons[i].buttonMode true;
                    
                    
    //here is where i want assign the var arrayLocationCount = to i,
                    //for each instance of an object in the array, be there 2 or 20.

               
    }//end for

         
    }//end addListeners
            
         
    private function clickHandler(event:MouseEvent):void
         
    {........... 
    any thoughts?

    big thanks,
    shields
    Last edited by krashe1313; 10-27-2009 at 12:05 PM. Reason: so it looks like it was written by a somewhat intellegent, sober, adult

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    PHP Code:
        private function clickHandler(event:MouseEvent):void{
            var 
    i:int theButtons.length;

            while(
    i--){
            if(
    theButtons[i] == event.target){ break };
            }

            
    trace('button ' ' clicked');        
        } 
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Member
    Join Date
    Jul 2009
    Posts
    88

    Thumbs up

    neznein9.... that is brilliantly simple! wow- i swear i over think things some times.
    i really do appreciate the help. this is fantastic.

    works perfect for what i needed to do! i just set arrayLocationCount = i and now i can call it from my main. sweet!

    thanks,
    shields
    Last edited by krashe1313; 10-27-2009 at 01: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