Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-22-2009, 12:22 AM   #11
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Unhappy

Quote:
Originally Posted by bluemagica View Post
try
var a = new A();
trace(a.gravity);
Crap, that gives me run time errors:

Error: Error #2136: The SWF file file:///F|/Multimedia%20Major%20Project/Game/Untitlegrd%2D1.swf contains invalid data.
at CollisonDetection$iinit()
at flash.display::Sprite/flash.display:Sprite::constructChildren()
at flash.display::Sprite$iinit()
at flash.display::MovieClip$iinit()
at GameEngine$iinit()


I removed the fact that this class (B) belongs to a movieclip in the libary and removed the extends in class B and added this to my class A (still talking in the context of your example):

Code:
var b = new B();
b.init();
I than tried the following combinations each separated by a comment:

Code:
var a = new GameEngine();
a.trace(gravity);
//
var a = new GameEngine();
trace(a.gravity);
//
trace(GameEngine.gravity);
//
GameEngine.trace(gravity);
//
trace(gravity);
All gave errors. Honestly, its as if the import statement isn't doing anything. It give me an error if I type in a fictional class, but if I add class A to it, it acknowledges the fact that its there but doesn't do anything.
aaron_da_killa is offline   Reply With Quote
Old 03-22-2009, 07:44 AM   #12
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

I will make you a sample later today!
bluemagica is offline   Reply With Quote
Old 03-22-2009, 08:07 AM   #13
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

Quote:
Originally Posted by bluemagica View Post
I will make you a sample later today!
Cheers buddy ! What a nice birthday present .

I've been reading up about inheritance and composition (extends vs import) and I think I need to use alot more import and alot less extending off other classes. The only problem is that import seems to have a null effect. Maybe I'm just doing something wrong. And with using extends, I'm having trouble getting things to work and be able to access movieclips off the stage at the same time.
aaron_da_killa is offline   Reply With Quote
Old 03-22-2009, 06:18 PM   #14
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

I have attached a zip.
Open the fla in flash CS3/cs4 IDE, and test it there so that you can view the trace results....if you just see the trace first before reading the code, it will be easier for you to understand!
bluemagica is offline   Reply With Quote
Old 03-23-2009, 01:33 AM   #15
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Talking

Thanks alot for that buddy. One thing I did experiment with was I commented out the import statements in both Main and A and the code seemed to work anyway!

Also, do you think you could look at this attatched example and tell me whats wrong and how to fix it? Thanks again mate !
aaron_da_killa is offline   Reply With Quote
Old 03-23-2009, 04:36 AM   #16
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

Do not extend the document class
bluemagica is offline   Reply With Quote
Old 03-23-2009, 05:49 AM   #17
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Question

Whoa thanks alot buddy. This is starting to look promising, one small problem though. If I have any other movieclips on the stage I get this runtime error:

TypeError: Error #1006: init is not a function.
at DocumentClass$iinit()


Edit:

No Idea what I did but I deleted that third movieclip and placed it on the stage again and now it works :S.

Edit 2:

Mmmmm, I'm getting that error again now but this time there is no third movieclip. Perhaps this error randomly occurs?


Edit 3:

Alrighty, I've reduced my game to be essentially the exact same as the example you gave me and I can not for the life of me figure out why I'm getting the same error. Everything is just as you did it!

If you could download example3.zip and find out what's going on that would be awesome. Thanks!

Edit 4:

Heh, I changed the line "MovieClip(getChildAt(0)).init();" to read "MovieClip(getChildAt(1)).init();" in example 3 and it works now. I don't entirely understand what this line of code does, but I understand why changing that value fixed the problem. Perhaps instead of using getChildAt there is another method that results in the same thing or before this line of code is called I could set player/playerContainer (face/ff) index to 1 or something? What do you think?
aaron_da_killa is offline   Reply With Quote
Old 03-23-2009, 07:10 AM   #18
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

Start creating instances through code rather than placing them manually, that wayyou will get more control and better understand those errors!

getChildAt(0) means get whatever instance is in 0th position on the display list, i used it as a makeshift. Just recode your file to place all instances through addChild!
bluemagica is offline   Reply With Quote
Old 03-23-2009, 07:16 AM   #19
aaron_da_killa
Registered User
 
Join Date: Feb 2009
Location: Sydney, Australia
Posts: 33
Send a message via MSN to aaron_da_killa
Default

Quote:
Originally Posted by bluemagica View Post
Start creating instances through code rather than placing them manually, that wayyou will get more control and better understand those errors!

getChildAt(0) means get whatever instance is in 0th position on the display list, i used it as a makeshift. Just recode your file to place all instances through addChild!
Yeah? You sure there is no work around? Part of the reason I wanted to use classes is so I could do all the level design in the flash IDE without having to change the code every time I want to add a platform or an npc or even tweak the their position.
aaron_da_killa is offline   Reply With Quote
Old 03-23-2009, 07:26 AM   #20
bluemagica
Senior Member
 
Join Date: Feb 2008
Posts: 387
Default

that comes later, first you need to understand how to work with the display list.....i also do design's in the FlashIDE, otherwise it will be real slow to place stuff through code, but after the placing you have to "access" those through code, and so if you don't understand how to work with the display list through code, you will have trouble!
bluemagica is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS2] Platform game problem renegadegd Gaming and Game Development 2 12-20-2008 11:59 PM
Flash AS2 Platform game help sakit Gaming and Game Development 0 04-14-2008 03:45 PM
Platform game - not working as intended! bloodstyle Gaming and Game Development 0 03-21-2008 07:09 PM
Platform jumper - type game the_r Gaming and Game Development 5 10-08-2007 04:59 PM
help with my platform game killkenny64 Gaming and Game Development 1 10-13-2006 10:35 AM


All times are GMT. The time now is 07:28 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.