|
-
[RESOLVED] [AS3] Error 1010 when creating class instance
I'm pretty new to classes, so this is probably something simple. When I try to create a new instance of a class that I created from a symbol in the library, I get a 1010 (A term is undefined and has no properties) error. I gave it a class name in it's linkage properties and it extends MovieClip. Is there anything else that I'm supposed to do? Maybe it's a syntax error when I'm creating an new instance of the class. It used just like any other class or datatype, right?
-
What is the source of the error?
Say your class name is Apple and it extends MovieClip. You do
var myapple:MovieClip = new Apple ();
-
I'm using an array so my code would be:
Actionscript Code:
myArray[a][b] = new Apple();
Right?
Last edited by FlyingMonkey456; 12-28-2010 at 02:22 PM.
-
-
-
When all hope is almost lost, posting the entire source code will always help.
-
The problem seems to be in my array, not my function. Here's the declaration:
var SandbagArray:Array = new Array();
Any code involving the array gives me an error.
Edit: for some reason highlight is making my text red instead of actionscripty.
Last edited by FlyingMonkey456; 12-29-2010 at 02:05 PM.
-
PHP Code:
var myarray:Array = new Array (); myarray [a][b] = new Apple ();//Assuming a and b are actually numbers
Is that how you're doing the whole thing? If it is then the problem is myarray is not a multidimensional array but you are trying to use it like one.
You need to declare new arrays inside each element of the main array. Assume you want your 2D array to have 3 arrays inside it.
PHP Code:
var myarray:Array = new Array (new Array (), new Array (), new Array ()); myarray [0][1] = new Apple ();//If you know exactly which element you want to put an Apple in myarray [0].push (new Apple ());//If you just want to add an Apple to the end of the array
This should solve your problem.
-
That fixed it. Thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|