3 Replies Latest reply on Mar 20, 2011 3:36 PM by kglad-zqbLf4

    onRollOver for dynamically created mc

    polonDev

      Hello,

       

       

      I need onRollOver event for dynamically created mc.

      My mc is inside another mc. I red that mc inside another mc can't have event.

       

      My code :

       

      function CreateCombosSurfaces()
      {
      for (i = 0; i < combos.length; i++)
      {
      position = combos[i].position;
      var mcName:String = "cs_" + (i+1);
      if (combos[i].type == "3")    // 3Combo
      {
      _root.Platform4.attachMovie("Combo3Surface", mcName, _root.Platform4.getNextHighestDepth());
      _root.Platform4[mcName]._x = 0;
      _root.Platform4[mcName]._y = -113;
      }
      else    // 4Combo
      {
      _root.Platform4.attachMovie("Combo4Surface", mcName, _root.Platform4.getNextHighestDepth());
      _root.Platform4[mcName]._x = 0;
      _root.Platform4[mcName]._y = -97;
      }
      Angle = ((position-1) - Platform4Pos) * 45;
      // Rotate combo surface
      RotateAroundExternalPoint(_root.Platform4[mcName], 0, 0, Angle);
      _root.Platform4[mcName].type = combos[i].type;
      _root.Platform4[mcName].ComboBalls = combos[i].ballsID;
      }
      }

       

      And now I need onRollOver  for (_root.Platform4[mcName]).

       

       

      at the moment :

       

      function CreateCombosSurfaces()
      {
      ...
      _root.Platform4[mcName].onRollOver = function()
      {
      trace("hit");
      }
      }

       

      doesn't work.

       

       

       

      Can you help me ?

      Thx

        • 1. Re: onRollOver for dynamically created mc
          kglad-zqbLf4 Level 3

          you can add mouse listeners to dynamically created nested movieclips.  if one of the parent movieclips has a mouse listener that will prevent any children with listeners from detecting mouse events.

           

          do any of your parents have mouse listeners?  if not, show your code.

          • 2. Re: onRollOver for dynamically created mc
            polonDev Level 1

            No i don't have mouse listener can you show me example ?

             

            My code is in my previous post.

             

             

            Platform4 is in _root in scene (not dynamically created).

             

            thx

            • 3. Re: onRollOver for dynamically created mc
              kglad-zqbLf4 Level 3

              :

               


               

              function CreateCombosSurfaces(){


              for (i = 0; i < combos.length; i++){
              position = combos[i].position;
              var mcName:String = "cs_" + (i+1);


              if (combos[i].type == "3")    // 3Combo{
              _root.Platform4.attachMovie("Combo3Surface", mcName, _root.Platform4.getNextHighestDepth());
              _root.Platform4[mcName]._x = i*100;
              _root.Platform4[mcName]._y = -113;
              }else    // 4Combo{
              _root.Platform4.attachMovie("Combo4Surface", mcName, _root.Platform4.getNextHighestDepth());
              _root.Platform4[mcName]._x = i*100;
              _root.Platform4[mcName]._y = -97;
              }
              Angle = ((position-1) - Platform4Pos) * 45;
              // Rotate combo surface
              RotateAroundExternalPoint(_root.Platform4[mcName], 0, 0, Angle);
              _root.Platform4[mcName].type = combos[i].type;
              _root.Platform4[mcName].ComboBalls = combos[i].ballsID;

               

              _root.Platform4[mcName].onRollOver = function(){
              trace("hit");
              }

               

              }

              }