2

I am working on a flash based web application. The front end is written in flex: MXML and ActionScript. The project builds fine in FlashDevelop, but when I test that using F5, it throws error.

Line of code:

[Bindable]
public var currentStateDataProvider:ArrayCollection = new ArrayCollection();

Error message:

[Starting debug session with FDB]
[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert mx.collections::ArrayCollection@c2acfc9 to Array.

Is there anything wrong the way I am declaring and initializing the variable?

Andrejs
  • 10,803
  • 4
  • 43
  • 48
Sonu Mishra
  • 1,659
  • 4
  • 26
  • 45
  • 1
    This isn't uncommon. The likely solution, is not instantiate the object in the var declaration. Move the `new ArrayCollection();` into the constructor instead. In AS3 it's always better to not instantiate complex objects in the class var declarations – BadFeelingAboutThis Aug 19 '16 at 01:06
  • Worked! Is there any specific reason why this happens? The application I am working on was written 3-4 years ago; it worked fine then, but now I am getting this error. – Sonu Mishra Aug 19 '16 at 20:51

1 Answers1

0

Probably the error comes from the use of the varible. The declaration and instantiation seem good and they not should be the problem. Anyway, i'm agree with the comment of BadFeelingAboutThis. To do the instantiation of complex variables in the constructor is better for me.

Community
  • 1
  • 1
jlebrato
  • 21
  • 5