Форум Flasher.ru
Ближайшие курсы в Школе RealTime
Список интенсивных курсов: [см.]  
  
Специальные предложения: [см.]  
  
 
Блоги Правила Справка Пользователи Календарь Сообщения за день
 

Вернуться   Форум Flasher.ru > Flash > ActionScript 1.0/2.0

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему  
Старый 24.05.2008, 14:40
Denis Davidov вне форума Посмотреть профиль Отправить личное сообщение для Denis Davidov Найти все сообщения от Denis Davidov
  № 8  
Ответить с цитированием
Denis Davidov

Регистрация: Sep 2006
Сообщений: 89
Просто думал что это общие грабли а не мой косяк в классе...
Не хотел лишний раз напрягать людей чтением классов...

Вот класс:
Код:
import com.mosesSupposes.fuse.*;
class com.davydden.TxtField extends MovieClip {
	private var _y, _height, _x, _width;
	private var __perc:Object;//w,h,x,y coordinantes in percents of Stage, needs to reScale __perc["_x","_y","_width","_height"]=...
	private var __txt:TextField;//dynamic multiline text
	private var	__Func:Function,__scope:Object,__params:Array;//Callback
	private var __FuncH:Function,__scopeH:Object,__paramsH:Array;//Hide callback
	var __textColor;// color of the text in Hex
	var __backColor;//color of the background in Hex
	private var __backAlpha:Number;//alpha of the background
	private var __textFormat:TextFormat;//format of the text	
	private var __scale:Array;//array of strings, containig properties to rescale "_x", "_y",....
	private var __back_mc:MovieClip;//movie Clip with background
	private var __s:Object;// object with .x,.y.widht.height 
	
	function TxtField() {
		super();
		trace("TxtField:TxtField...");		
		com.mosesSupposes.fuse.ZigoEngine.register(com.mosesSupposes.fuse.Fuse, com.mosesSupposes.fuse.PennerEasing);		
	}
	function rgb2Hex(rgb) {
		if (rgb.length>1) {
			var r=rgb[0];
			var g=rgb[1];
			var b=rgb[2];
			//var hex:String = "0x"+ r.toString(16)+g.toString(16)+b.toString(16);
			//return hex;
			return (r << 16 | g << 8 | b);
		} else {
			return rgb;
		}
	}
	
	function drawBack(w:Number,h:Number) {
		trace("TxtField:drawBack:...");
		this.__back_mc=this.createEmptyMovieClip("back", 1);
		this.__back_mc._x=0;
		this.__back_mc._y=0;
		//trace("this.__back_mc :x: "+this.__back_mc["_x"]+" "+this.__back_mc["x"]);
		trace(this.__backColor);
		with (this.__back_mc) {
			beginFill(this.__backColor,100);
			moveTo(0,0);
			lineTo(w,0);
			lineTo(w,h);
			lineTo(0,h);
			endFill();
		}//end with		
		this.__back_mc._alpha=__backAlpha;
		trace("back w/h/alpha: "+this.__back_mc._width+" "+this.__back_mc._height+" "+this.__back_mc._alpha);
	}
	
	function init(_txt:String,x:Number,y:Number,w:Number,h:Number,_textColor,_backColor,_backAlpha:Number,_textFormat:TextFormat,_scale:Array) {
		trace("TxtField:init...");
		this.__s.x="width";
		this.__s.y="height";
		this.__s.width="width";
		this.__s.height="height";
		this._x=x;
		this._y=y;
		this.__textColor=rgb2Hex(_textColor);//[255, 255, 255];
		this.__backColor=rgb2Hex(_backColor);//[202, 4, 4];
		trace("__textColor: "+this.__textColor+" __backColor: "+this.__backColor);
		this.drawBack(w,h);
		trace("this w/h: "+this._width+" "+this._height);
		this.initScale(_scale);
		this.__textFormat = _textFormat;		
		this.__textFormat.color = this.__textColor;
		this.__txt = this.createTextField("txt2", this.getNextHighestDepth(), 0, 0, w,h);		
		trace("this w/h: "+this._width+" "+this._height);
		this.setText(_txt);
		this.__FuncH=undefined;
		this.__scopeH=undefined;
		this.__paramsH=undefined;
		this.__Func=undefined;
		this.__scope=undefined;
		this.__params=undefined;
		//Stage.addListener(this);		
	}
	function onResize() {
		this.scale();
	}
	function scale() {
		for (var i=0; i<__scale.length;i++) {
			var sc=__scale[i];			
			this[sc]=this.__perc[sc] * Stage[this.__s[sc]];
			trace("TxtField:scale "+i+"="+this[sc]);
        }
		trace(this["_x"]);
	}
	function setText(txt:String) {
		trace("TxtField:setText... "+txt);
		this.__txt.html = true;
		this.__txt.wordWrap = true;
		this.__txt.multiline = true;
		//this.__txt.autoSize = "left";
		this.__txt.antiAliasType = "advanced";
                this.__txt.border = false;
                this.__txt.embedFonts = true;
		this.__txt.selectable = false;
		this.__txt.htmlText=txt;
		//this.__txt.text=txt;		
		//this.__txt.setTextFormat(this.__textFormat);
		trace("TF :"+this.__textFormat);
		trace("__txt.text: "+this.__txt.text);
		trace("this.__txt.htmlTex: "+this.__txt.htmlText);
	}
	function setCallback(_Func:Function,_scope:Object,_params:Array) {
		this.__Func=_Func;
		this.__scope=_scope;
		this.__params=_params;
	}
	function setHideCallback(_Func:Function,_scope:Object,_params:Array) {
		this.__FuncH=_Func;
		this.__scopeH=_scope;
		this.__paramsH=_params;
	}
	function initScale(_scale:Array) {
		trace("TxtField:setScale..."+_scale);
		this.__scale=_scale;
		for (var i=0; i<__scale.length;i++) {
			var sc=__scale[i];
			trace(this.__s[sc]);
			trace("Stage[i] "+Stage[this.__s[sc]]);
                this.__perc[sc] = this[sc]/Stage[this.__s[sc]];
			trace("TxtField:writeScale: "+sc+":"+this.__perc[sc]);
        }	//this.hold_mc._x = this.hold_mc._x-(_root._xmouse-Stage.width/2)/20;
		trace("Stage[x]: "+Stage["width"]+" :: "+Stage.width);
	}
}
Это черновик, т.е. там много чуши и много не работает, но для текста важна функция setText в init(...). Все остальные вещи закомментины...

Во флеше это так:
Код:
var descriptS:String;
descriptS="<font face='Times New Roman' size='25'>This is how you assign HTML text to a text field.</font><br>It's very useful.</br>";
var my_format:TextFormat = new TextFormat();
my_format.font = "Times New Roman";
my_format.size = 15;
this.descriptionTxt=this.createEmptyMovieClip("dTxt",this.getNextHighestDepth());
this.descriptionTxt._x=250;
this.descriptionTxt._y=250;
this.descriptionTxt.__proto__=TxtField.prototype;
var txtW=500;
this.descriptionTxt.init(descriptS,Stage.width/2-txtW/2,0,txtW,Stage.height,[255,0,0],[98,98,98],100,my_format,["x","y","width","height"]);
Спасибо!..

Создать новую тему   Часовой пояс GMT +4, время: 22:39.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB коды Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.


 


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


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