![]() |
|
||||||||||
|
|||||
|
Регистрация: Aug 2011
Сообщений: 50
|
СПАСИБО ОГРОМНОЕ все отлично работает!!!
Только можно еще пару вопросиков: 1.Я изменил infoblock, чтобы кнопка всегда была в закрытом состоянии, но заметил, что первое нажатие на кнопку открывает блок, а только второе вызывает функцию как можно сделать так чтобы, при первом нажатии вызывалась функция и блок не открывался при нажатии на кнопку вот infoblock.as: package { import flash.display.Bitmap; import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.events.TextEvent; /* * * * * * * * * * * * * @author wolsh * * * \* * * * * * * * * */ public class InfoBlock extends Sprite { static public const BLOCK_BUTTON_CLICKED:String = "blockButtonClicked"; private var _info:XML; private var _mode:uint = 0; private var _backgroundColor:uint = 0x000000; private var _backgroundAlpha:Number = 0.24; private var _blockWidth:Number = 400; private var _date:IconLabel; private var _name:IconLabel; private var _title:IconLabel; private var _text:TextField; private var _labelFormat:TextFormat = new TextFormat("Arial", 11, 0x000000); private var _textFormat:TextFormat = new TextFormat("Arial", 12, 0x000000); private var _hiden:Boolean = true; private var btn_tools : tools = new tools(); public function InfoBlock(info:XML) { _info = info; prepare(); setMode(0); drawBack(); } private function prepare():void { _date = new IconLabel(new Bitmap(new _dateIcon()), _info..date, _labelFormat); _name = new IconLabel(new Bitmap(new _userIcon()), _info..user, _labelFormat); _title = new IconLabel(new Bitmap(new _titleIcon()), _info..title, _labelFormat); this.addChild(_date); _date.x = 10, _date.y = 10; this.addChild(_name); _name.x = 10, _name.y = 30; this.addChild(_title); _title.x = 10, _title.y = 50; this.addChild(btn_tools); btn_tools.x = 450; btn_tools.y = 25; _text = new TextField(); _text.defaultTextFormat = _textFormat; _text.multiline = true; _text.wordWrap = true; _text.width = _blockWidth - 20; _text.htmlText = _info..message.text(); _text.height = _text.textHeight + 4; } private function setMode(mode:uint):void { if (mode == _mode) return; if (mode == 0) { this.removeChild(_text); } else { this.addChild(_text); _text.x = 10, _text.y = 70; btn_tools.addEventListener(MouseEvent.CLICK, buttonClickHandler); } _mode = mode; drawBack(); } private function buttonClickHandler(event:MouseEvent):void { event.stopImmediatePropagation(); dispatchEvent(new Event(BLOCK_BUTTON_CLICKED)); } private function drawBack():void { this.graphics.clear(); this.graphics.beginFill(_backgroundColor, _backgroundAlpha); this.graphics.drawRoundRect(0, 0, _blockWidth, this.height + 20, 12); } public function get hiden():Boolean { return _hiden; } public function set hiden(value:Boolean):void { _hiden = value; setMode(_hiden ? 0 : 1); } public function get info():XML { return _info; } } } необходимо их также объявить как btn_tools и сделать btn_one.addEventListener(MouseEvent.CLICK, buttonClickHandler_one); btn_two.addEventListener(MouseEvent.CLICK, buttonClickHandler_two); private function buttonClickHandler_two(event:MouseEvent):void { event.stopImmediatePropagation(); dispatchEvent(new Event(BLOCK_BUTTON_CLICKED_TWO)); } private function buttonClickHandler_one(event:MouseEvent):void { event.stopImmediatePropagation(); dispatchEvent(new Event(BLOCK_BUTTON_CLICKED_ONE)); } block.addEventListener(InfoBlock.BLOCK_BUTTON_CLICKED_ONE, blockButtonClickedHandler_one); block.addEventListener(InfoBlock.BLOCK_BUTTON_CLICKED_TWo, blockButtonClickedHandler_two); а и еще предположим у меня XML файл вида: Как мне вывести на экран (т.е. в _text.htmlText) Сергей и Олег? которые в <friends> Последний раз редактировалось Drac0Sha; 23.08.2011 в 11:54. |
![]() |
Часовой пояс GMT +4, время: 19:24. |
|
|
« Предыдущая тема | Следующая тема » |
|
|