21.12.10

I need classes

... and here's why. I'm going to take one of the older scripts and make some changes to it.


import flash.utils.Timer;
import flash.events.TimerEvent;
var timer:Timer;

var tDura:Number =.01*1000
var Reps:Number = 500
var tStep:Number = .5
var tDone:Number = Reps * tStep

The Push_Timer class actually has variables in it, so it will be more useful in this explanation. 
Let's say that I want to change all of these from standard variables to private or protected. 

protected var tDura:Number =.01*1000
protected var Reps:Number = 500
protected var tStep:Number = .5
protected var tDone:Number = Reps * tStep

I attempt to run the program and receive these errors:

Scene 1, Layer 'Actions', Frame 1, Line 8 1150: The protected attribute can only be used on class property definitions.
Scene 1, Layer 'Actions', Frame 1, Line 7 1150: The protected attribute can only be used on class property definitions.
Scene 1, Layer 'Actions', Frame 1, Line 6 1150: The protected attribute can only be used on class property definitions.
Scene 1, Layer 'Actions', Frame 1, Line 5 1150: The protected attribute can only be used on class property definitions.

Without consulting reference, I add a little class definition at the top.

public class paera extends MovieClip

And the resulting errors:

Scene 1, Layer 'Actions', Frame 1 1084: Syntax error: expecting rightbrace before end of program.
Scene 1, Layer 'Actions', Frame 1, Line 7 1084: Syntax error: expecting leftbrace before protected.
Scene 1, Layer 'Actions', Frame 1, Line 5 1114: The public attribute can only be used inside a package.

So then I add the braces and the package notation.

The resulting error

Scene 1, Layer 'Actions', Frame 1, Line 1 1037: Packages cannot be nested.


'Packages cannot be nested' means that I cannot place my package inside of the Actions panel of Flash CS5, and therefore I won't be able to use the advanced features unless I create an external file.

No comments:

Post a Comment