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

Change fonts issue on runtime

Explorer ,
Nov 26, 2013 Nov 26, 2013

Hi

I have load system fonts and I wanna change fonts in my dynamic textbox but it dosen't work,

I take files from http://www.emanueleferonato.com/2008/05/21/create-a-font-browser-with-flash-as3/  <<< you can download source file from here

you can view my files http://www.fltech.in/fontsissue/,

here the main issue is when you change font text goes unvisible

here my code

import fl.data.DataProvider;

import flash.text.TextField;

import flash.text.TextFormat;

import flash.text.Font;

var fonts:Array = Font.enumerateFonts(true).sortOn("fontName");

var fonts_array:Array = new Array();

for (var i:int = 0; i < fonts.length; i++) {

    fonts_array.push(new String(fonts.fontName));

}

var dp:DataProvider=new DataProvider(fonts_array)

font_list.dataProvider = dp

font_list.addEventListener(Event.CHANGE, change_font);

sampletext.addEventListener(Event.CHANGE,change_text);

function change_font(event:Event):void {

    var font:TextFormat = new TextFormat();

    font.font = new String(font_list.selectedItem.data);

    displayer.setTextFormat(font);

}

function change_text(event:Event) {

    displayer.text = sampletext.text;

}

TOPICS
ActionScript
772
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
Guru ,
Nov 27, 2013 Nov 27, 2013

apart from the fact that your app won`t work the way you intend,

since flash can`t simply access the users systemfonts and use them in a textfield:

you only have embedded a subset of chatracters in your Result field.

You have to embed every possible charcter if you want to gurantee  it displayed.

Also: The change_font event somehow seems to clear the variable which holds the sample text.

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
Explorer ,
Nov 27, 2013 Nov 27, 2013

you mean if i embed the font then will it work..?,

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
Guru ,
Nov 27, 2013 Nov 27, 2013

you mean if i embed the font then will it work..?,

If you want to publish over the web, your app will not work, simply because you can`t embed every possible font every of your users might have installed.

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
Explorer ,
Nov 27, 2013 Nov 27, 2013

but same thing is working here, and I am using it's source code. please have a look.

http://www.emanueleferonato.com/2008/05/21/create-a-font-browser-with- flash-as3/

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
Guru ,
Nov 27, 2013 Nov 27, 2013

Hm, interesting, it works for me too.

Since the script is from 2008, avoid using TLF Text fields and publish to Flash 9.

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
Explorer ,
Nov 27, 2013 Nov 27, 2013
LATEST

I m already using dyamic text box with flash player 9. but nothing works for 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