Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Atonis

Another Flex 4 Index Out of range Problem

Recommended Posts

Hello,

 

I'm currently trying to implement a crop tool to our Application.

My problem is that I keep getting indexOutOfRange errors from TransformManager.bringToFront either when clicking on the image I want to crop or when clicking outside to unselect it.

 

The same application also gives me from time to time an "wrong parent" error when trying to remove the dummyBox, event though the instance passes the "_selection.parent == _parent" test just before  (TransformManager.updateSelection). 

 

Both Errors seem very very weird as the range error is thrown even thought range is correct and the parent is ok.

 

Does anyone have any clue on what I'm doing wrong ?

 

Here's a sample app and my basic instanciation code : 

protected function application_creationCompleteHandler(event:FlexEvent):void
{
	transformManager=new TransformManager();
	transformManager.bounds = new Rectangle(0,0,955,600);
	
	imageCompo.image.source = "image.jpg" ;
	imageCompo.image.addEventListener(Event.COMPLETE,image_readyHandler);
}

protected function image_readyHandler(event:Event):void
{
	trace ("complete");

// for some reason flex never tells you when the image is actually ready
	setTimeout(wtf_flex_handler,1000);
}
			
private function wtf_flex_handler():void
{
	trace ("timer complete");
	var crop:FlexCrop=new FlexCrop(imageCompo.image, transformManager);
}

and the imageCompo code :

public class ImageComponent extends SkinnableComponent
{
	[SkinPart(required="true")]
	public var image : Image;
//...some basic stuff
}

Thanks in advance for any input that could help me, I'll give out anything I find if I do find something.

 

proto-crop-greensock.zip

Link to post
Share on other sites

update : using transformManager.forceSelectionToFront = false; prevents the issues wich in my case is good enough as I only modify one item.

  • Like 1
Link to post
Share on other sites

Glad you figured out a solution. There are a bunch of strange Flex-specific rules that that framework imposes which is why we created FlexTransformManager which is like a Flex-friendly wrapper for TransformManager. You might want to try using that instead of a raw TransformManager if you're using it inside Flex. 

Link to post
Share on other sites

yeah I thought about using the flextransformmanager, but I can't really do that, It's instanciated somewhere else and I'd rather have only markup definitions in my mxml.

I had to remove the image component thougt and have directly on my main app view, since we are running out of time and I still had a bunch of errors.

 

By the way, I had to "ducttape" the onReleaseMove method In TransofmManager 

from 

if (_trackingInfo.moved) {
dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_MOVE);				}

to 

if (_trackingInfo && _trackingInfo.moved) {
	dispatchInteractiveEvent(TransformEvent.FINISH_INTERACTIVE_MOVE);
}

as  _trackinInfo is not always instanciated (not sure why).

 

Thanks guys, your tool just saved me a few days of coding to have a working crop tool (and the rest of the transformmanager is awesome)

Link to post
Share on other sites

Great, thanks for letting us know. I'll look into that. Glad to hear the tool has saved you some time and hassle. 

 

Cheers!

Link to post
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.

×