So for 2012 I'm trying to work smarter by using Classes. I've used Flash before and usually just throw all my AS in the actions panel each time. I get that I'm missing out so I'm trying to learn Classes. I've done a handful of basic tutorials and am working on my first self-built Class and can't get it to work.
So in my .fla I have this...
Actionscript Code:
import CalculatePercentageClass;
And in my CalculatePercentageClass.as (in the same directory as the .fla) I have...
Actionscript Code:
package {
public class CalculatePercentageClass {
public function CalculatePercentageClass()
{
trace("CalculatePercentageClass LOADED");
}
public function CalculatePercentage(percent,total):String
{
public var percent:Number = Number(percent);
public var total:Number = Number(total);
if (percent > 1)
{
percent = percent/100;
}
return String(total*percent) + "%";
}
}
}
Now, I'm assuming there's quite a bit wrong here but since this is my very first class.
First, my constructor should be tracing when it loads, correct? I get no compile errors.
If anybody can see I'm heading down the wrong path on anything, please chime in.
I realize I'm not using the actual calculatePercentage method yet, I'm just trying to get some proof that it's loading correctly.
Thanks in advance!
-Layne