Box2D Forums

It is currently Sat May 25, 2013 12:06 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Referencing a body
PostPosted: Tue Mar 27, 2012 12:53 am 
Offline

Joined: Thu Feb 23, 2012 4:22 am
Posts: 8
Code:
package {

   import Box2DAS.*;
   import Box2DAS.Collision.*;
   import Box2DAS.Collision.Shapes.*;
   import Box2DAS.Common.*;
   import Box2DAS.Dynamics.*;
   import Box2DAS.Dynamics.Contacts.*;
   import Box2DAS.Dynamics.Joints.*;
   import cmodule.Box2D.*;
   import wck.*;
   import shapes.*;
   import misc.*;
   import extras.*;
   import flash.utils.*;
   import flash.events.*;
   import flash.display.*;
   import flash.text.*;
   import flash.geom.*;
   public class World extends wck.World {

      public function World() {
         createBody();
      }
      public function parseInput(e:Event):void {
         trace(c.y);
      }
      function createBody(){
         var c:BodyShape = new Bilog();
         c.x=100;
         c.y=100;
         addChild(c);
         c.listenWhileVisible(this, StepEvent.STEP, parseInput, false, 10);
      }
   }
}


Why I got an error on this...."undefined property" and when I define it above the function public function world it became null object reference.

And please can you point me to any docs about coding in wck...
Thank you very much.


Top
 Profile  
 
 Post subject: Re: Referencing a body
PostPosted: Tue Mar 27, 2012 3:41 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
When you come across an error copy paste the whole error output, otherwise it's really hard to guess what happened.

Try not naming your class "World". Adobe has an invisible, undocumented class of the same name for some reason that causes conflict.

The docs:

https://github.com/jesses/wck/wiki


Top
 Profile  
 
 Post subject: Re: Referencing a body
PostPosted: Wed Mar 28, 2012 2:02 am 
Offline

Joined: Thu Feb 23, 2012 4:22 am
Posts: 8
Thanks for your quick reply and the link. But in the WCK wiki/doc it seems I couldn't find other stuff Util.getChildPostAt, Util.addChildAtPos and the like that I can see in the WCK demo codes. I am googling that kind of scripts, can you tell me is that AS3(still consider myself noob) or there something I must learn coding in WCK.

Anyway here is the error.
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
   at World/parseInput()
   at flash.events::EventDispatcher/dispatchEventFunction()
   at flash.events::EventDispatcher/dispatchEvent()
   at Box2DAS.Common::b2EventDispatcher/dispatchEvent()
   at Box2DAS.Dynamics::b2World/Step()
   at wck::World/step()


Top
 Profile  
 
 Post subject: Re: Referencing a body
PostPosted: Thu Mar 29, 2012 1:04 pm 
Offline

Joined: Fri Dec 14, 2007 8:07 pm
Posts: 913
You are defining c in the createBody function but you are trying to use it in your parseInput function... try making it a class variable instead.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Powered by phpBB® Forum Software © phpBB Group