I have a var to get thumbnails width, and it’s set at the beggining of my class code.
var thumbW:Number;
Then I update that var inside a function that updades with stage resize.
function x(){
var thumbW:thumbnails.width;
//tracing thumbW here returns the updated value. Perfect!
}
Then I try to get the thumbW value inside a function that scrolls the thumbnails
function y(){
trace(thumbW);
}
But, in y function, it only returns NaN, aka Not a Number, telling me that the value for that variable is not set nor updated.
I’m wondering why this is happening? Why I can’t update this var? How can it be done?
There is something wrong in your function x.
If you want to access the global variable thumbW, you should direct use it like
thumbW = 123. Usingvarwill declare another local variable inside the function.And, why you put the flag
thumbnails.width? There should be compiler error! Typo?The whole code for function x should be:
BTW, you should learn more about variable scope. There is an article from adobe help.