Jump to content
Search Community

Can't Transform centered Image Control

MDiddy test
Moderator Tag

Recommended Posts

So I'm trying to get an mx.controls.Image added to a FlexTransformManager, but if I apply verticalCenter & horizontalCenter = 0 to the control, The object can be selected, but I can't move or transform it. The bounding box seems to move, but the object just seems to keep snapping back to its original position. Here's some stub code:

//Adding object script. The CustomImage is an extended Image with a customVO assigned to it - and the verticalCenter/horizontalCenter style set to 0;
protected function onImageToAdd(e:CustomEvent):void
var img:CustomImage = new CustomImage();
img.addEventListener(CustomEvent.IMAGE_LOADED, onCustomImageLoad);
img.customVO = e.customVO;
img.source = e.customVO.fullImage;

protected function onCustomImageLoad(e:BoardEvent):void
		//Resize Image to fit and center it
		var img:CustomImage = e.currentTarget as CustomImage;
		img.customVO.x = img.x =  (transformManager.width)/2;
		img.customVO.y = img.y = (transformManager.height)/2;
                       //Delay selectItem to ensure bounding box draws correctly;
		TweenMax.delayedCall(.25, function():void{transformManager.selectItem(img);});			

Essentially, when an image is added, I want it to default to the center of the FlexTransformManager, and be selected. This is my first time working with TransformManager, so if there's some best practices or tips anyone has based on this small chunk of code, I'd love to hear it.



Link to comment
Share on other sites

Sounds like the Flex framework code is fighting with TransformManager because you told Flex to force your object to have its center be in the middle of the container. See what I mean? TransformManager is probably doing its job fine, but as soon as it moves your object, Flex is saying "wait, I've gotta move it back to the center because verticalCenter & horizontalCenter = 0". Sound reasonable? If you're still having trouble please shoot me a PM or e-mail with a simple Flex project zip that demonstrates the issue.

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