views:

48

answers:

1

Hi, i have 3 mc : category1, category2, category3 in library, in each of them i have mc with the same instance names : _background, _picture, but with totally different contend. What i wanted to do is to create a SuperCategory class that would do the same things on _background, _picture. So in library i did Export for Actionscript Category1, Category2, Category3.

public class SuperCategory extends MovieClip
{
    public var _picture:MovieClip;
    public var _background:MovieClip;
    public var time:int = 0;

 public function SuperCategory() 
 {
         addEventListener(MouseEvent.ROLL_OVER, onRollOver)
 }
    public function onRollOver(event:MouseEvent):void
    {
         TweenMax.to(_picture,time,{alpha:0.2});
    }

}

and i want to extend this class

public class Category1 extends SuperCategory
{
    public function Category1()
    {
        time = 2;
        super();
    }
}

I know that the conflict is between the public var _picture and the mc in library having an instance named _picture, but how can i do something like this and avoid this error ?

A: 

What if in the Category MC you change the instance name to something else maybe "_pic". Then in the Category class in the constructor you do something like:

public class Category1 extends SuperCategory{    
       public function Category1()    
       {        
          time = 2;        
          super();   
          registerRollOver(_pic);
       }
}

SuperCategory class

 public class SuperCategory extends MovieClip
    {
        public var _picture:MovieClip;
        public var _background:MovieClip;
        public var time:int = 0;

        public function SuperCategory() 
        {

        }
        public function onRollOver(event:MouseEvent):void
        {
           TweenMax.to(_picture,time,{alpha:0.2});
        }

        public function registerRollover(clip:MovieClip):void
        {
           _picture = clip; //in case you want it to be class member still
           _picture.addEventListener(MouseEvent.ROLL_OVER, onRollOver)
        }

    }
Allan
Hi, thank you got the idea about "registering" those library MovieClips
exus