woensdag 5 januari 2011

1046: Type was not found or was not a compile-time constant: Loader.

As3 has been driving me crazy.
I tried creating a container the way I used to do this in as2.
Load in stuff with LoadMovieNum (Yes, I'm old fashioned, but I found the "layer"-concept very usefull in building minisites).

The pre is that you can develop a page (almost) completely independant and then get stuff from _level0.. The beauty is, because there is a _root as well as a _level0 the _root functionality isn't lost.
But oh well, as2 is long ago.

When I was trying to create this in as3, I got this enigmatic error when I just followed the example from adobe:

package nl.ludatic.container{
 import flash.display.*;
 import flash.events.*;
 import flash.net.URLRequest;
 import flash.net.navigateToURL;
 import flash.system.*;
 import flash.text.*;

 public class Container extends MovieClip
 {
  private var loader:Loader=new Loader();

and BAM!
There was no way I could get the compiler to go past this line...

Now what happened:
nl.ludatic.container means, the compiler has to look in nl/ludatic/container to get to the Container class..
In this directory I had also put a empty file called Loader.as.
Apparantly the compiler looked at this file when I said new Loader() and found it empty, so it concluded there was NO Loader class.

Now I don't know how an empty file can override a hard import, but it did.
I got rid of the file and everything works beautifully.

So I worked it out in the end, but wow...
Oh well, on to the next inexplicable error!

Geen opmerkingen:

Een reactie posten