Ask a Question related to Macromedia Flash Actionscript, Design and Development.
-
RusD #1
Re: the "I" scope in (for....) statement
kglad wrote:
It's all fine with all this. Try to trace 'i' variable and you'l> first, if you set a movieclip's _visible property to false or zero, it can't
> detect any mouse events. to remedy set it's _alpha to zero. second, you have
> coding errors in that script, not the least of which is that setRGB() is
> already a flash method.
>
understand it.
This is correct code :
for(var i=1; i<5; i++) {
_root["b"+i].pair_mc = _root["m"+i];
_root["b"+i].onRollOver=function(){
trace(i+' '+this.pair_mc);
this.pair_mc.setRGB(0xFFFFFF);
}
_root["b"+i].onRollOut=function(){
this.pair_mc.setRGB(0x006600);
}
}
RusD Guest
-
Application.xml -> Process -> Scope ; "app" disturbs FMSconsole
Hi, I'm not sure if this is a bug related to version 2.0.1 but if we enable "app" scope in Application.xml (Application.xml -> Process -> Scope)... -
How can I callError ocurring when Event Listener methodein "for statement" is called
Hy guys, I would be gratefull if somebody could answer me how can I call a method from flex in "for statement", that is actually in my remote... -
Flash Remoting and a CFC's "this" scope
FYI - When accessing a CFC via Flash Remoting, you are making a static call, not creating an instance. This can be worked around however. You... -
What is postgresql doing for "statement: commit;begin;"
Hi All I've turned on slow query reporting via log_min_duration_statement, and I've been looking through the log files. Quite a lot, I'm... -
execute + ArraySearch causes "Expected end of statement" error - Why?
Here is the function ArraySearch: '-------------------------------------------------------------------------------------- 'ArraySearch will... -
liangshun #2
the "I" scope in (for....) statement
Hello everyone, I have some problem with the (for ... ) statement.. Basically,
I have 4 invisible movie clip in the stage, they are named b1, b2, b3, b4,
and another 4 movie clip in the stage, they are named m1, m2, m3, m4.
What I want to achieve is when I rollover those invisible movie clip (b1,
b2...), the other movie clip (m1, m2... ) change color, but it seems doesn't
work..... I am wondering if this is something have to do with the scope of
the "i"....
I attached the AS here...
Any help will be appreciated.
Sam
MovieClip.prototype.setRGB=function(col){
(new Color(this)).setRGB(col);
}
for(i=1; i<5; i++) {
_root["b"+i].onRollOver=function(){
_root["m"+i].setRGB(0xFFFFFF);
}
_root["b"+i].onRollOut=function(){
_root["m"+i].setRGB(0x006600);
}
}
liangshun Guest
-
kglad #3
Re: the "I" scope in (for....) statement
first, if you set a movieclip's _visible property to false or zero, it can't
detect any mouse events. to remedy set it's _alpha to zero. second, you have
coding errors in that script, not the least of which is that setRGB() is
already a flash method.
kglad Guest
-
kglad #4
Re: the "I" scope in (for....) statement
now, you're introducing addtional errors. i is not a persistant variable. if
you want to retreive the "i" associated wiht each of your movieclips you'll
need to store its value in a persistant variable. try:
for (var i = 1; i<5; i++) {
_root["b"+i].pair_mc = _root["m"+i];
_root["b"+i].iVar=i;
_root["b"+i].onRollOver = function() {
trace(this.iVar+' '+this.pair_mc);
this.pair_mc.setRGB(0xFFFFFF);
};
_root["b"+i].onRollOut = function() {
this.pair_mc.setRGB(0x006600);
};
}
and you're still using setRGB() incorrectly. it's not a movieclip method,
it's a color method. see the correct use above.
kglad Guest
-
kglad #5
Re: the "I" scope in (for....) statement
in fact, just copy and paste this code into your movie and try it:
MovieClip.prototype.colorChange = function(col) {
myC = new Color(this);
myC.setRGB(col);
};
for(i=1; i<5; i++) {
_root["b"+i].onRollOver=function(){
_root["m"+i].colorChange(0xFFFFFF);
}
_root["b"+i].onRollOut=function(){
_root["m"+i].colorChange(0x006600);
}
}
kglad Guest
-
liangshun #6
Re: the "I" scope in (for....) statement
Thanks a lot ! it works perfect now. ..... I have much better understanding of nested function now.....
Cheers!!
Sam
liangshun Guest
-
liangshun #7
Re: the "I" scope in (for....) statement
Thanks a lot , RusD, kglad!!
Cheers!
Sam
liangshun Guest
-
kglad #8
Re: the "I" scope in (for....) statement
you're very welcome and good luck, sam!
kglad Guest
-
RusD #9
Re: the "I" scope in (for....) statement
kglad wrote:
I placed tracing of 'i' variable just to show error. I thought it's clear
RusD Guest
-
liangshun #10
Re: the "I" scope in (for....) statement
hi RusD, kglad, thanks again for the very helpful explaination.
this line is the key..... :
_root["b"+i].pair_mc = _root["m"+i];
Cheers.
Sam
liangshun Guest



Reply With Quote

