Jump to content
Search Community

Adding Objects Larger than Bounds

pwhite20 test
Moderator Tag

Recommended Posts

I'm having a problem that maybe someone can help with. I have a text field which users can enter text into, and when hitting the "Add Text" button it gets dynamically added to the FlexTransformManager. This works great with short lines of text, but when a long line of text gets entered that extends the Text object's size beyond the bounds of the TransformManager I run into a problem. It allows it to be added, but once the user selects it, it scales itself down to a size that is about 80% of the TransformManager's width and jumps both the x and y coordinates to some random position down and to the right.

 

Idealy I would like to avoid the scenario above altogether and scale the object down to be within the boundaries at the point that it's added to the TransformManager instead of waiting until the user selects the object. Any ideas on how to accomplish this?

 

<?xml version="1.0" encoding="utf-8"?>








Link to comment
Share on other sites

Never fails. Solve your own problems just after posting on the message boards. Anyway, decided to leave up and post the solution in case it's of use to anybody else. What I was missing was the fact that width and height properties don't get set in Flex until AFTER the the objects are written out to the canvas. The TransformItem has default width and height parameters (both set to 100), but nothing useful for performing the necessary calculations for scaling until they get overridden with the correct values later on.

 

The solution was to add an eventListener to watch for the creation of the new object, THEN grab the original width and height to calculate the scaling that the new object needed to be set to.

 

<?xml version="1.0" encoding="utf-8"?>








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