Beno,
It's difficult knowing exactly what you have done. I don't know any AS2,
just AS3. To help sort out the scenario let's say:
You have a program called program.fla
You have clicked the stage and in 'properties' you have named the class
as Main - without the as.
So the code that drives the swf is in a file called Main.as
The class Main must extend MovieClip.
That code in Main.as wants to use an asset called HatAndFace from
program.fla's library.
All files are in the same directory.
If Main.as is going to use HatAndFace from the library then just write
var public myClip:HatAndFace = new HatAndFace;
or
var myClip:HatAndFace = new HatAndFace;
Use the first if it's in the class but not in a function, and the second
if it's in a function.
I assume that mcHatAndFace is in your library, so perhaps your error was
in writing:
var mcHatAndFace = new MovieClip;
For AS3 there are two errors here.
1. You don't want any old MovieClip, you want a HatAndFace MovieClip.
2. After the ':' you have to specify what 'type' of thing your instance
name 'mcHatAndFace' applies to, like this...
var mcHatAndFace:MovieClip = new MovieClip;
Or, to fix both errors:
var mcHatAndFace:HatAndFace = new HatAndFace;
Notice that I have not written HatAndFace();
That's because I have not provided the HatAndFace() constructor method.
For a libary item, Flash will create a constructor that no one will ever
see, just to get it going.
Now if you wanted tp place an HatAndFace instance at say x=100, y=200
with a constructor call like 'new HatAndFace(100,200);' you can't.
To do that, you would write your own class in HatAndFace.as with a
constructor HatAndFace(xx:int,yy:int) {...} that takes your required x,y.
This one will accept an xx,yy position which you can use to set x,y.
The library asset would name this class HatAndFace as the constructor
for the exported code to be found in HatAndFace.as
If main.as is going to find the HatAndFace class in the HatAndFace.as
file, then you have to import it.
Avoid a function built inside a function.
We never stop struggling.
You are not alone.
John
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders