Categories

XML Flash. How to enable RTL support

Chris Diaz March 14, 2012
No votes yet.
Please wait...

This tutorial shows how to convert XML Flash template to RTL.

1) Open your FLA file and go to File >> Publish settings and select Flash tab, then set Flash player to version 10 or higher

2) In the FLA file in Flash CS5 or Flash CS 5.5 and locate your fonts in the library, doubleclick it and select actions tab

you will be able to see several check boxes like “export for ActionScript” and “export in frame 1? – you need to check both and select “TFL” in Outline Format at the top of the actionscript tab.

It is very important to do this step for all the fonts in the template.

3) Open you “main.as” file and add the following function at the top:

private function createTLF(_textField:TextField, _content:String):void
  {
  var TLF_Text:TLFTextField = new TLFTextField();
  var newTextFormat:TextFormat = new TextFormat ;
  newTextFormat = _textField.getTextFormat();
  TLF_Text.antiAliasType = _textField.antiAliasType;
  TLF_Text.embedFonts = _textField.embedFonts;
  TLF_Text.width = _textField.width;
  TLF_Text.x = _textField.x;
  TLF_Text.y = _textField.y;
  TLF_Text.rotation = _textField.rotation;
  if (_textField.multiline)
  {
  TLF_Text.height = _textField.textHeight + newTextFormat.size + newTextFormat.leading;
  }
  TLF_Text.setTextFormat(newTextFormat);
  TLF_Text.htmlText = _content;
  MovieClip(_textField.parent).addChild(TLF_Text);
  MovieClip(_textField.parent).removeChild(_textField);
}

3) Regularly text fields have such function in AS file:

public function textContent(nameText:TextField, numText:Number)
  {
  nameText.htmlText = websiteXML.pages.titlePage[linkPage].texts.pageText[numText].text();
  nameText.addEventListener( TextEvent.LINK, textLinkClick );
  nameText.mouseWheelEnabled = false;
  nameText.condenseWhite = true;
  if (nameText.multiline)
  {
  var fmt:TextFormat = nameText.getTextFormat();
  nameText.height = nameText.textHeight + fmt.size + fmt.leading;
  }
  else
  {
  nameText.autoSize = TextFieldAutoSize.LEFT;
  }
}

You should call TFL function at the end and make it look like:

public function textContent(nameText:TextField, numText:Number)
  {
  nameText.htmlText = websiteXML.pages.titlePage[linkPage].texts.pageText[numText].text();
  nameText.addEventListener( TextEvent.LINK, textLinkClick );
  nameText.mouseWheelEnabled = false;
  nameText.condenseWhite = true;
  if (nameText.multiline)
  {
  var fmt:TextFormat = nameText.getTextFormat();
  nameText.height = nameText.textHeight + fmt.size + fmt.leading;
  }
  else
  {
  nameText.autoSize = TextFieldAutoSize.LEFT;
  }
createTLF(nameText, nameText.htmlText);
}

This like has the following varibale that may differ depending on the text you implement it, as you can see our currect text variable is: nameText, so if we have “readmoreText”, then our function would look like:

  createTLF(readmoreText, readmoreText.htmlText);
This entry was posted in Working with XML Flash and tagged flash, RTL, XML. Bookmark the permalink.

Submit a ticket

If you are still unable to find a sufficient tutorial regarding your issue please use the following link to submit a request to our technical support team. We'll provide you with our help and assistance within next 24 hours: Submit a ticket