4

Does anyone knows something about "World" being reserved or built in class with that name? when I try to construct the World class I've created it throws compile error:

1136: Incorrect number of arguments.  Expected 2.

But I've million times checked, there are no arguments expected at all, all package naming, variable types.. everything is correct, but it throws that stupid error. :/ Try it on your own and you will see that it does.. or I'm stupid?

When I try to call init function in the World class it throws this one:

1061: Call to a possibly undefined method init through a reference with static type World.

Grr..

Adam Harte
  • 9,820
  • 7
  • 48
  • 82
Rihards
  • 9,751
  • 14
  • 53
  • 76
  • 1
    try changing the class name to something else to see if the same problem persists. – Chunky Chunk Nov 17 '10 at 11:20
  • tried and it works with different name. :] but i want that "world" name. :D – Rihards Nov 17 '10 at 11:32
  • this might be collision with another entity named 'World'. AFAIK, it's not a current or even reserved keyword. – alxx Nov 17 '10 at 11:49
  • 1
    certainly it's a mystery, which would be better understood. but if it helps, my trusty thesaurus has returned these potential substitutes: earth, globe, planet, sphere, moon, star, heavenly body, orb, society, circle, arena, milieu, province, domain, orbit, preserve, realm, field, discipline, area, sector, everyone, everybody, people, mankind, public, population. – Chunky Chunk Nov 17 '10 at 12:02
  • @TheDarklnl1978, is that a sarcasm cause i sounded like one?! (English is not my foreign language so.. ;D) – Rihards Nov 17 '10 at 15:00
  • 1
    no! lol. i was genuinely trying to be helpful. i often go back and rename my classes and variables because i think of or use a thesaurus to research more appropriate titles. – Chunky Chunk Nov 17 '10 at 21:04
  • 1
    This is coming late as I ran into this issue for the first time earlier today. I blew apart the libs in the default as3 CS5 include path, and it turns out World is a top level class associated with the fl.ik package; the inverse kinematics lib for managing armature animations. Hope this helps. The World class is located in ik.swc. – stat Feb 08 '12 at 03:11

6 Answers6

4

I have had this same problem. I think it is reserved as of FlashPlayer 10 (possibly 10.1, but can't be sure). I had to work around it by using my full package name when referencing my World class.

var myWorld:com.foo.World = new com.foo.World();

Ugly, but it works!

Adam Harte
  • 9,820
  • 7
  • 48
  • 82
  • 1
    +1 Yes, I have had the problem as well. My game compiled fine on CS4 for Flash Player 10, but later on compiling with CS5 I received the compile error. I think it must be 10.1 being the problem then? – Allan Nov 17 '10 at 23:21
1

You must have another class called World somewhere in your source path. Look at your imports.

Type the full package path if neccessary to avoid confusion with another World class somewhere else:

var w:my.package.World = new my.package.World();
frankhermes
  • 4,189
  • 1
  • 18
  • 36
  • Nope, no other World classes. Everything - imports, packages... everything is correct. – Rihards Nov 17 '10 at 14:57
  • Well, creating a new world object (new World();) in a fresh document throws an error saying it can't find the class, so it must be something you're importing. – Flassari Apr 03 '12 at 13:14
1

A couple of other possibilities:

Are you using Flex/FlashBuilder, and importing a SWC? Those can expose classes without revealing the source code.

Or are you compiling from a FLA? In that case, there may be a library symbol exporting to an ActionScript class whose name conflicts with yours.

Another possibility is that the Flash compiler you are using (whether FlashPro or FlashBuilder) has improperly cached a class definition you created earlier. I have experienced this bug a few times before. Try doing a Project/Clean (in FlashBuilder) or, if you're desperate, creating a new project.

Jonathan Lidbeck
  • 1,308
  • 1
  • 12
  • 14
0

I just check it myself even it was an old post that has been answered yet. The reason is that I found this post due to a search about a list of reserved keywords in AS3.

The "World" Keyword is not reserved :) Oooops...

This is the list I found so far with reserved words / keywords in AS3: If, you edit this list, please leave a comment / with sources... THX Sometimes the same keyword may appear twice in the list under different categories...

0   :   abstract        (future keyword)
1   :   as              (reserved keyword)
2   :   boolean         (future keyword)
3   :   break           (reserved keyword)
4   :   byte            (future keyword)
5   :   case            (reserved keyword)
6   :   cast            (future keyword)
7   :   catch           (reserved keyword)
8   :   char            (future keyword)
9   :   class           (reserved keyword)
10  :   const           (reserved keyword)
11  :   continue        (reserved keyword)
12  :   debugger        (future keyword)
13  :   default         (reserved keyword)
14  :   delete          (reserved keyword)
15  :   do              (reserved keyword)
16  :   double          (future keyword)
17  :   dynamic         (syntactic keyword)
18  :   each            (syntactic keyword)
19  :   else            (reserved keyword)
20  :   enum            (future keyword)
21  :   export          (future keyword)
22  :   extends         (reserved keyword)
23  :   false           (reserved keyword)
24  :   final           (syntactic keyword)
25  :   finally         (reserved keyword)
26  :   float           (future keyword)
27  :   for             (reserved keyword)
28  :   function        (reserved keyword)
29  :   get             (syntactic keyword)
30  :   goto            (future keyword)
31  :   if              (reserved keyword)
32  :   implements      (reserved keyword)
33  :   import          (reserved keyword)
34  :   in              (reserved keyword)
35  :   include         (syntactic keyword)
36  :   instanceof      (reserved keyword)
37  :   interface       (reserved keyword)
38  :   internal        (reserved keyword)
39  :   intrinsic       (future keyword)
40  :   is              (reserved keyword)
41  :   long            (future keyword)
42  :   namespace       (syntactic keyword)
43  :   native          (reserved keyword)
44  :   native          (syntactic keyword)
45  :   new             (reserved keyword)
46  :   null            (reserved keyword)
47  :   override        (syntactic keyword)
48  :   package         (reserved keyword)
49  :   private         (reserved keyword)
50  :   protected       (reserved keyword)
51  :   prototype       (future keyword)
52  :   public          (reserved keyword)
53  :   return          (reserved keyword)
54  :   set             (syntactic keyword)
55  :   short           (future keyword)
56  :   static          (syntactic keyword)
57  :   super           (reserved keyword)
58  :   switch          (reserved keyword)
59  :   synchronized    (future keyword)
60  :   this            (reserved keyword)
61  :   throw           (reserved keyword)
62  :   throws          (future keyword)
63  :   to              (future keyword)
64  :   to              (reserved keyword)
65  :   transient       (future keyword)
66  :   true            (reserved keyword)
67  :   try             (reserved keyword)
68  :   type            (future keyword)
69  :   typeof          (reserved keyword)
70  :   use             (reserved keyword)
71  :   var             (reserved keyword)
72  :   virtual         (future keyword)
73  :   void            (reserved keyword)
74  :   volatile        (future keyword)
75  :   while           (reserved keyword)
76  :   with            (reserved keyword)

Here are the 3 Arrays of keywords :

private static var reserved:Array = [
                          "as","break","case","catch","class","const","continue","default","delete",
                          "do","else","extends","false","finally","for","function","if","implements",
                          "import","in","instanceof","interface","internal","is","native","new","null",
                          "package","private","protected","public","return","super","switch","this",
                          "throw","to","true","try","typeof","use","var","void","while","with"
                          ];
private static var syntactic:Array = [
                           "each","get","set","namespace","include","dynamic","final","native","override","static"
                           ];
private static var future:Array = [
                        "abstract","boolean","byte","cast","char","debugger","double","enum","export","float",
                        "goto","intrinsic","long","prototype","short","synchronized","throws","to","transient",
                        "type","virtual","volatile"
                        ]
tatactic
  • 855
  • 1
  • 6
  • 16
0

I think you should check the parameters which are required in the constructor and make them optional by passing = null or something to the constructor-function.

This 'error' can occur when you place a symbol from your library which has required parameters in the constructor.

package com.myworld
{
    public class World
    {
        public function World(parameter1:int = null, parameter2:String = null ) 
        {

        }
    }
}
Mark Knol
  • 7,885
  • 3
  • 26
  • 43
0

this is a stretch, but try deleting your ASO files (Control > Delete ASO Files) and recompile.

if that doesn't work the only other thing i would suggest is to rebuild your project, testing this problem each time you import one or a group of classes. this approach should guarantee you to at least find the where the problem is originating.

the following document class compiles and executes completely fine for me in Adobe Flash CS5 targeting Flash Player 10.1.53.64 (10.1):

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

public class World extends Sprite
    {
    public function World()
        {
        addEventListener(Event.ADDED_TO_STAGE, init);
        }

    private function init(evt:Event):void
        {
        removeEventListener(Event.ADDED_TO_STAGE, init);
        trace("World Document Added To Stage");
        }
    }
}
Chunky Chunk
  • 14,884
  • 13
  • 75
  • 149