PDA

View Full Version : Attribute used outside class


ikee
02-28-2009, 01:44 AM
Hi!

I'm really new to using the actionscript of macromedia flash, and i hope someone could help me out. i think my problem can be solved pretty easily anyway; im just not that used to using the language yet.

I'm currently working on a script with arrays. the excerpt of the code is shown below.

import mx.controls.*;

var switch_but:Button;
switch_but.label="switch";
var array=new Array(10);
for(var 1=0; i<10; i++){
array[i]=0;
}

switch_but.clickHandler=function(evt:Object){

array=evt.target._parent.array;
var rand=random(10);

if(array[rand]==0){

array[rand]=1;
gotoAndPlay(25);

}

basically, if array[rand] is already equal to 1, flash should play from frame 25. the problem is, after the gotoAndPlay line, the array 'refreshes' itself and all values become 0 again. if i removed the line, the values would be retained. can anyone tell me how to retain the values of the array, even as the gotoAndPlay line is accessed? i was thinking of declaring the array as static as in java, but the error 'Attribute used outside class.' is incurred. maybe static is just not the right way to do it?

i hope it's clear enough. ask me for any further details i should discuss. thanks a lot! :)

kkbbcute
03-01-2009, 12:19 PM
Make the attribute global, although I didn't really catch your problem but I answered based on your title.:confused: