私はコードの天才ではありませんが、アクション スクリプトのファンです。これについて私を助けてもらえますか:
選択したオブジェクトに応じて、すでにステージ上にある「サブアイテム」のセットにイベント リスナーを呼び出す関数があります (複数のインスタンスと複数のコードを作成する代わりに、クリック時に変更されたパラメーターでこのサブアイテムを再利用したい) )。
したがって、選択した「ケース」ごとに、次のように、これらの「サブアイテム」に異なる変数を渡す必要があります。
function fooMenu(event:MouseEvent):void {
switch (event.currentTarget.name)
{
case "btUa1" :
trace(event.currentTarget.name);
// a bunch of code goes here
//(just cleaned to easy the view)
/*
HELP HERE <--
here is a way to pass the variables to those subitems
*/
break;
}
}
function fooSub(event:MouseEvent):void
{
trace(event.target.data);
trace(event.currentTarget.name);
// HELP PLEASE <-> How can I access the variables that I need here ?
}
btUa1.addEventListener(MouseEvent.CLICK, fooMenu);
btUa2.addEventListener(MouseEvent.CLICK, fooMenu);
btTextos.addEventListener(MouseEvent.CLICK, fooSub);
btLegislacao.addEventListener(MouseEvent.CLICK, fooSub);
誰でも私を助けてください。よろしくお願いします。:)