1 Reply Latest reply on Aug 8, 2006 5:09 AM by Mac_Apollo

    calling that movieClip by name

    yvidanpeled Level 1
      hi all


      please take a look at the following code:

      the code refers to a movieclip eg. checkbox1 that has within it a child mc named checked
      the movieClips are allready on stage and the function calls them by name in parameters


      if you look at the code, you will see that even though the functions parameters contain the movieClips instance name i have yet to find a way to use that instance name with an action like onRelease.
      what i did in the code below is use the whole name :
      _root.sadot.checkbox2.onRelease = function(){}
      and as a result had to duplicate this function for more sets of checkboxes
      replacing them.

      please help if you are familiar with a technique to acheive this.

      p.s. - i know how to make it work if i created instances on the fly using loadMovie from library but in this case i work with designers that want to see the buttons on the stage


      -------------------code --------------------------------------------------

      buildCheckBox1 = function(mcname1,mcname2,whoIsOn){
      check1 = "_root.sadot."+mcname1+".checked"
      check2 = "_root.sadot."+mcname2+".checked"
      if(whoIsOn==1){
      setProperty("_root.sadot."+mcname1+".checked",_visible,true)
      setProperty("_root.sadot."+mcname2+".checked",_visible,false)
      } else {
      setProperty("_root.sadot."+mcname1+".checked",_visible,false)
      setProperty("_root.sadot."+mcname2+".checked",_visible,true)
      }

      _root.sadot.checkbox1.onRelease = function(){
      isChecked = getProperty("_root.sadot."+mcname1+".checked",_visible)
      if (isChecked==false){
      setProperty("_root.sadot."+mcname1+".checked",_visible,true)
      setProperty("_root.sadot."+mcname2+".checked",_visible,false)
      }
      }

      _root.sadot.checkbox2.onRelease = function(){
      isChecked = getProperty("_root.sadot."+mcname2+".checked",_visible)
      if (isChecked==false){
      setProperty("_root.sadot."+mcname1+".checked",_visible,false)
      setProperty("_root.sadot."+mcname2+".checked",_visible,true)
      }
      }
      }