Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
rob.roberts

What is the proper use of the Flip and LayerUp methods?

Recommended Posts

I am attempting to use LayerUp and LayerDown and flipV and flipH buttons in my application (see below).

A TransformManager object item is selected, but will not respond to the button push.

 

var manager:TransformManager = new TransformManager({targetObjects:[], bounds:new Rectangle(PICSTAGE_OFFSETX, PICSTAGE_OFFSETY, stageWidth, stageHeight), allowDelete:true});
manager.addItem(image);

fliph_btn.addEventListener(MouseEvent.CLICK,manager.flipSelectionHorizontal);
flipv_btn.addEventListener(MouseEvent.CLICK,manager.flipSelectionVertical);
imgLayerUp_btn.addEventListener(MouseEvent.CLICK,manager.moveSelectionDepthUp); 
imgLayerDown_btn.addEventListener(MouseEvent.CLICK,manager.moveSelectionDepthDown); 

 

The buttons have been added to the manager as IgnoredObjects using manager.addIgnoredObject.

I have also added another item to the stage and manager to test both the flip and moveup/movedown functions, but the action does nothing on either display object.

Link to comment
Share on other sites

Looks to me like the problem is that you're pointing your listeners directly to those methods, but since the methods don't accept any parameters, you'll get errors because an Event instance is always passed to event listeners.

 

BAD:

fliph_btn.addEventListener(MouseEvent.CLICK, manager.flipSelectionHorizontal);

 

GOOD:

fliph_btn.addEventListener(MouseEvent.CLICK, clickFlipHorizontalHandler);
function clickFlipHorizontalHandler(event:Event):void {
   manager.flipSelectionHorizontal();
}

Link to comment
Share on other sites

That is actually what I wound up doing (and had it on my list to update this entry later today.)

 

Now we're "cooking with gas".

 

BTW, a tip for those who are doing a bitmap.draw of items managed by TransformManager:

 

Issue a _manager.deselectAll(); before doing the draw or you may get the handles in your drawing (assuming that your TransformManager instance is called _manager)

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.
×