AS3 Display Object instantiation problem

Posted on 2009-04-26
Last Modified: 2013-11-11
I want to create two children that will be placed into a display object and then added to the display list. I know my code is close, but I get the following error:

1061: Call to a possibly undefined method addChild through a reference with static type flash.display:DisplayObject.

What am I doing wrong?
public function populateLogoAndFooter() {

  //Create a container for the children

  var lfContainer:DisplayObject = new DisplayObject();


  //----- Add Header logo

  var amLegacyLogo:Sprite=new americanLegacyLogo;




  //----- Add footer type

  var baselineType:Sprite=new footerType;





  lfContainer.addEventListener(MouseEvent.MOUSE_UP, mouseUp);


Open in new window

Question by:msukow

    Author Comment

    I figured that out - had to change the
    var lfContainer:DisplayObject = new DisplayObject();
    var lfContainer:Sprite= new Sprite();

    Author Comment

    However, Now I have a new issue. I have a listener attached to a button as follows:

    public function populateNavigation() {
      //----- Film Info button
      var button1:filmInfo=new filmInfo;
      button1.addEventListener(MouseEvent.MOUSE_UP, populateFilmInfo);
      button1.addEventListener(MouseEvent.MOUSE_OVER, navOver);
      button1.addEventListener(MouseEvent.MOUSE_OUT, navOut);

    The populateFilmInfo function is as follows:
    public function populateFilmInfo() {
      trace("populateFilmInfo reached");
      trace("lfContainer.x: " +lfContainer.x);

    I get the following message when I compile and press the button1:
    ArgumentError: Error #1063: Argument count mismatch on Main/populateFilmInfo(). Expected 0, got 1.
    LVL 34

    Accepted Solution

    populateFilmInfo method should except an MouseEvent..

    here is the updated code:

    public function populateFilmInfo(evt:MouseEvent) {
      trace("populateFilmInfo reached");
      trace("lfContainer.x: " +lfContainer.x);


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Suggested Solutions

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
    The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
    The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now