Jump to content
Search Community

Creating and adding TextFields to TransformManager [SOLVED]

mobius31 test
Moderator Tag

Recommended Posts

Hello All,

 

I'm having a bit a of trouble adding TextFields created with actionscript to the TransformManager without getting a runtime error. Here's the code below.

 

// Creates Instance of TranformManager

var manager:TransformManager = new TransformManager({targetObjects:[], constrainScale:false, lockRotation:true, allowDelete:true, autoDeselect:true});

 

// Creates new TextField

function addTextBox(evnt:Event):void {

 

var textBox:TextField = new TextField();

var mc_children:Number = mc.numChildren + 1;

textBox.name = "textBox" + mc_children.toString();

 

textBox.appendText("" + textBox.name);

textBox.type=TextFieldType.INPUT;

textBox.wordWrap=true;

textBox.x = 100;

textBox.y = 100;

textBox.border=true;

textBox.addEventListener(MouseEvent.MOUSE_DOWN, setTextField);

 

manager.addItem(textBox);

textBox.setTextFormat(format);

mc.addChild(textBox);

 

}

 

The first TextBox I create works fine, I can scale, move, etc.. But when I create a second TextBox and try to scale that I get this runtime error:

 

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

at gs.transform::TransformItem/reposition()

at gs.transform::TransformItem/scaleRotated()

at gs.transform::TransformManager/scaleSelection()

at gs.transform::TransformManager/updateScale()

at gs.transform::TransformManager/onMouseMoveScale()

at gs.transform::TransformManager/onPressScale()

 

 

I'm and experienced web developer but ActionScript 3.0 is new to me.

Can anyone tell me what I'm doing wrong?

 

Thanks so much for any help in advance.

Link to comment
Share on other sites

It looks like the problem had to do with the fact that you were adding the item to TransformManager before adding it to the display list. I made an adjustment in the class, though, so it should resolve the issue. Just download it from the link in the e-mail I sent you and let me know if that works well for you.

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