Hello, I’m trying to create a text with a mask animation, it works, but when I try to use a AutoSize Script the text disappears.
Any type of help is welcome!
Files: https://drive.google.com/open?id=1B1-2uEhc2nPyPzYXJ8qVaTq_IMWqHtSp
Hello, I’m trying to create a text with a mask animation, it works, but when I try to use a AutoSize Script the text disappears.
Any type of help is welcome!
Files: https://drive.google.com/open?id=1B1-2uEhc2nPyPzYXJ8qVaTq_IMWqHtSp
Try with this code:
private static function ScaleDownTextField(Input:String, Field:TextField, initialFieldWidth:int, initialFieldX:int, align:int):void
{
var wi:int = initialFieldWidth;
Field.autoSize = TextFieldAutoSize.LEFT;
Field.scaleX = 1;
Field.text = Input;
if (wi < Field.width)
{
Field.scaleX = wi / Field.width;
}
if (align == 0) //left
{
Field.x = initialFieldX;
}
if (align == 1) //center
{
Field.x = initialFieldX + (initialFieldWidth - Field.width) / 2;
}
if (align == 2) //right
{
Field.x = initialFieldX + initialFieldWidth - Field.width;
}
}
Arguments:
Hi didikunz!
Your code is working for me, but when my mask reach the last frame of the animation the text changes to the text I’ve written on Adobe Flash.
Prints: https://imgur.com/a/XjawTXA
Files: https://drive.google.com/open?id=1Mb_RUn7VYylJYdbaR27GUwajsBGserG7
Thanks!
Make sure, that the tween of the text is in one piece, use a motion tween.
Worked using a motion tween on the text’s mask!
Thanks for the help didikunz!
I have tried the script and it’s work
I wan to ask something …
Is it possible to un-overide text position
because i want to do it manual.
I try to modify the code but not success
private static function ScaleDownTextField(Input:String, Field:TextField, initialFieldWidth:int):void
{
var wi:int = initialFieldWidth;
Field.autoSize = TextFieldAutoSize.LEFT;
Field.scaleX = 1;
Field.text = Input;
if (wi < Field.width)
{
Field.scaleX = wi / Field.width;
}
}public override function SetData(xmlData:XML):void{ for each (var element:XML in xmlData.children()){ if (element.@id == "teste"){ ScaleDownTextField(element.data.@value, teks.teste, 881); } if (element.@id == "even"){ ScaleDownTextField(element.data.@value, teks2.even, 877); }
Thanks
I don‘t understand that. What do you want?
Ohh Sorry …
It mean, I wanto manage text position and align manual by maouse in Adobe Flash
not by script script in AS3. and only text width will controlled by AS3
So i try to remove this.
private static function ScaleDownTextField(Input:String, Field:TextField, initialFieldWidth:int, initialFieldX:int, align:int):void
if (align == 0) //left
{
Field.x = initialFieldX;
}
if (align == 1) //center
{
Field.x = initialFieldX + (initialFieldWidth - Field.width) / 2;
}
if (align == 2) //right
{
Field.x = initialFieldX + initialFieldWidth - Field.width;
}
and
ScaleDownTextField(element.data.@value, teks.team2, 498**, 645, 3**); // lebar max, position in symbol,
align
You can get rid of all that code, when you want to manage everything by yourself. If you want to have the scaling functionality you need to keep the code. The problem is, that to be able to scale the text, the textfields alignment property get lost, because the autoSize property actually only work as expected when set to TextFieldAutoSize.LEFT
.
The code you use is an old version of that function, that only can handle left aligned text. Today I normally use the code bellow:
private static function ScaleDownTextField(Input:String, Field:TextField, initialFieldWidth:int, initialFieldX:int, align:int):void
{
var wi:int = initialFieldWidth;
Field.autoSize = TextFieldAutoSize.LEFT;
Field.scaleX = 1;
Field.text = Input;
if (wi < Field.width)
{
Field.scaleX = wi / Field.width;
}
if (align == 1) //center
{
Field.x = initialFieldX + (initialFieldWidth - Field.width) / 2;
}
if (align == 2) //right
{
Field.x = initialFieldX + initialFieldWidth - Field.width;
}
}
It has the align
parameter. Set it to 0 for left align, to 1 for center align and to 2 for right align. The initialFieldWidth
parameter defines the maximum width the field can grow (it is, what it is initially set to in the designer) and the initialFieldX
is the X-coordinate the field has been set in the designer. These two parameters are necessary to scale the field and keep it at it’s place.
Thanks Didi