If you are trying to create a new instance of myMenu, then you need the "new" keyword:
Code:
var aMenu:myMenu = new myMenu();
If that's not what you're trying to do, I don't know what you're trying to do. But
Code:
myMenu(somevalue);
is the syntax for casting somevalue to myMenu. That is probably what the compiler thinks you're trying to do, which is why it expects an argument. But you're not trying to do that anyway.
Works great as a document class. How can i use it in a fla ? if i "run" the constructor i have this error 1136: Incorrect number of arguments. Expected 1.
You are not "running" the constructor with the code you posted above. You are incorrectly attempting to cast an empty argument list to myMenu. That's not what you want. If you want to create a new instance of myMenu, you need to use the "new" keyword.
It doesn't even make sense to "run" a constructor. What do you think that means? Post the code where you are attempting to do that.
( i was just posting it.. you answered while i was typing)
This file if used as DOCUMENT class is supposed to pop a CUSTOM right click menu!
But i want to use it as a file normal class.. because i want to make many others... and i have that error.
No, that is myMenu.as. I am asking for the code where you attempt to "run" the constructor. I am also asking you to explain what you think "run the constructor" means.
I have already explained why that doesn't work: it does not call the constructor of myMenu. It attempts to cast nothing to myMenu, which is why you get the error about expecting an argument.
Even if it DID call the constructor, what would you expect to happen? You aren't doing anything with the new instance of myMenu.
Well, you could make your document class be or extend myMenu, but myMenu doesn't seem to do much besides configure a ContextMenu with hardcoded values.
Or, you could do the same things myMenu does directly in your document class.
Or, you could change myMenu to have static functions which add and configure a context menu on an instance that you pass in (though I do not like this approach, it's not particularly object oriented style).
You don't want myMenu to extend the document class, you want the document class to extend myMenu. That is, you want your new class to be a myMenu as well as whatever new stuff you add.
To do that, simply add "extends myMenu" to the class declaration, just like you made myMenu extend MovieClip:
Code:
public class Something extends myMenu {
By the way, by convention, classes begin with a capital letter and variables begin with a lower case letter.