Показать сообщение отдельно
Старый 16.07.2007, 16:04
tracert вне форума Посмотреть профиль Отправить личное сообщение для tracert Найти все сообщения от tracert
  № 1  
Ответить с цитированием
tracert

Регистрация: Jun 2007
Сообщений: 17
По умолчанию Непонятный баг getTextExtent

При нажатии на кнопку добавляется текстовое поле, при установке фокуса на этом поле измеряются его размеры для последующего использования. При этом удаляется мувиклип который не как с этими функциями не связан.

Скопировал пример 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
		
		
	};
}

что делать? кто с таким сталкивался?