I don't like external as files. Most developers prefer this and claim it's better. Explain why is it better to use classes in ActionScript 3.0.
My ActionScripts are different. I strip the classes away and paste it in the Flash IDE. 9 out of 10 times it works fine. My question is Socratic, but I really feel ignorant about this, since there is less code for what I'm trying to do. Have fun with this.
Here's a tutorial I dissected - "example tests keyboard output"
//AFTER
//remove curly brackets and "outer shell of class definitions"
//remove class function "don't need it"
//function at bottom, remove "public", make sure it has a body {}
var _time_scale:Number = .25;
var _frames_elapsed:int = 0;
var _clip:MovieClip;
function handleEnterFrame(e:Event):void {
_frames_elapsed++;
_clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale));
}
//BEFORE
package {
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
public class Main extends Sprite {
private var _time_scale:Number = .25;
private var _frames_elapsed:int = 0;
private var _clip:MovieClip;
public function Main():void {
_clip = new SomeClip;
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
}
private function handleEnterFrame(e:Event):void {
_frames_elapsed++;
// we multiply the "real" time with our timescale to get the scaled time
// we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off
_clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale));
}
}
}
There may be no answer, but there must be a definative explanation that makes sense.