This content has been marked as final. Show 12 replies
Do you have any code to offer for what you are doing?
ok, the code is quite complicated, it's a VISIO like designer, so I cannot post the entire code here, but here are some additional info:
first I collect all the _width , _height , _rotation data of the movie clips and textboxes in a movieclip, then I serialize it using JSON.as . When I deserialize the text, and create the objects again, everything is fine, only TextField 's _width, and _height is different. I've noticed that the amount of the difference is based on the rotation angle...
the save code part:
for each element
newElementArray._width = theelementobject._width;
newElementArray._height = theelementobject._height;
newElementArray._xscale = theelementobject._xscale;
newElementArray._yscale = theelementobject._yscale;
newElementArray._rotation = theelementobject._rotation;
..then on the end
var js = new JSON();
outStr = js.stringify(outArray);
.. and I store this string somewhere
the load code:
var js = new JSON();
var inObject = js.parse(dataStr);
foreach object, i attach the movie clip to the container than i set the properties:
theComponent._rotation = theElement._rotation;
... i've even tried using _xscale and _yscale, tried to simply set _width, _height, and changing the order of rotation and setSize... didn't helped, the rotation is ok, but the size will be different...
i hope the problem is understandable... I cannot paste the whole source here...
thanks in advance...
assign rotation first, then dimensions.
Thanks, but changing the rotation and setsize order Does not help. Any other idea?
use the trace() function to ensure the variables are correct. if they are, check your setSize() method.
I've solved it.
the _width and _height of a textfield will return the dimensions of the smallest rectangle that can be drawen around the textbox, so if it's rotated, then it will return wrong values. All I needed to do was to save the rotation angle into a temporary value, then rotaten the textfield back to 0, THEN read the dimensions, and then rotate it back...
Thank for your help!
that's why i told you to rotate it first, then assign its dimension.
It was a good starting point, and thank you for your help, but Interestingly rotating first when setting the dimensions doesn't help. You have to rotate it back to ZERO degrees, then read the dimensions, that helps.
it shouldn't make a difference. you were rotating and then reading the width/height.
re-creating the textfield, rotating and then setting the width/height should yield the same textfield size.
i just tested that and you're correct. it doesn't yield a textfield with the same dimensions.
and what's even more bizarre is flash handles textfields and movieclips differently when re-sizing a rotated object.
I'm so tired of this unlogical behavior... I have been using a few programming languages and IDEs in my life, but actionscript is FAR the worst I've ever seen... It's illogical,IT has no IntelliSense (!!!), and debugging is a pain in the a**. No effense, but Abode could learn a LOT from microsoft's Visual Studio IDE... coding in that enviroment is a dream ;) ok, i stoped with complains, I've found another "interresting" thing though:
I used (_root._widht - window._width) / 2 and (_root._height- window._height) / 2 to place a window component on the center of the screen, and it worked FINE, until I placed a textfield object on the _root, then_root._width and _root._height started to returned an incredebly large number - It was 640px originally, and the returned value was a larger number than 10000 ??? WTF? I solved this issue by using Stage.width , but i tought it is worth mentioning.
Thanks again for Your help.
_root dimensions will depend on the objects on the _root timeline and will be (or should be) the dimensions of the smallest bounding rectangle that encompasses all objects present on the main timeline when that code executes.
You're right,but FYI the text field was placed on the center of the screen... that should not modify the _root._width to 10000px ....