View Full Version : ActionScript...
John
10th April 2007, 01:49
Hello (Glos) :)
Still working on that graph project. I've created an empty text field through ActionScript and formatted it, as per below. Do you know if it's possible to change the text direction of the text? This is for the Y-axis label, so would like it to read sideways if possible. I've Googled this and not got far, I'm not sure if it's settable on a dynamic text field. Anyway, here's the code:
var axisYMC:MovieClip = Frame.createTextField("axisYMC", Frame.getNextHighestDepth(), axisYX, axisYY, 300, 150);
axisYMC.text = axisYTitle;
style = new TextFormat();
style.bold = true;
style.size = 7;
style.font = "Arial";
axisYMC.setTextFormat(style);
color = 0x000000;
Any help would be much appreciated.
GlosRFC
10th April 2007, 02:36
Flash isn't great at text handling and you've just found out why - it can't handle vertical alignment for dynamic or input text fields.
But you can fool it:
// create a text field
this.createTextField("my_txt", 1, 100, 100, 300, 100);
my_txt.multiline = true;
my_txt.wordWrap = true;
my_txt.selectable = false;
my_txt._rotation = 90; // Amount to rotate in degrees
my_txt.autoSize = "center";
my_txt.embedFonts = true; // Tell Flash to embed the fonts in this textfield
// Apply formats
var my_fmt:TextFormat = new TextFormat();
my_fmt.color = 0xFF0000;
my_fmt.font = "arial"; // This is the Linkage Identifier name not the font name
my_txt.text = "This is a test of vertically aligned text.";
my_txt.setTextFormat(my_fmt);
Although it's not true vertical alignment, it's possible to rotate the text so that it looks like it is. Note the commented lines especially the one about the linkage name. To create this, right-click on the Library and select New Font. Give the font a library name, choose which font you want plus the other attributes and click OK. When the font appears in your Library, right-click on it, and choose Linkage. Choose Export for Actionscript and enter a unique Identifier name - this name is the one that must be the same as that stated in your code.
Actually, this effect is perfect of rotating text for graphs - 90 and 270 (or -90 and -270) are the obvious values but there's no reason why you can't use 45 :)
Can't upload the FLA as it's not recognised. Nor is a zipped folder and I haven't reinstalled Winzip yet. P.S. check your PMs too!!
John
10th April 2007, 03:13
Glos, what would I do without you?!
Thanks for that, very helpful as always. Hopefully I can get it to work troublefreesomely (is that a word?) using whatever the text is in my XML file.
P.S. I've forwarded you the FLA back. :wink
GlosRFC
10th April 2007, 08:47
Cheers John, I've got it...it was in RAR so I had to download and reinstall it anyway. Oh well!
Just a reminder - to create the pseudo-vertical text, just apply the following to your TextField instances:
embedFonts = true;
_rotation = xx;
Then link to your embedded font by applying a TextFormat to your instances:
font = "link ID name";
Win2Win
10th April 2007, 10:01
I'm sure this will be very helpful to Vegy as well. :rolleyes:
Jonny2621
10th April 2007, 10:31
I thought all forum members had to post in English ? :doh
John
10th April 2007, 13:14
They do Johnny, Keith only knows Scouse-speak though. :D
Cheers Glos, got it to work, you're a genius and that's a fact.
Win2Win
10th April 2007, 13:26
I wonder how many folk would either be out of a job, or fail Uni without this forum?
Hi Glos,
Have sent you an email. No rush; just letting you know.
Cheers.
GlosRFC
10th May 2007, 21:47
Got it...and not rushing to reply :D
silax
10th May 2007, 22:42
jesus john you're becoming a clever ass these days
Haha! That's like saying "Jesus John, you used to be so thick!" :yikes:
Cheers for the back-handed compliment. :laugh :D
Maybe I should become a teacher? :spinning
mathare
10th May 2007, 22:56
Maybe I should become a teacher? :spinningCan't be that hard if Silax can do it :D
GlosRFC
10th May 2007, 23:34
jesus john you're becoming a clever ass these days
The cleverest part is that he's actually asking me to do it for him... :ermmm
The cleverest part is that he's actually asking me to do it for him... :ermmm
But I always return the favours and more. :D
:sex1
Powered by vBulletin™ Version 4.0.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.