hi
maybe someone can help me:)
i have a game character that is a bodyshape and inside it i have a box....
my hero has a custom class hero.as that extends wck.BodyShape
in this class if put this.restitution = 0.4 does not override the default value in the component definition
any idea what i'm doing wrong?
10x in advance!
So in FlashCS5 you want the default component property value to change from what the base class defines? I've tried to do that before various different ways and failed. I'd also like to know if it's possible.
The workaround I eventually did was to have all inspectable component properties as strings equal to "default", then my code handled the assignment of the actual default value if the user didn't specify a number. Any number input was changed from a string using parseInt()/parseFloat(). I generally set the variable name to show the actual default value, i.e. in the Inspectable metadata tag set the name to "friction (default=0.7)" instead of just "friction", unless it was expected that subclasses would be modifying the default value a lot. I understand that even this workaround doesn't work in a lot of situations, but maybe it can spark an idea for you or something.
mayobutter 10x for your reply
unfortunately still does not work.....
public override function create():void {
restitution = 0.4;
super.create();
}
this does not override default component definition values either i have a bodyshape with a box in it or a simple bodyshape with a vector in it.....
i could not find the isGuideShape property for shapes.Box
Ok, let me be clear what that does: it sets restitution to a value in code AFTER flash sets restitution to whatever is entered in the component inspector, whether it is a custom value or the default. Then super.create() uses that value when it creates the shape (or body). So whatever you enter in the component inspector is irrelevant; it is overridden at the last posible moment.
If you want the default restitution to be something different for all BodyShapes, you'll have to edit the source. Then you'll have to reopen the "Component Properties" dialog and hit "OK" to force flash to reload the component definition and inspectable properties. You may even have to delete your existing instances and re-drag them to the stage. It's kind of a pain.