Applying Gravity to certain objects! HELP!

Hey everyone,

so I found posts about applying gravity to certain objects and I keep getting a Reference Error and am not sure what to do about it.

I loaded up b2Island.as and switched the gravity code to

Code:
         if ( b.m_userData.gravity == false ){
           
            b.m_linearVelocity.x += step.dt * (b.m_invMass * b.m_force.x);
            b.m_linearVelocity.y += step.dt * (b.m_invMass * b.m_force.y);
           
         } else {

            b.m_linearVelocity.x += step.dt * (gravity.x + b.m_invMass * b.m_force.x);
            b.m_linearVelocity.y += step.dt * (gravity.y + b.m_invMass * b.m_force.y);
           
         } //end if else


and when building my body's I do

bodyRef.userdata = new Sprite();
bodyRef.userdata.gravity = true/false;

And everytime I run this I get
ReferenceError: Error #1056: Cannot create property gravity on flash.display.Sprite.

Help!
Sprite is not a dynamic class. In order to add properties at run time in flash you need to have the class be declared as dynamic. You could get around this many ways but the simplest is to just use MovieClip instead.
I get the same issue when I change it to movieclip

Original thread: https://box2d.org/forum/viewtopic.php?t=4900