Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   не меняется шрифт (http://www.flasher.ru/forum/showthread.php?t=169603)

areostar 08.10.2011 12:04

не меняется шрифт
 
Хочу вывесть на экран простенькие часики:

Код AS3:

public class clock extends MovieClip 
        {
                var graficPoint:Shape = new Shape();
                var _text:TextField = new TextField();
                var _format:TextFormat = new TextFormat();
 
                var clock_timer:Timer = new Timer(1000);
 
                public function clock()
                {
                        _format.size = 20;
                        _format.color = 0x00f088;
                        _format.bold = true;
                        _format.font = "Rosewood Std";
 
                        clock_timer.addEventListener(TimerEvent.TIMER, clock_timer_function);
                        clock_timer.start();
                }
 
        public function clock_timer_function(e:TimerEvent):void
                {
                        var myTime:Date = new Date();
                        var theSeconds = myTime.getSeconds();
                        var theMinutes = myTime.getMinutes();
                        var theHours = myTime.getHours();
 
                        var theDay = myTime.getDay();
                        var theMonth = myTime.getMonth();
                        var theYear = myTime.getFullYear();
 
                        var time_string = "";
                        if(theHours < 10) { time_string += "0" + theHours + ":"; }
                        else time_string +=  theHours + ":";
                        if(theMinutes < 10) { time_string += "0" + theMinutes + ":"; }
                        else time_string +=  theMinutes + ":";
                        if(theSeconds < 10) { time_string += "0" + theSeconds; }
                        else time_string += theSeconds;
                        _text.text = time_string; _text.setTextFormat(_format);
 
                        _text.x = 5; _text.y = 5; addChild(_text);
                }
        }
}

всё в порядке то только шрифт остаётся по умолчанию!? :мда: что делать!?

stweet 08.10.2011 12:10

Код AS3:

_format.font = "Rosewood Std"; // точно в системе есть такой шрифт?

смею предположить что ваш ролик не видит шрифта. попробуйте простой "Arialbd" если прокатит значит проблема в пути к файлу а там и имя файла роль играет, с пробелами в именах проблематично.

Добавлено через 11 минут
Код AS3:

package 
{
        import flash.display.MovieClip;
        import flash.display.Shape;
        import flash.events.TimerEvent;
        import flash.text.TextField;
        import flash.text.TextFormat;
        import flash.utils.Timer;
 
        public class clock extends MovieClip {
 
                private var graficPoint        :Shape        = new Shape();
                private var _text                :TextField        = new TextField();
                private        var _format        :TextFormat= new TextFormat();
 
                private        var clock_timer:Timer = new Timer(1000);
 
                public function clock()
                {
                        _format.font        = "Arial";
                        _format.size        = 20;
                        _format.color        = 0x808080;
                        _format.bold        = true;
                        _format.italic        = true;
 
                        _text.defaultTextFormat = _format;
                        _text.autoSize = "left";
 
                        _text.text = "ShOw TEST font:\t00:00:00";
 
                        _text.x = 5;
                        _text.y = 5;
 
                        addChild(_text);
 
                        clock_timer.addEventListener(TimerEvent.TIMER, clock_timer_function);
                        clock_timer.start();
                }
 
                public function clock_timer_function(e:TimerEvent):void
                {
                        var myTime                :Date        = new Date();
 
                        var theSeconds        :Number        = myTime.getSeconds();
                        var theMinutes        :Number        = myTime.getMinutes();
                        var theHours        :Number        = myTime.getHours();
 
                        var theDay                :Number        = myTime.getDay();
                        var theMonth        :Number        = myTime.getMonth();
                        var theYear                :Number        = myTime.getFullYear();
 
                        var time_string        :String = "";
 
                        if (theHours < 10)
                                time_string += "0" + theHours + ":";
                        else
                                time_string +=  theHours + ":";
 
                        if (theMinutes < 10)
                                time_string += "0" + theMinutes + ":";
                        else
                                time_string +=  theMinutes + ":";
 
                        if (theSeconds < 10)
                                time_string += "0" + theSeconds;
                        else
                                time_string += theSeconds;
 
 
                        _text.text = "ShOw TEST font:\t" + time_string;
                }
        }
}


areostar 08.10.2011 12:43

_format.font = "Rosewood Std"; // точно в системе есть такой шрифт?

Но в графическом режиме он есть! и работает!

чтото не выходить ни чего!

stweet 08.10.2011 12:54

Цитата:

Сообщение от areostar (Сообщение 1037793)
_format.font = "Rosewood Std"; // точно в системе есть такой шрифт?

Но в графическом режиме он есть! и работает!

чтото не выходить ни чего!

грузите шрифт в приложение.

Код AS3:

[Embed(source = 'сюда вписываем путь к файлу', fontFamily = 'arial', embedAsCFF = 'false')] private var NeedFont:Class;

а в конструкторе пишим

Код AS3:

 
Font.registerFont(NeedFont);
 
_text.embedFonts = true;

Плюс, импорт библиотеки "Font" Если в Адобефлешь пишите то импорт не нужен. Там вообще как то по иному можно зарегистрировать шрифт.

areostar 08.10.2011 14:04

а в ситеме этот шрифт лешит или скачать шрифт!?

Добавлено через 2 минуты
Да я работаю в адоб флеш профешинл

TWETTI 08.10.2011 14:31

Чтобы вставить шрифт в SWF файл для его корректного отображения нужно сделать следующее:
1. В панели Properties нажать кнопку Embed.

[IMG]http://dl.************/u/4366487/1.png[/IMG]

2. Указать какие символы будут использоваться. Для русских символов нужно поставить галочку напротив слова Cyrillic.

[IMG]http://dl.************/u/4366487/2.png[/IMG]

TanaTiX 08.10.2011 14:35

И еще почитайте про defaultTextFormat.


Часовой пояс GMT +4, время: 04:51.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.