Discuz! Board

 

 

Search
Discuz! Board Forum Integration Questions sub classes ( A extends B )
View: 483|Reply: 1
go

sub classes ( A extends B )

Rank: 2

Post on 2011-10-11 03:29 |All posts
hi papaya team -

i am working with GameEngine, and having problems with subclasses.


if i put all my classes all in one file, including the subclass, things compile fine.
but if i try to break out into a few separate files i get compile errors, eg:


1120: line 3: Variable SubTest is not defined

----------------------------#  file SubTest.as
class SubTest {
}

----------------------------# another file Sub2.as

// tried import in both files just in case this was issue
// also tried as import SubTest pikkle.SubTest  pikkle.subtest etc


// so keyword SubTest throws the error here as not defined... :/

import pikkle.SubTest;   

class Sub2 extends SubTest {
}

----------------------------# then in the main.as

import pikkle.SubTest;
import pikkle.Sub2;


----------------------------# error:

Parsing file : projects/trav1/main.as
Analyzing file : projects/trav1/pikkle/Sub2.as
1120: line 3: Variable SubTest is not defined
Traceback (most recent call last):
File "/Library/Python/2.5/site-packages/cx_Freeze/initscripts/Console.py",
line 27, in <module>
File "r.py", line 3, in <module>
File "/Android/GameSDK/package/compile.py", line 229, in main
File "/Android/GameSDK/package/ascompile.py", line 1182, in compile
File "/Android/GameSDK/package/ascompile.py", line 1107, in decl
File "/Android/GameSDK/package/ascompile.py", line 362, in declcls
File "/Android/GameSDK/package/ascompile.py", line 159, in getInheritScope
TypeError: 'NoneType' object is unsubscriptable


none of the code examples seem to use classes at all, and the PDF only talks about classes in the same file.
i assume your as implementation doesn't support packages?

thanks for your help!



/dc

Rank: 4

Post on 2011-10-12 10:26 |All posts
In the downloaded package, there is a project called "demo". It uses many packages, please learn from it. A usual way is to put all common data in one file (includes.includes in demo) and import it in the main file.

If the main file is like this:

import a.a;
import b.b;
import c.c;
import includes.includes;

the compile order is includes->c->b->a.
Security Q&A Change Security code Change

Archiver|Comsenz Inc.

All time is GMT+8, 2013-5-25 14:11 , Processed in 0.029760 second(s), 10 queries .

Powered by Discuz! X1.5

© 2001-2010 Comsenz Inc.