Jump to content
Search Community

bounds issue in scaled parent MC

gparker test
Moderator Tag

Recommended Posts

Hi again,


OK so I need some help once more. I've ran into an issue where trying to add bounds is causing odd behavior. If I set the bounds to the full size, the bound drag/scale behavior works as expected, but the movieclips I'm trying to transform get compacted into a smaller scale version of my product area when it's loaded (almost like it's trying to enforce the bounds without the scale that is applied to the parent MC of the added objects). However, if I apply the scale multiplier to the bounds, then the movieclips appear in their correct locations, but they can be dragged far off to the right and bottom.


I guess my confusion and question on all of this is: is there a way to set the manager to reside in a particular movieclip so it picks up the scale of it? Or do i need to do something else? Here is part of my code that's related to this issue, with some lengthy parts commented out to explain what they're doing.


This is AS3 in a Flex application

(the dataProvider.layouts contains a bunch of layer nodes of parsed XML that contains text and image objects)


public var manager:TransformManager = new TransformManager();
private var _layoutCanvas:Canvas;

public function renderPanel():void
var xScale:Number = _panelSprite.width / _dataProvider.width;
var yScale:Number = _panelSprite.height / _dataProvider.height;
layoutCanvas.scaleX = xScale;  //I also tried to apply these scales at the end of all the code, it didn't help
layoutCanvas.scaleY = yScale;

var layout:LayoutVO = _dataProvider.layouts.getItemAt(0) as LayoutVO;
for( var i:int = 0; i < layout.layers.length; ++i )
	var layer:LayerVO = layout.layers.getItemAt(i) as LayerVO;
	var region:EditableRegion;  //extends UIComponent

	switch( layer.type )
		case "text":
			var textVO:TextVO = layer.content as TextVO;
			var textRegion:TextRegion = new TextRegion();  //extends EditableRegion
			region = textRegion;

		case "image":
			var imageVO:ImageVO = layer.content as ImageVO;
			var imageRegion:ImageRegion = new ImageRegion();  //extends EditableRegion
			region = imageRegion;

	if( region )
		var position:PositionVO = layer.frame.position;
		region.x = position.xOffset;
		region.y = position.yOffset;
		region.width = position.width;
		region.height = position.height;

		region.dataProvider = layer;
		layoutCanvas.addChild( region );
		editableRegionsArray[i] = region;

		if(layer.movable) {
			var tmItem:TransformItem = manager.addItem(region);
			tmItem.addEventListener(TransformEvent.SELECT, checkContents);
			tmItem.addEventListener(TransformEvent.RELEASE_CURSOR, tmOnRelease);


//Transform Manager options setup
var boundsRect:Rectangle = new Rectangle(_dataProvider.boundsPosition.xOffset, _dataProvider.boundsPosition.yOffset, _dataProvider.boundsPosition.width, (_dataProvider.boundsPosition.height));
manager.bounds = boundsRect;
manager.constrainScale = true;
manager.hideCenterHandle = true;
manager.forceSelectionToFront = false;


So, basically, this rect: var boundsRect:Rectangle = new Rectangle(_dataProvider.boundsPosition.xOffset, _dataProvider.boundsPosition.yOffset, _dataProvider.boundsPosition.width, (_dataProvider.boundsPosition.height));

Makes the bounds BEHAVIOR as expected, but jacks up the placement of the editableRegions.


and this Rect (or no bounds set at all) results in the editableRegions being placed correctly, BUT then the bounds at the right and bottom bounds are WAY off the expected edge.

var boundsRect:Rectangle = new Rectangle(_dataProvider.boundsPosition.xOffset, _dataProvider.boundsPosition.yOffset, (_dataProvider.boundsPosition.width*xScale), (_dataProvider.boundsPosition.height*xScale));


So, do you have any idea have I can get the bounds behavior to be scaled correctly with the layoutCanvas, which is scaled and has the displayObjects added to it? I tried to add the bounds before the objects were added to the manager and that didn't change anything. I can give more info if needed.

Link to comment
Share on other sites

Wow, wouldn't you know it. Within minutes of posting this long rabble, I solved it. I just set the manager.bounds later on after the objects had been rendered on the stage and now it all works as expected! So.... it's a non-issue really. You can delete this thread if you want, or leave it for others to see, whatever works. Thanks.

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