A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: [RESOLVED] [AS3] Error 1010 when creating class instance

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    18

    resolved [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?

  2. #2
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    What is the source of the error?

    Say your class name is Apple and it extends MovieClip. You do

    var myapple:MovieClip = new Apple ();

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    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.

  4. #4
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    Yes.

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    It doesn't work.....

  6. #6
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    When all hope is almost lost, posting the entire source code will always help.

  7. #7
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    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.

  8. #8
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    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.

  9. #9
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center