Copy link to clipboard
Copied
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
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);
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Hi,
Thanks for the help. It worked. Sometimes a few lines of code make a big difference.
Thanks again,
qazsd
Find more inspiration, events, and resources on the new Adobe Community
Explore Now