0

I get error code 1009 when I run this code...

for(var aObj:int = 1; aObj < 50; aObj++){           
    this["elementsSb.netDev"+aObj].addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
    this["elementsSb.netDev"+aObj].addEventListener(MouseEvent.MOUSE_UP, stopDragObject);
}

But when I run basically in this way...

elementsSb.netDev1.addEventListener(MouseEvent.MOUSE_DOWN, dragObject);
elementsSb.netDev1.addEventListener(MouseEvent.MOUSE_UP, dragObject);

It works. Though, I don't want to make it this way because it's a bit messy, and I have 49 netDev objects.

Any proper way to deal with this guys. Thanks in advance.

2
  • 1
    this["elementsSb.netDev"+aObj] -> this["elementsSb"]["netDev"+aObj] Commented May 21, 2013 at 7:16
  • @fsbmain, you should add that as an answer, as probably that's the reason of error. Commented May 21, 2013 at 7:18

1 Answer 1

2

When you use the fences to access to the properties of any objects the dot . withing the string identifier doesn't work.

The correct path must be:

this["elementsSb"]["netDev"+aObj]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.