Просмотр полной версии : onRollOver на любую кнопку
Если в _root лежат button1, button2, button3 и т.д. сколько бы их ни было, как сделать onRollOver, обращающийся к ТОЙ из них, на которую наведен курсор (на что каждая кнопка реагирует соответственно выдачей значения переменной current_button = 1, или 2, или 3 соответственно). ...спасибо
var i:Number = 0;
while (true) {
if ( !this['button_' + i] ) break;
this['button_' + i].index = i;
this['button_' + i].onRollOver = function():Void {
trace(this.index);
}
i++;
}
var i: Number = 0;
var button: Button;
while (button = this['button_' + i]) {
button.index = i;
button.onRollOver = function():Void {
trace(this.index);
}
i++;
}
for (var i:Number = 0; i < 10; i++) {
this['button_' + i].index = i;
this['button_' + i].onRollOver = function():Void {
trace(this.index);
}
}
если я использую второй по счету скрипт, как мне скомандовать всем прочим кнопкам кроме активной сделать что-нибудь?
с _parent['button_text' + i] не получается.
if ( !this['button_text' + i] ) break;
this['button_text' + i].index = i;
this['button_text' + i].onRelease = function():Void {
var Nr:Number = this.index - 1
_root.swf03.gotoAndPlay("produkt_wechsel");
_root.placeholder_produkt.loadMovie(product_picture[Nr]);
whoIsOn = this.index - 1
On(this)
//Off (_parent['button_text' + i]) ---------------> ?????
//trace(this.index);
}
lexa2000lexa
08.07.2009, 20:27
var i:Number = 0;
var but:MovieClip;
while (but = this["but_" + i]) {
but.index = i;
but.onPress = function():Void {
trace(this.index);
this._alpha = 100;
for(var j:Number =0;j<i;j++){
var but:MovieClip = this._parent["but_" + j]
if(j!=this.index){
but._alpha = 30;
}
}
}
i++;
}
Спасибо, lexa2000lexa, все функционирует замечательно. Только как мне подцепить эти кнопки функцией?
функции:
function On (buttonName) {
var getred:Transform = new Transform(buttonName);
var redColorTransform:ColorTransform = new ColorTransform(1, 0, 0, 1, 255, 0, 0, 0);
getred.colorTransform = redColorTransform;
}
function Off (buttonName) {
var getback:Transform = new Transform(buttonName);
var blackColorTransform:ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
getback.colorTransform = blackColorTransform;
}
скрипт:
var i:Number = 1;
var but:MovieClip;
while (but = this["button_text" + i]) {
but.index = i;
but.onRelease = function():Void {
trace(this.index + " this.index ");
On( ????????????? )
//this._alpha = 100;
for(var j:Number =0;j<i;j++){
var but:MovieClip = this._parent["button_text" + j]
if(j!=this.index){
Off ( ???????????? )
}
}
}
i++;
}
Можно вообще без индексов обойтись.
import flash.geom.ColorTransform;
var RED: ColorTransform = new ColorTransform(1, 0, 0, 1, 255, 0, 0, 0);
var BLACK: ColorTransform = new ColorTransform(1, 1, 1, 1, 0, 0, 0, 0);
var app: MovieClip = this;
AsBroadcaster.initialize(this);
var i: Number = 1;
var but: MovieClip;
while (but = this["button_text" + i++]) {
app.addListener(but);
but.transform.colorTransform = app.BLACK;
but.release = function(target:MovieClip):Void {
this.transform.colorTransform = this === target ? app.RED : app.BLACK;
};
but.onRelease = function():Void {
app.broadcastMessage('release', this);
};
}
ругается на строчку
but.transform.colorTrasform = app.BLACK;
(нет св-ва с именем" colorTransfrom")
не понятно, почему...
Опечатка colorTrasform => colorTransform
Работает на vBulletin ® версия 3.7.3. Copyright ©2000-2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Copyright © 1999-2008 Flasher.ru. All rights reserved.