Copy link to clipboard
Copied
hi, I want to create my array class which extends the functionality of the base array.
I wrote something like this:
package {
public class my_array extends Array {
// (...)
public function my_array(_long:int) {
// (...)
super(_long);
}
} // class
} // package
in other words, I have to call the super constructor, and since when I declare a new array I specify the lenght of the array, I pass the length of the array to the super constructor.
Nothing wrong so far, but when I try to use my new array, like this:
var test:my_array = new my_array(10);
test[0] = 1;
I get this error:
ReferenceError: Error #1056: Cannot create property 0 on my_array.
at rob1_fla::MainTimeline/frame1()
then I replaced the 'super' line in the constructor of my class with this one:
this = super(_long);
and now I get this one:
1050: Cannot assign to a non-reference value.
so how do I extend the array class, so I can use the indexes of my new array class?
tnx
make your class dyanamic.
Copy link to clipboard
Copied
make your class dyanamic.
Copy link to clipboard
Copied
yup, that worked, tnx!. I also noticed that making it dynamic, even though not extending array class works the same, or, making it dynamic makes it work as an array even though it has nothing to do with array class. I see no point in inheriting from array then, if just by inheritance it will not make it dynamic, or even though not being dynamic will not separate the requested space with the super constructor call
Copy link to clipboard
Copied
you'll need to extend the array class is you want to treat your new class as an array and use the array class methods and properties.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now