I've encountered another problem. The following code does not mention that I have a MovieClip in the Library set up with its class as my_class. I drag it onto the stage and name it my_object. When I try to use the my_array property it does not work. The class includes a boolean property that works fine, so I concluded that my arrays must be discombobulated. I also tested a string property and it works. Plz help? :confused; /////--------- class my_class extends MovieClip var my_array:Array; } /////--------- //my_object <- is instance of my_class my_object.my_array[0] = "rasin"; trace(my_object.my_array[0]) // returns undefined. why?
you've got to instantiate the my_array variable as a Array rather than just typecasting it. so change var my_array:Array; to var my_array:Array = [];
Omg. I fiddled with this and apperently did just that. That would explain why it's doing soemthing now, It's still not working properly. I have three objects, and I set the first spot in each to three different things, but when I trace them all of the array values are set to the same value as the last object. No code modifies them after they are set. I checked.
Each object should have a unique array property, but it behaves like the property is the same for all objects. What I mean is when I change the array at postion 0 for each object, it acts like I'm modifying the same array value three times. Why isn't it independent?
Okee... The class is shown. There is a movie clip in the library with its class set to "crate." I drag an instance of this MovieClip into another clip and say the code following the class. I get "item2" and not "item1." ///////// class crate extends MovieClip { var contents:Array = new Array(); } ///////// crate1_mc.contents[0] = "item1"; crate2_mc.contents[0] = "item2"; trace(crate1_mc.contents[0] ); //< returns "item2." why?
Having just finished my only AS side project, I will now attempt this the hard way. I'm going to create five different string properties for the crate class, and use those instead. And if that doesn't work I'll have to go back to that one animation I was doing.
Don't see what you're looking for? Try a search.
|