Skip to main content
Inspiring
January 24, 2013
Answered

Can a var unite mc's into a group to assign events?

  • January 24, 2013
  • 1 reply
  • 470 views

I would like a set of MC buttons react a certain way on the screen. For this I did not wan to group then into another one MC but decided to make a var with them. However it does not seem to work. Is it possible?

Here is my not working code:

var dimmedLyteRing_arr:Array = new Array(IntroIMGS_COLLAGE.AppsIntro.coolingreflectionsIntro_btn, IntroIMGS_COLLAGE.AppsIntro.towerspectaculaireIntro_btn, IntroIMGS_COLLAGE.AppsIntro.CountryTowerIntro_btn, IntroIMGS_COLLAGE.AppsIntro.FlamelessTabletopAccentsIntro_btn, IntroIMGS_COLLAGE.AppsIntro.SilverBloomIntro_btn, IntroIMGS_COLLAGE.AppsIntro.gazingglowIntro_btn);

dimmedLyteRing_arr.buttonMode=true;

dimmedLyteRing_arr.useHandCursor = true;

Here is my full version of non working code:

//set up a vars array for a set of images to dim on MOUSE_OVER/OUT

var dimmedLyteRing_arr:Array = new Array(IntroIMGS_COLLAGE.AppsIntro.coolingreflectionsIntro_btn, IntroIMGS_COLLAGE.AppsIntro.towerspectaculaireIntro_btn, IntroIMGS_COLLAGE.AppsIntro.CountryTowerIntro_btn, IntroIMGS_COLLAGE.AppsIntro.FlamelessTabletopAccentsIntro_btn, IntroIMGS_COLLAGE.AppsIntro.SilverBloomIntro_btn, IntroIMGS_COLLAGE.AppsIntro.gazingglowIntro_btn);

dimmedLyteRing_arr.buttonMode=true;

dimmedLyteRing_arr.useHandCursor = true;

//set up a vars array for a set of images to make dimLyteRing_arr to dim on MOUSE_OVER/OUT

var dimmerLyteRing_arr:Array = new Array(IntroIMGS_COLLAGE.prdctsIntro.LyteRing6SMTIntro_btn);

//var dimLyteRing_Tween:TweenMax = TweenMax.allTo(dimLyteRing_arr, 1, {scaleX:.7, scaleY:.7, colorMatrixFilter:{saturation:.1, brightness:.5}, paused:true});

var dimLyteRing_Tween:TweenMax = TweenMax.to(dimmedLyteRing_arr, .5, {alpha:.5, paused:true});

dimmerLyteRing_arr.addEventListener(MouseEvent.MOUSE_OVER, navOver_dimLyteRing_arr);

dimmerLyteRing_arr.addEventListener(MouseEvent.MOUSE_OUT, navOut_dimLyteRing_arr);

                    

          function navOver_dimLyteRing_arr(e:MouseEvent):void{

         dimLyteRing_Tween.play();

         }

        

          function navOut_dimLyteRing_arr(e:MouseEvent):void{

         dimLyteRing_Tween.reverse();

         }

This topic has been closed for replies.
Correct answer moccamaximum

You can not have a Array listening for MouseEvents.

To be able to listen for MouseEvents an Object has to be a DisplayObject.

What you can do, though, is adding any DisplayObject to an Array, and then looping through the Array and assign your EventListeners individually.

1 reply

moccamaximumCorrect answer
Inspiring
January 24, 2013

You can not have a Array listening for MouseEvents.

To be able to listen for MouseEvents an Object has to be a DisplayObject.

What you can do, though, is adding any DisplayObject to an Array, and then looping through the Array and assign your EventListeners individually.