Просмотр полной версии : Вложенные кнопки
Сложно озаглавить тему, но пусть так.
Есть два клипа. mc1 и mc2. mc1 суть родитель для mc2
function Over()
{
trace(this);
}
mother = mc1;
child = mc1.mc2;
mother.onRollOver = Over;
child.onRollOver = Over;
mc2 игнорирует события мыши, пока на mc1 есть какой-либо обработчик. Как это обойти?
Смог обработать клик и onRollOver на mother и child (клик на родительском здесь не показан ибо нет смысла)
function Over()
{
trace(this);
this.onMouseMove = function()
{
if (child.hitTest(_root._xmouse, _root._ymouse))
{
trace(child);
delete this.onMouseMove;
}
};
this.onMouseUp = function()
{
if (child.hitTest(_root._xmouse, _root._ymouse))
{
trace("Клик по child");
}
};
}
mother = mc1;
child = mc1.mc2;
mother.onRollOver = Over;
//
mother.onRollOut = function()
{
trace("мышь вне mother");
};
delete this.onMouseMove; - неспроста, ибо мне надо лишь зарегистрировать попадание мыши на child. Как после всего этого отследить, что мышь ушла с child (симуляция onRollOut)?
Добавлено через 18 минут
Простите, поспешил с вопросом. Достаточно было подумать над проверкой:
function Over()
{
var mouseOnChild = false;
trace(this);
this.onMouseMove = function()
{
if (child.hitTest(_root._xmouse, _root._ymouse) && mouseOnChild == false)
{
trace("Мышь на child");
mouseOnChild = true;
}
if (!child.hitTest(_root._xmouse, _root._ymouse) && mouseOnChild == true)
{
trace("Мышь вне child");
mouseOnChild = false;
}
};
this.onMouseUp = function()
{
if (child.hitTest(_root._xmouse, _root._ymouse))
{
trace("Клик по child");
}
};
}
mother = mc1;
child = mc1.mc2;
mother.onRollOver = Over;
//
mother.onRollOut = function()
{
trace("мышь вне mother");
};
mooncar, большое спасибо за исчерпывающий ответ
Вот, приводил пример (http://www.flasher.ru/forum/showpost.php?p=1080417&postcount=2). Может пригодится.
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.