Jump to content
Search Community

blitMask eventListener not working

icekomo test
Moderator Tag

Recommended Posts

When I add my eventListener to the blitMask, it seems to break the code..... can't seem to figure out why?

 

 

 

public class Home extends MovieClip

{

public var t1:uint,t2:uint,y1:Number,y2:Number;

public var timer:Timer = new Timer(250,2);

public var bounds:Rectangle = new Rectangle(0,0,511,725);

public var menuTemp:MovieClip = new MovieClip();

public var blitMask:BlitMask = new BlitMask(menuTemp, bounds.x, bounds.y, bounds.width, bounds.height, false);

 

public function Home()

{

trace("2");

menuTemp = menuContent;

blitMask.update(null, true)

blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

//menuContent.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

}

public function mouseDownHandler(event:MouseEvent):void

{

timer.reset();

timer.start();

TweenLite.killTweensOf(menuContent);

y1 = y2 = menuContent.y;

t1 = t2 = getTimer();

menuContent.startDrag(false, new Rectangle(bounds.x, -99999, 0, 99999999));

menuContent.addEventListener(Event.ENTER_FRAME, enterFrameHandler);

menuContent.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

}

Link to comment
Share on other sites

The problem is that you applied your BlitMask to an empty MovieClip and then never updated it. For example, you started with this:

 

public var menuTemp:MovieClip = new MovieClip();
public var blitMask:BlitMask = new BlitMask(menuTemp, bounds.x, bounds.y, bounds.width, bounds.height, false);

 

Then later you did this:

 

menuTemp = menuContent; //blitMask.update(null, true);

 

So again, you just updated your variable rather than the BlitMask's target. You should either just create the BlitMask when you know your target or reset the target correctly like blitMask.target = menuContent;

Link to comment
Share on other sites

the problem I am running into, and maybe it due to my limited knowledge of OOP, is that the home is a class, and my target isn't established until the constructor is ran, but then it's to late to set a public var for that class.... if that make sense?

Link to comment
Share on other sites

You can declare variables without actually setting them yet. In your code, it'd look like:

public class Home extends MovieClip {
   ...
   public var bounds:Rectangle = new Rectangle(0,0,511,725);
   public var menuTemp:MovieClip;
   public var blitMask:BlitMask;

   public function Home() {
       menuTemp = menuContent;
       blitMask = new BlitMask(menuTemp, bounds.x, bounds.y, bounds.width, bounds.height, false);
       ...
   }
   ...
}

 

Or if you need to use your old code, you'd just need to set the blitMask.target = menuContent in your constructor.

 

Does that clear things up?

 

Make sense?

Link to comment
Share on other sites

Thank you so much for clearing that up for me! Big help.

I have another question for you but this is more along the lines of OOP.

I have my main class, and inside that class I create a new class called

home:Home;

home = new Home;

I have a movieClip (contentContainer) that I add home into like such: contentContainer.addChild(home);

I create another class;

homeBtns:HomeButtons;

homeBtns = new HomeButtons(sectionXml. contentContainer);

 

I am trying to pass an xml file and the contentContainer file to the homeButton class.

When I try to even trace this from the homeButton class

homeWrapper = home that was passed in from the main class.

trace(homeWrapper.home.x);

 

What I am trying to do is access the dynamic text field inside the home class, but this throws an error:

 

TypeError: Error #1010: A term is undefined and has no properties.

 

I'm not sure I am going about this right, or even if you can pass a "class" into another "class" and access that classes timeline.

Maybe I have to target the main timeline after it's beed added and access it that way?

 

If this is confusing I understand...this is a new area for me and I know my vocabulary isn't quiet there yet.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...