![]() |
|
||||||||||
|
|
|
|||||
|
Регистрация: Jun 2007
Сообщений: 17
|
При нажатии на кнопку добавляется текстовое поле, при установке фокуса на этом поле измеряются его размеры для последующего использования. При этом удаляется мувиклип который не как с этими функциями не связан.
Скопировал пример getTextExtent из хелпа один в один та же ерунда. function newTextLayer() {
mcTools.createTextField("mcNewLayer"+LayerCount, LayerCount, 100, 100, 200, 100);
trace ("img " +_level0.img_mc) //возвращает ссылку на mc
mcTools["mcNewLayer"+LayerCount].type = "dynamic";
mcTools["mcNewLayer"+LayerCount].text = NewLayerText;
txtInput.text = mcTools["mcNewLayer"+LayerCount].text;
var textStr:String = mcTools["mcNewLayer"+LayerCount].text;
mcTools["mcNewLayer"+LayerCount].onSetFocus = function() {
var my_str:String = "Small string";
// Create a TextFormat object,
// and apply its properties.
var my_fmt:TextFormat = new TextFormat();
with (my_fmt) {
font = "Arial";
bold = true;
}
// Obtain metrics information for the text string
// with the specified formatting.
var metrics:Object = my_fmt.getTextExtent(my_str);
// Create a text field just large enough to display the text.
this.createTextField("my_txt", this.getNextHighestDepth(), 100, 100, metrics.textFieldWidth,
metrics.textFieldHeight);
my_txt.border = true;
my_txt.wordWrap = true;
// Assign the same text string and TextFormat object to the my_txt object.
my_txt.text = my_str;
my_txt.setTextFormat(my_fmt);
trace ("img " +_level0.img_mc) //возвращает undefined
};
}
что делать? кто с таким сталкивался? |
|
|||||
|
Et cetera
Регистрация: Sep 2002
Сообщений: 30,787
|
Вероятно, проблема в указанной глубине при создания текстового поля.
|
|
|||||
|
Регистрация: Jun 2007
Сообщений: 17
|
а у текста глубина 0, 1, 2 и т.д.
|
|
|||||
|
Et cetera
Регистрация: Sep 2002
Сообщений: 30,787
|
Если в проекте используются компоненты, то для работы надо использовать DepthManager вместо getNextHighestDepth().
|
![]() |
![]() |
Часовой пояс GMT +4, время: 03:12. |
|
|
« Предыдущая тема | Следующая тема » |
|
|