FORUMS: list search recent posts

Error #1010

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Sam Pipes
Error #1010
on Jul 6, 2014 at 12:11:40 am

I'm trying to do a little project to get me acquainted with as3 and almost immediately I'm getting weird problems. Here's the code:

bigButton.addEventListener(MouseEvent.CLICK, originate_main);

function originate_main(event:MouseEvent):void
for(var n:Number=1; n <= 3; n++)
this["animalField" + n].txt_1.text = animArray[Math.floor(Math.random()*animArray.length)];

It works when I run it, but in the output window I get:

TypeError: Error #1010: A term is undefined and has no properties.
at RandomAnimalGenerator2_fla::MainTimeline/originate_main()

The problem seems to be with "this["animalField" + n]" but I have no idea why. Any suggestions?

Return to posts index

Sam Mattern
Re: Error #1010
on Jul 6, 2014 at 1:04:49 pm

Comment out the this[ "animalField"+n] line, copy it, and replace it with this.animalField1... to see if the dynamic reference truly is the problem. If your error doesn't go away you'll know it's not a syntax issue refering to the object dynamically and that it's something else, such as scope referring to the object or a syntax issue or scope with the math.random or the animArray respectively. These can be tracked down by breaking up the call into multiple parts and running a trace on them to make sure you're getting what you're expecting to get.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved