Jump to content
GreenSock

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

TransformItem Null Parent

Recommended Posts

I am having trouble using TransformManager with TextFields. I am dynamically adding a DisplayObject to the stage, which contains a Textfield. I then add the DisplayObject to the TransformManager, setting the scale to WIDTH_HEIGHT, like this:

 

var mcItem:TransformItem =  Application.application.designerControl.pageEditor.myManager.addItem(_view, TransformManager.SCALE_WIDTH_AND_HEIGHT, false);

 

My DisplayObject is a custom class that automatically changes its width and height based on the TransformManager (creates a Sprite in TransformItem as a proxy).

 

All works great when I add one DisplayObject to the stage, and transform its width and height. But once I add two DisplayObjects to the stage, switch between them and then try to transform the first one again, all of the sudden it gives me this error:

 

TypeError:  Error #1009:  Cannot access a property of a null object reference.

 

This error is occurring in the reposition() function within the TransformItem. Somehow, the _target.parent is getting lost when I select between the two separate TransformItems.

 

protected function reposition():void { //Ensures that the _origin lines up with the _localOrigin.
		var p:Point = _target.parent.globalToLocal(_target.localToGlobal(_localOrigin)); 
		_target.x += _origin.x - p.x;
		_target.y += _origin.y - p.y;
	}

 

Can anyone please help me with this one? I cannot figure it out for the life of me. Thanks!

Link to comment
Share on other sites

You're saying you edited TransformItem, right? It's very difficult to troubleshoot blind. Nobody else has reported any such problems, so it sure sounds like it's related to something you're doing in your app or customized version of TransformItem (just a guess).

Link to comment
Share on other sites

  • 9 months later...

I am having the same problem mate! Can anyone help us? I have been trying to troubleshoot this for a while now. I am getting really frustrated regarding this. Please help me. Please? car accident attorney

 

 

 

You must be the change you wish to see in the world. —Gandhi

Link to comment
Share on other sites

I am having the same problem mate! Can anyone help us? I have been trying to troubleshoot this for a while now. I am getting really frustrated regarding this. Please help me. Please?

Two questions:

  1. What version of TransformManager are you using? (I would definitely recommend using the latest)
  2. Can you please send me a simplified example FLA or Flex project that clearly demonstrates the issue? Again, it is very difficult to troubleshoot blind.

Link to comment
Share on other sites

  • 5 months later...

Oops, I forgot to add my response. Yes, I have done some customizations to the TransformManager and TransformItem, but nothing that should really mess with getting the parent of the target object. I am using version 1.96681.

 

My "Hack" Solution

I'm not exactly sure why, but when I add the following code to the onmousedown method in the TransformItem, it works:

 

if(_target.parent == null) {
_targetObject.parent.addChild(_proxy);
}

 

Any thoughts on why this is happening would be great. Otherwise, my "hack" seems to be working. It only happens when I use "SCALE_WIDTH_AND_HEIGHT" when adding a TransformItem. I guess once possible reason is the fact that I am using the TransformManager in a Flex project, but adding TransformItems as objects with pure AS3 (not Flex elements). So not sure if Flex does things differently when it comes to retrieving parents.

Link to comment
Share on other sites

It's tough to say without having a sample file to publish, but it sounds like the proxy isn't getting added correctly (again, not sure why - never heard of a problem like that before). The _proxy is only necessary when the scale mode is WIDTH_AND_HEIGHT. If your solution is working, great. If you run into trouble, just let us know.

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.

×