0

I am new to adobe flash cs6 and actionscript and am having trouble doing what should be a simple task. I have created a new project and document class that looks like this:

package  {

    import flash.display.MovieClip;

    public class MyClass extends MovieClip {

        public function MyClass() {

        }
}

Now all I want to do is programmatically add an image to the stage when running.

So far, I imported the image to the library which is titled mytestimage which i converted to a symbol. The mytestimage symbol has linkage to a class mytestimage which looks like this:

package  {

    import flash.display.Sprite;
    import flash.events.Event;

    public class mytestimage extends Sprite {

        public function mytestimage () {
            addEventListener(Event.ENTER_FRAME, enterFrame);
        }
        private function enterFrame(e:Event):void {

            }
        }

}

I then updated my document class to the following :

package  {

    import flash.display.MovieClip;

    public class MyClass extends MovieClip {

        public function MyClass() {
            var myMovieClip = new mytestimage();
            addChild(myMovieClip);
        }
}

and when I debug the project nothing errors and the image isn't loaded - all I see is the white stage. Can somebody help me figure out what I am doing wrong here? Thanks

Cooper Cripps
  • 205
  • 2
  • 6
  • 14

1 Answers1

0

Most likely the constructor for your document class is never run. Nothing looks wrong with your code so it is probably "something else".

There is an annoying thing with Flash that it never "tells you when a specific document class cannot be found". (ie. wrong path/library linkage to the wanted file, it just auto creates a new file since that is what it thinks you want to do...)

Easiest way to start debugging this issue is to do a trace inside your constructor of the document class similar to public function MyClass() { trace("ctor()") };

That way you can find out if it is an actual "image issue" or if it just fails to find the correct class.

Depending on the physical locations of your files, you might have to add a linkage to your source folder inside your "source path" inside flash actionscript settings. (file/publish settings)

It could also be (doesn't sound like it) that what you call your "document class" is a library item and the linkage exists on that library item. In that case, the clip needs to be placed on the stage in order to be run. (but it didn't sound like this is what you did)

If this doesn't solve your issue, feel free to start a chat with me or share the files and I'll look into it.

It's always a hassle to start a new project in a new language with new tools, Good Luck! :o)

Daniel MesSer
  • 1,191
  • 1
  • 7
  • 13
  • Also make sure you haven't accidently checked "omit trace statements" in publish settings when trying to get the file to run. Also, the "class" linkage to a file is case sensitive so make sure that matches. Another tip is to click on the "pen symbol" next to your class-field in property window. If that opens up your as-file you know that you have set up things correct. Otherwise something is wrong with the linkage to the file – Daniel MesSer Mar 31 '13 at 13:07