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

Вернуться   Форум Flasher.ru > Flash > Flex

Версия для печати  Отправить по электронной почте    « Предыдущая тема | Следующая тема »  
Опции темы Опции просмотра
 
Создать новую тему Ответ
Старый 21.05.2010, 15:49
locust19 вне форума Посмотреть профиль Отправить личное сообщение для locust19 Найти все сообщения от locust19
  № 1  
Ответить с цитированием
locust19

Регистрация: Nov 2009
Сообщений: 55
По умолчанию Combobox переписал. не найду ошибки арея

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

определенно решение лежит тут

причем очень интересно выходит.. когда данные с dataprovider приходят. то первое поле попадает в арей [0], но увы при выборе одного элемента из бокса ничего не возвращает_ и также выбирает, но стоит для этого нажать сперва ctr и отпустить его с одним выбранным элементом

Код AS3:
override protected function keyDownHandler( event:KeyboardEvent ):void
		{
			super.keyDownHandler( event );
 
			this.ctrlKeyPressed = event.ctrlKey;
 
			if( this.ctrlKeyPressed == true ) 
			{
				dropdown.allowMultipleSelection = true;
			}
		}
 
		/**
		 * This function prevents the ComboBox from closing if CtrlKey is pressed
		 * Else it fires a Change event to update selectedItems array on close  
		 * 
		 * If CtrlKey is not pressed then, 
		 * 								ComboBox dropdown is closed and change event is dispatched.
		 * 
		 * 'dropdown' in a ComboBox is a List component
		 **/
		override protected function keyUpHandler( event:KeyboardEvent ):void
		{
			super.keyUpHandler( event );
			this.ctrlKeyPressed = event.ctrlKey;
 
			if ( this.ctrlKeyPressed == false ) 
			{
				this.close(); 
				var changeEvent:ListEvent = new ListEvent( ListEvent.CHANGE );
				this.dispatchEvent( changeEvent );
				this.selectedIndex = -1;
			}
		}
 
...
        /**
         * 'selectedItems' Setter
         **/
        public function set selectedItems( value:Array ):void
        {
            if( this.dropdown )
            {
                this.dropdown.selectedItems = value;
            }
        }
 
 
        /**
         * 'selectedItems' Getter
         **/
        [Bindable("change")]
        public function get selectedItems( ) : Array
 
        {
            if ( this.dropdown )
                return this.dropdown.selectedItems
            else
                return null;
        }
 
 
        /**
         * 'selectedIndices' Setter
         **/
        public function set selectedIndices( value:Array ) : void
        {
            if ( this.dropdown )
            {
                this.dropdown.selectedIndices = value;
            }
        }
 
 
        /**
         * 'selectedIndices' Getter
         **/
        [Bindable("change")]
        public function get selectedIndices( ) : Array
        {
            if ( this.dropdown )
                return this.dropdown.selectedIndices;
            else
                return null;
        }
}
далее следует полный код

Код AS3:
		package
{
	import flash.events.Event;
	import flash.events.KeyboardEvent;
 
	import mx.controls.ComboBox;
	import mx.events.ListEvent;
 
	public class MultiSelectComboBox extends ComboBox
	{
 
		private var ctrlKeyPressed:Boolean = false; //Control Key Pressed
 
		/**
		 * This function checks whether the CtrlKey is pressed.
		 * If CtrlKey is pressed then, 
		 *   						multiple selection is enabled for the ComboBox dropdown.
		 **/
		override protected function keyDownHandler( event:KeyboardEvent ):void
		{
			super.keyDownHandler( event );
 
			this.ctrlKeyPressed = event.ctrlKey;
 
			if( this.ctrlKeyPressed == true ) 
			{
				dropdown.allowMultipleSelection = true;
			}
		}
 
		/**
		 * This function prevents the ComboBox from closing if CtrlKey is pressed
		 * Else it fires a Change event to update selectedItems array on close  
		 * 
		 * If CtrlKey is not pressed then, 
		 * 								ComboBox dropdown is closed and change event is dispatched.
		 * 
		 * 'dropdown' in a ComboBox is a List component
		 **/
		override protected function keyUpHandler( event:KeyboardEvent ):void
		{
			super.keyUpHandler( event );
			this.ctrlKeyPressed = event.ctrlKey;
 
			if ( this.ctrlKeyPressed == false ) 
			{
				this.close(); 
				var changeEvent:ListEvent = new ListEvent( ListEvent.CHANGE );
				this.dispatchEvent( changeEvent );
				this.selectedIndex = -1;
			}
		}
 
		/**
		 * This function prevents the ComboBox from closing if CtrlKey is pressed on a Close Event
		 **/
		override public function close( trigger:Event=null ):void
		{
			if( this.ctrlKeyPressed == false )
			{
				super.close( trigger );
				this.selectedIndex = -1;
			}
		}
 
 
		/**
		 * 'selectedItems' Setter
		 **/
		public function set selectedItems( value:Array ):void
		{
			if( this.dropdown )
			{
				this.dropdown.selectedItems = value;
			}
		}
 
 
		/**
		 * 'selectedItems' Getter
		 **/
		[Bindable("change")]
		public function get selectedItems( ) : Array
 
		{
			if ( this.dropdown )
				return this.dropdown.selectedItems
			else
				return null;
		}
 
 
		/**
		 * 'selectedIndices' Setter
		 **/
		public function set selectedIndices( value:Array ) : void
		{
			if ( this.dropdown )
			{
				this.dropdown.selectedIndices = value;
			}
		}
 
 
		/**
		 * 'selectedIndices' Getter
		 **/
		[Bindable("change")]
		public function get selectedIndices( ) : Array
		{
			if ( this.dropdown )
				return this.dropdown.selectedIndices;
			else
				return null;
		}
 
		/**
		 * 'MultiSelectComboBox' constructor
		 **/		
		public function MultiSelectComboBox()
		{
			super();
		}
 
	}
}
разобрался с -1 на 1 нужно было заменить


Последний раз редактировалось locust19; 21.05.2010 в 16:51.
Создать новую тему Ответ Часовой пояс GMT +4, время: 17:09.
Быстрый переход
  « Предыдущая тема | Следующая тема »  

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

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


 


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


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