As3 Error #2012 Class Cannot Be Instantiated
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What Causes Flash Error #2012 (Can't instantiate class)? up vote 12 down vote favorite I am new to ActionScript 3 and have run into a problem: 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: ArgumentError: Error #2012: B class cannot be instantiated. Can someone explain what I'm doing wrong? Update: Please see my own answer below (I could not vote it to the top since I'm not yet registered). flex flash actionscript-3 flexbuilder share|improve this question edited Dec 16 '15 at 5:36 ketan 13k122953 asked Sep 16 '08 at 0:28 Bob F add a comment| 3 Answers 3 active oldest votes up vote 20 down vote 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. 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. Thanks for everyone's answers, hopefully they will help others who run into error 2012. share|improve this answer answered Sep 1
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping http://stackoverflow.com/questions/68244/what-causes-flash-error-2012-cant-instantiate-class each other. Join them; it only takes a minute: Sign up Adding to Stage in ActionScript 3 from a .as file up vote 0 down vote favorite Note: Yes, I know that similar questions have been asked before. However, after following the answers in such questions I'm still stuck and can't find a solution to my problem. I'm http://stackoverflow.com/questions/14709682/adding-to-stage-in-actionscript-3-from-a-as-file having a problem which requires adding DisplayObjects to the Flash stage. Since I have to Display elements of several different classes, I decided to create a class to work as an intermediary between the .as files and the addChild function called "Displayer" as shown below: package { import flash.display.DisplayObject; import flash.display.Sprite; import flash.display.Stage; public class Displayer extends Sprite //I read somewhere that DisplayObject //as an extension can't be used for this, so Sprite will have to do. { private var _stage:Stage; function Displayer() { _stage = new Stage; } public function displayElement(displayable:DisplayObject) { _stage.addChild(displayable); } } } I compile it and there appears a problem that I don't understand: Error #2012: Can't instantiate Stage class. Evidently, something in this code is either missing or out of place, but since it's so straightforward I fail to see what the problem can be. I'm sure that it's not very complicated, I probably just need an outsider's perspective. actionscript-3 sprite stage addchild displayobject share|improve this question asked Feb 5 '13 at 14:21 Anthony 25111 add
ElementsAdobe Dreamweaver Adobe MuseAdobe Animate CCAdobe Premiere ProAdobe After EffectsAdobe IllustratorAdobe InDesignView all communitiesExplore Menu beginsMeet the expertsLearn our productsConnect with your peersError: You don't have https://forums.adobe.com/thread/867181 JavaScript enabled. This tool uses JavaScript and much of it will not work correctly without it enabled. Please turn JavaScript back on and https://books.google.com/books?id=7F0nCgAAQBAJ&pg=PA104&lpg=PA104&dq=as3+error+%232012+class+cannot+be+instantiated&source=bl&ots=BdbCwRtwO9&sig=vRjk09TR1Tw_bkRDiAuAqL501sI&hl=en&sa=X&ved=0ahUKEwiGg5X77KzPAhUU0IMKHVhKDv reload this page. Please enter a title. You can not post a blank message. Please type your message and try again. More discussions as3 error in ActionScript 3 All CommunitiesAdobe Animate CC - HomeActionScript 3 2 Replies Latest reply on Jun 20, 2011 4:09 AM by Hakan KIRIK Problem while instantiating Magedyz Jun 20, 2011 4:03 AM I simply wrote this 2 lines of code:import flash.display.DisplayObject;var testIt:DisplayObject = new DisplayObject();
And I receive as3 error #2012 this weird error:ArgumentError: Error #2012: DisplayObject$ class cannot be instantiated.Any idea? Thanks in advance 631Views Tags: none (add) This content has been marked as final. Show 2 replies 1. Re: Problem while instantiating Hakan KIRIK Jun 20, 2011 4:09 AM (in response to Magedyz) DisplayObject is an abstract base class; therefore, you cannot call DisplayObject directly.http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayOb ject.html?filter_flash=cs5.5&filter_flashplayer=10.3&filter_air=2.6 Like Show 0 Likes(0) Actions 2. Re: Problem while instantiating Magedyz Jun 20, 2011 4:31 AM (in response to Hakan KIRIK) Thanks Hakan a lot. Like Show 0 Likes(0) Actions Go to original post Actions More Like This Retrieving data ... Legend Correct Answers - 10 points © 2016 Adobe Systems Incorporated. All Rights Reserved. | Powered by Help | Terms of Use | Privacy Policy and Cookies (UPDATED) | Forum Help | Tips for AskingJive Software Version: 8.0.3.0 , revision: 20160218075410.6eafe9c.release_8.0.3.xfrom GoogleSign inHidden fieldsBooksbooks.google.com - ActionScript 3 is a full-fledged programming language, with complete object-oriented capabilities, event handling, sound and video support, drawing capabilities, support for regular expressions, and much more.Whether you are just starting out on the road to computer programming and animation or an experienced...https://books.google.com/books/about/Foundation_ActionScript_3.html?id=7F0nCgAAQBAJ&utm_source=gb-gplus-shareFoundation ActionScript 3My libraryHelpAdvanced Book SearchBuy eBook - $31.19Get this book in printApress.comAmazon.comBarnes&Noble.comBooks-A-MillionIndieBoundFind in a libraryAll sellers»Foundation ActionScript 3Paul Milbourne, Darren RichardsonApress, Dec 2, 2014 - Computers - 556 pages 0 Reviewshttps://books.google.com/books/about/Foundation_ActionScript_3.html?id=7F0nCgAAQBAJActionScript 3 is a full-fledged programming language, with complete object-oriented capabilities, event handling, sound and video support, drawing capabilities, support for regular expressions, and much more.Whether you are just starting out on the road to computer programming and animation or an experienced developer who wants to learn a new language, you’ll find all you need to know in Foundation ActionScript 3. Starting with the fundamentals, you’ll learn how to add interactivity to your Flash movies by using ActionScript objects, manipulating sound and video, and harnessing the power of regular expressions and XML. The book concludes with two case studies to consolidate what you’ve learned and introduce some additional advanced techniques. You’ll gain a solid understanding of the exciting world of ActionScript 3 and see how everything fits together, so you’ll be able to build your own professional applications.The sensible layout of the book makes it easy to find information about specific techniques. It focuses on the essential skills that will enable you to get up and running quickly. With this book as your guide, you’ll be creating killer Flash applications before you know it. Preview this book » What people are saying-Write a reviewWe haven't found any reviews in the usual places.Selected pagesPage 10Title PageTable of ContentsIndexContentsGetting Started with ActionScript 301 ActionScript 30 Fundamentals23 Objects and Classes6