Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

stage.addchild

Guest
Jul 31, 2009 Jul 31, 2009

Hi,

This is my Document Class

package BowerPower.Startup{

import flash.display.MovieClip;
import flash.events.Event;

public class Preloader extends MovieClip {

  public function Preloader() {
  
   stage.addChild(Preloader);

  }
}
}


I have a movieclip in the library exported for actionscript. With a Class: Preloader.  The Bace Class: flash.display.MovieClip.

My problem is I get the error: 1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.

How do I fix this,

Thanks

TOPICS
ActionScript
1.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , Jul 31, 2009 Jul 31, 2009

A couple of problems:

1. You're trying to add a class to the stage instead of an instance of the child

2. Generally, the movieclip shouldn't add itself to the stage (displaylist).  You should do it from outside.

So something like this (from outside your Preloader class (perhaps a Main class):

// Import the class
import BowerPower.Startup.Preloader;

// Create the instance and add it to the displaylist
var p:Preloader = new Preloader();
addChild(p);
Translate
Explorer ,
Jul 31, 2009 Jul 31, 2009

A couple of problems:

1. You're trying to add a class to the stage instead of an instance of the child

2. Generally, the movieclip shouldn't add itself to the stage (displaylist).  You should do it from outside.

So something like this (from outside your Preloader class (perhaps a Main class):

// Import the class
import BowerPower.Startup.Preloader;

// Create the instance and add it to the displaylist
var p:Preloader = new Preloader();
addChild(p);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jul 31, 2009 Jul 31, 2009
LATEST

Hi,

Thanks for the help.  It worked.  Sometimes a few lines of code make a big difference.

Thanks again,

qazsd

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines