• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1487
  • Last Modified:

Loading my LucidaTypewriterRegular.ttf font from the actionscript file

Dear all,

I'm trying to get the MTASC tutorial running on my Linux Kubuntu box

http://www.mtasc.org/#tutorial

but to no avail.

It does not want to display the text.

I understand that it is a font issue.

I could display a text with the following SWFMILL snippet:

<?xml version="1.0" encoding="iso-8859-1" ?>

<movie width="320" height="240" framerate="12">
  <background color="#ffffff"/>
  <frame>
    <font id="LucidaTypewriterRegular" import="LucidaTypewriterRegular.ttf" />
    <library>
      <textfield id="hellobox" width="200" height="50" size="10" font="LucidaTypewriterRegular" text="hello world!"/>
      <place id="hellobox" name="output" depth="10"/>
    </library>
  </frame>
</movie>

How can I load the LucidaTypewriterRegular.ttf font from the actionscript file..?

Note that the actionscript must compile with MTASC.

Kind Regards,

Stephane
0
stephaneeybert
Asked:
stephaneeybert
1 Solution
 
BishopNeoCommented:
You can't 'loadl' a font file from AS, you have to either create a textfield on the stage (or with AS) and set the font to Lucida and turn on embedFont, or you can create a new font file in the Library by clicking on the options menu and selecting New Font.
0
 
stephaneeybertAuthor Commented:
I run Linux and do not have Macromedia Flash.

I can only enjoy a text editor and the compiler MTASC from www.mtasc.org

As I explained above, I could create a swf file that displays some text using my own font. I did this with the swfmill compiler.

Since this swfmill tool creates a swf file from an xml text file, I assumed it could be possible to do the same thing, using some as syntax, in an actionscript file.

In that case, I would need a demo code snippet of as to create a swf displaying such a text.

Is it workable..?

Regards,

0
 
GuicCommented:
Hi,

Try this, and be sure to have "LucidaTypewriterRegular.ttf", in the same directory, or to be sure put the absolute path : "/library/fonts/...." in the import.

<movie width="320" height="240" framerate="12">
  <background color="#ffffff"/>
  <frame>
    <library>
               <font id="LucidaTypewriterRegular" import="LucidaTypewriterRegular.ttf" />
    </library>
      <textfield id="hellobox" width="200" height="50" size="10" font="LucidaTypewriterRegular" text="hello world!"/>
      <place id="hellobox" name="output" depth="10"/>
  </frame>
</movie>

Rgds
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
stephaneeybertAuthor Commented:
Hi Guic,

Is it a swfmill xml file..?

If so, thanks for it but it's not what I need.

My own swfmill xml file worked fine already.

I'm looking for its as equivalent. If such a thing is possible..

Thanks anyway!

Regards,

Stephane
0
 
GuicCommented:
"How can I load the LucidaTypewriterRegular.ttf font from the actionscript file..?"

I though you have a pb to import the .ttf.
Let me know : do you want a solution to load fonts in your actionscript ?
0
 
stephaneeybertAuthor Commented:
Hi Guic,

Sorry for any misunderstanding.. Yes to your question, I would like to load a font into my actionscript.

Have you some actionscript code snippet to spare that does just that..?

In fact, my goal is to have a "Hello world" actionscript compile in MTASC on Linux and have it display "Hello world" on the sceen.

With Linux, contrary to Windows, no fonts is pre loaded.

I therefore have to load it explicitely.

Thanks for your continuing support!

0
 
GuicCommented:
hum .
What .ttf are you using ?
Try with the lucida in the sunjava jre if you have installed it :

/usr/lib/SunJava2-1.4.2/jre/lib/fonts/LucidaTypewriterRegular.ttf

Or with a font already in your linux.
0
 
stephaneeybertAuthor Commented:
I'm using the "LucidaTypewriterRegular.ttf"

And it worked fine when being loaded from a swfmill xml file.

I loaded it like this:

<movie width="320" height="240" framerate="12">
  <background color="#ffffff"/>
  <frame>
    <library>
               <font id="LucidaTypewriterRegular" import="LucidaTypewriterRegular.ttf" />
    </library>
      <textfield id="hellobox" width="200" height="50" size="10" font="LucidaTypewriterRegular" text="hello world!"/>
      <place id="hellobox" name="output" depth="10"/>
  </frame>
</movie>
0
 
stephaneeybertAuthor Commented:
Here is the actionscript file that I have:

class HelloWorld {

  static var app : HelloWorld;

  function HelloWorld() {
    _root.createTextField("tf",0,0,0,800,600);
    _root.tf.text = "Hello world !";
  }

  static function main(mc) {
    app = new HelloWorld();
  }

}

But I don't know how to go about in order to load the LucidaTypewriterRegular.ttf font.

Any clue..?

Thanks
0
 
Gorba916Commented:
Manually embed the font inside your flash file. Try this as well.

class HelloWorld {
      static var app : HelloWorld;

      function HelloWorld() {
            _root.createTextField("tf",0,0,0,800,600);
            _root.tf.text = "Hello world !";
            _root.tf.embedFonts = true;
            _root.tf.font = "LucidaTypewriterRegular"
            _root.tf.font = "Lucida Typewriter Regular"
      }

      static function main(mc) {
            app = new HelloWorld();
      }
}

The combination of embedding the font manually and in the script should work.
0
 
stephaneeybertAuthor Commented:
I can compile your code.

But nothing appears.

I tried also by commenting out your line: _root.tf.font = "Lucida Typewriter Regular"

But I had found out some time ago that it was a font issue.

I installed the font in my system and it then worked fine.

Thanks anyway for your efforts!

Cheers

0
 
stephaneeybertAuthor Commented:
I had forgotten about this opened question.

Sorry guys for letting you out.

I feel like giving the points to Gorba916 if that's okay with you all.

Thanks
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now