<p>I am new to ActionScript 3 and have run into a problem:</p>

<p>Using Flex Builder 3, I have a created a project with a few simple classes. If code in class A instantiates an object of class B (class B is in its own source file) then the code compiles fine, but I get the following run time error:</p>

<blockquote>
  <p>ArgumentError: Error #2012: B class cannot be instantiated.</p>
</blockquote>

<p>Can someone explain what I'm doing wrong?</p>

<p><strong>Update:</strong> Please see my own answer below (I could not vote it to the top since I'm not yet registered).</p>

[{'answer_id': 68305, 'author': 'mikechambers', 'author_id': 10232, 'author_profile': 'https://Stackoverflow.com/users/10232', 'pm_score': 2, 'selected': False, 'text': '<p>This usually means that the class information was not included in the SWF. </p>\n\n<p>Make sure that you are importing the class, and that there is a reference to it somewhere (so the compiler will included it in the SWF).</p>\n\n<p>btw, here are the runtime error codes:</p>\n\n<p><a href="http://livedocs.adobe.com/flex/201/langref/runtimeErrors.html" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/201/langref/runtimeErrors.html</a></p>\n\n<p>(not much useful info though)</p>\n\n<p>mike chambers</p>\n\n<p>mesh@adobe.com</p>\n'}, {'answer_id': 68431, 'author': 'Brent', 'author_id': 10680, 'author_profile': 'https://Stackoverflow.com/users/10680', 'pm_score': 0, 'selected': False, 'text': '<p>It\'s worth noting that if you\'re including classes that someone else built, and they used Flash CS3 and you\'re using Flex, or vice versa, that the core libraries of each are different and some things are not included in both. Check out the two reference docs to be sure:</p>\n\n<p>CS3: <a href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/" rel="nofollow noreferrer">http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/</a></p>\n\n<p>Flex: <a href="http://livedocs.adobe.com/flex/2/langref/" rel="nofollow noreferrer">http://livedocs.adobe.com/flex/2/langref/</a></p>\n'}, {'answer_id': 69044, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 4, 'selected': False, 'text': "<p>I finally realized what was wrong: Class B was subclassing from DisplayObject which I now see is an abstract class. Class B did not implement the abstract members, thus the error. I'll probably change class B to subclass from Sprite instead.</p>\n\n<p>This seems like a problem that should have been caught by the compiler. Does the fact that it wasn't mean implementation of abstract members can wait until run time? Even if so, it would be nice to at least get a compiler warning.</p>\n\n<p>Thanks for everyone's answers, hopefully they will help others who run into error 2012.</p>\n"}]
['https://Stackoverflow.com/questions/68244', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/-1/']