Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to align XML loading text to right

Guest
Jan 07, 2009 Jan 07, 2009
Hi,

I am loading in text using XML. I have applied some simple formatting but want the text to align to the right not the left. Can anybody tell me how to do this please?

Thanks,
Mikey
TOPICS
ActionScript
1.5K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 07, 2009 Jan 07, 2009
Look into the TextFormat.align property.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 07, 2009 Jan 07, 2009
Hi,

Try this:

var myTextFormat:TextFormat = new TextFormat();
myTextFormat.align = TextFormatAlign.RIGHT;

Kind Regards,

Boxing Boom
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 07, 2009 Jan 07, 2009
hmm, I'd already tried this and it isn't giving me the effect I want. I have an image box above it and I want the end of the word each time a new word is loaded to be aligned to the right side of the box. I am autosizing the text box too. When I set sutosize to the left it is fine but when I set it to the right it seems to jump all over the place with each new word. I can't figure out what's going on with it?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 07, 2009 Jan 07, 2009
Hi,

Lets see your code ;)

Kind Regards,

Boxing Boom
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 07, 2009 Jan 07, 2009
Now I have discovered that if I remove the .x setting it stops jumping about and is aligned to the right of the text box but I can't get the text box to line up with the right side of the image box.

sorry if I am missing something obvious, it's the end of a long day!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 07, 2009 Jan 07, 2009
ok, finally I fixed it. The .x setting was in the wrong place. It was in the function and should have been outside.

Now I can go home to sleep....

Thanks for help.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 07, 2009 Jan 07, 2009
Hi,

Let us see your fix, it might help someone down the line, share your fixes ;)

Kind Regards,

Boxing Boom
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 07, 2009 Jan 07, 2009
Hi,

My code is generally very messy and long-winded but here is the section I was working on. It ended up looking like this:

function showPic(event:MouseEvent):void
{
imageLoader = new Loader();
imageLoader.load(new URLRequest(event.target.name));
imageLoader.x = 180;
imageLoader.y = 140;
addChild(imageLoader);

imageGlow.color = 0xFF9900;
imageGlow.strength = 255;
imageGlow.blurX = 10;
imageGlow.blurY = 10;
imageGlow.quality = 4;

imageLoader.filters = [imageGlow];

for(var j:int = 0; j <xmlList.length(); j++)
{
if(xmlList.attribute("source") == event.target.name)
{
imageText.text = xmlList;
imageText.y = 440;
myFormat.font = "arial";
myFormat.size = 14;
myFormat.color = 0xFF9900;
myFormat.bold = true;
myFormat.align = TextFormatAlign.RIGHT;
imageText.setTextFormat(myFormat);
}
}
}

imageText.autoSize = TextFieldAutoSize.RIGHT;
imageText.x = 555;
addChild(imageText);

Hope you find it useful.

Cheers,
Mikey
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jan 07, 2009 Jan 07, 2009
LATEST
Hi,

Nice one loki2357, that's what I'm talking about ;)

Kind Regards,

Boxing Boom
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines