This content has been marked as final. Show 2 replies
I don’t think you need the first void in the brackets. The parameters a method takes in there would go inside the brackets. If a method took in a number, it would go: function aFunctionName(inputNumber:Number):Void
Since onEnterFrame takes in no parameters, I’m guessing that’s why void is there. But it can also be written: function onEnterFrame():Void
The second void specifics what the method would return after it’s called. If it returned a number, it would be: function aFunctionName():Number. Since onEnterFrame method returns ‘nothing’, that is why the void is there.
However, from your attached code, (which doesn’t appear strict AS2), you can also leave this off and have: function onEnterFrame()
Conversely, you could have written you init() method like: function init(void):Void
As for spinning, I’m assuming this means actually rotating the ball. You could try something like when the user clicks on the ball, you get the difference between the position of the mouse and the ball’s center, and then use that as a rotation speed/magnitude and spin it by that amount every frame.
I got this code originally from a Friends of ED Actionscript Animation book I am working through, and there is little explanation of Void - that I understand, anyway. Just to clarify, I'm actually using a playing card - not a ball, for my throwing action (I just used code that was already there, and am working on modifying it for my needs).
Thanks for the spinning advice! I'll work on that and see what I can come up with!