Copy link to clipboard
Copied
I could not realize how should I resize my TLF Textfiels in flash cs6 with actionscript??
None of these worked:
if (....)
{
myTLFText.textSize++;
myTLFText.fontSize++;
}
Error: Access of possibly undefined property size through a reference with static type fl.text:TLFTextField.
I appreciate your kind help please??
setting width/height is no help. use scaleX and scaleY like i suggested.
Copy link to clipboard
Copied
you can control the font size using a textformat instance and applying the textformat instance to your textfield:
var tfor:TextFormat=new TextFormat();
var i:int = 1;
while(myTLText.width<300)
{
tfor.size=i;
myTLFText.setTextFormat(tfor);
i++;
}
Copy link to clipboard
Copied
Thanks a lot for your kind reply. Now I can change the Font size.
but still the bigger problem is my text contains many different text formats
(some words are BOLD, some parts are RED, some words have different Fonts!.) and all are gathered in a TLF Text field called "myTLFText".
When I apply a new Font size, for example:
var tfor:TextFormat=new TextFormat();
tfor.size = 30;
myTLFText.setTextFormat(tfor);
Then all the previous formats are lost! Default Font, Color and Font size of 30 will be applied.
In Microsoft word, when you sellect a paragraph and press " Crtl + ] " or " Ctrl + [ ", it keeps all the Fonts, colors, Bold, Italic, etc. in your selection, and increase or decrease only the Font size all together!
Is this also possible in Flash TLF Text Fields or I'm expecting a lot from Flash??
Copy link to clipboard
Copied
try:
while(myTLFText.width<300){
myTLFText.scaleX+=.1;
myTLFText.scaleY+=.1;
}
Copy link to clipboard
Copied
Thanks alot for your kind reply again and YES it works!! The problem is with My App design that it Auto-Fit the width and height based on screen size (for mobile apps) and therefore I need to really change the Font size (pt) of texts inside the RTLTextField, rather that resizing it in X and Y. (When I resize with your formula, again it FITS back to the screen size).
So i will try to fix it myself and once again thank you for your time and effort.
I will post the result here hopefully as soon as I realize:
How can I change the Point size of Text by ActionScript (RED ARROW below😞
Copy link to clipboard
Copied
Thanks alot for your kind reply again and YES it works!!
The problem is with My App design that it Auto-Fit the width and height based on screen size (for mobile apps) and therefore I need to really change the Font size (pt) of texts inside the RTLTextField, rather that resizing it in X and Y. (When I resize with your formula, again it FITS back to the screen size).
what code are you using to resize the textfield and what do you want that code to do?
How can I change the Point size of Text by ActionScript (RED ARROW below😞
again, you can control the font size using a textformat instance and applying the textformat instance to your textfield:
Copy link to clipboard
Copied
Here is the part of code I am using to resize the textfield (and other elements).
/******SET POSITION**********/
function setPosition():void
{
//Position appBG
appBG.height = stage.stageHeight;
appBG.width = appBG.height;
//Fit the appTXT in middle of screen (AppTXT is a MovieClip contains sourceText - RTLTextField)
appTXT.sourceText.width = stage.stageWidth * 0.9;
appTXT.sourceText.x = stage.stageWidth * 0.05;
appTXT.sourceText.y = stage.stageHeight * 0.1;
//Fit the maskText layer on top of text;
maskText.width = appTXT.sourceText.width;
maskText.height = stage.stageHeight * 0.8;
maskText.x = stage.stageWidth * 0.05;
maskText.y = stage.stageHeight * 0.1;
//Set buttons in their proper position
...
if (stage.stageWidth > stage.stageHeight)
{
appBG.width = stage.stageWidth;
appBG.height = appBG.width;
}
appBG.x = stage.stageWidth / 2;
appBG.y = stage.stageHeight / 2;
}
Everything works fine, but when I install the apk on my Google nexus (800x1280), the font size looks VERY SMALL and I can hardly read it!
If I increase the Font size pt (Red Arrow in above PrntScr) to 40. then it reads perfect on phones with 800x1280 screen size. Ok? But then any OTHER smaller screen cell phones will see the font TOO BIG!
So I need to set the Font size pt by CODE based on a percent of stageWidth to could solve this. thx.
Copy link to clipboard
Copied
setting width/height is no help. use scaleX and scaleY like i suggested.
Copy link to clipboard
Copied
wow! now I got what you mean!! Yes, I need to re-write the code for positioning the text based on scaleX and scaleY!
thanks a lot!
It will solve my problem.
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now