Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   [as1] Actionscript1&ComboBox&Flash8 (http://www.flasher.ru/forum/showthread.php?t=79717)

BorisL 14.05.2006 15:06

[as1] Actionscript1&ComboBox&Flash8
 
Здравствуйте всем!
Снова проблема с actionscrip1.0 в восьмерке.
Использую компонент ComboBox. Родной "Восьмерочный" CB при actionscript1.0 не работает, поэтому ComboBox взял из Flash MX.
В таком случае сам компонент работает, данные в него грузятся, но почему-то не получается контролировать события на компоненте, то есть на такой код (из хелпа):
Код:

myObject = new Object();
myObject.myHandler = function(component){
            trace(toyList.getSelectedItem().label);
}
toyList.setChangeHandler("myHandler", myObject);

просто никакой реакции. В MX такой код отрабатывает.
Подскажите чего я недопонимаю:)

Nirth 14.05.2006 16:21

я не работал с компонентами MX но мне кажеться у тебя проблема с областью видимости.

попробуй дать абсолютную ссылку к toyList

PS на AS1 можно писать и при настройках AS2

BorisL 14.05.2006 16:52

Цитата:

Сообщение от Nirth
я не работал с компонентами MX но мне кажеться у тебя проблема с областью видимости.

попробуй дать абсолютную ссылку к toyList

Спасибо, попробую.

Цитата:

Сообщение от Nirth
PS на AS1 можно писать и при настройках AS2

Да, я знаю, но проект изначально делался не мной, я его дорабатываю. При установке настроек AS2 появляется куча глюков, которые проблемно править, исходник ужасный:)

Nirth 14.05.2006 16:56

а можешь дать цитату референса для setChangeHandler ?
а то в нете уже нету хелпа для MX .

BorisL 14.05.2006 17:02

Цитата:

Сообщение от Nirth
а можешь дать цитату референса для setChangeHandler ?
а то в нете уже нету хелпа для MX .

Конечно:

Availability

Flash Player 6.

Usage

myComboBox.setChangeHandler(functionName, [location])

Parameters

functionName A string specifying the name of the handler function to execute when the selection in the combo box changes. If the location parameter is not specified, this function must be in the same Timeline as the component instance.

location A path reference to a data object, movie clip, or Timeline that contains the specified function. This parameter is optional and defaults to the parent Timeline of the component.

Returns

Nothing.

Description

Method; specifies a change handler to call when the selection in the combo box changes. You can specify the same change handler function for more than one component; the function always accepts the instance of the component that has changed as a parameter. Calling this method overrides the Change Handler parameter value specified in authoring.

For more information, see Using Components chapter of Using Flash.

Example

The following code specifies myHandler as the function called when the value of toyList changes. Because the location parameter is not specified, myHandler must be in the same Timeline as the component instance.

The component parameter in myHandler is automatically filled in with the instance of a component (the component that has changed as the result of user input and that specifies myHandler as its change handler). The actions defined in myHandler specify that when the user selects an item in the list, the label of the item is written to the Output window.

toyList.setChangeHandler("myHandler");
function myHandler(component){
trace(toyList.getSelectedItem().label);
}

If in the preceding example myHandler is a function located in the great-grandparent Timeline of the component's Timeline, the first line of code would be as follows:

toyList.setChangeHandler("myHandler", _parent._parent._parent);

The following code creates the function myHandler in an instance of myObject (which is of class Object), and then specifies myHandler as the function for toyList.

myObject = new Object();
myObject.myHandler = function(component){
trace(toyList.getSelectedItem().label);
}
toyList.setChangeHandler("myHandler", myObject);

Nirth 14.05.2006 17:08

попробуй так
Код:

listener = new Object();
listener.onChange = function(component){
trace(component.getSelectedItem().label);
}
toyList.setChangeHandler("onChange", listener);

я назваие обработчика и листенера изменил, все эти myObject и тд глаза раздражают лично мне

BorisL 14.05.2006 17:22

Цитата:

Сообщение от Nirth
попробуй так

Не получилось, то есть в MX работает, в восьмерке не реагирует...
Может старые компоненты вообще в восьмерке не работают? Но ведь данные из массива в него запихать получилось...

aksios 14.05.2006 17:32

Цитата:

Сообщение от BorisL
Не получилось, то есть в MX работает, в восьмерке не реагирует...
Может старые компоненты вообще в восьмерке не работают? Но ведь данные из массива в него запихать получилось...

А енти компоненты написаны под 6 плеер - компелить надо как 6 и лучше в MX. Ваще проще взять алтернативный ComboBox - их довольно много, но там можно будет код руками поправить и под 8 если што.

Nirth 14.05.2006 17:38

лично мне больше всего нравиться v2 комбобокс, из за возможности менять cellRenderer

BorisL 14.05.2006 17:40

Цитата:

Сообщение от Nirth
лично мне больше всего нравиться v2 комбобокс, из за возможности менять cellRenderer

Хорошо, попробую. Подскажите где их берут:) Я редко компонентами пользуюсь, особенно чужими.


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

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