flash on 2012-12-5
♥0 |
Line 42 |
Modified 2012-12-05 22:08:58 |
MIT License
archived:2017-03-30 22:55:55
ActionScript3 source code
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aRlx
*/
package {
import flash.text.TextField;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public var deb:TextField;
public var mp:MiniParser = new MiniParser();
public function FlashTest() {
deb = new TextField();
addChild(deb);
var str:String;
str = "Move_node1_node2";
mp.parseCommand(str, "_", 16);
deb.text = "";
deb.appendText("Command: " + mp.getCommand() );
deb.appendText("\n Arg1: " + mp.getArg(1) );
deb.appendText("\n Arg2: " + mp.getArg(2) );
deb.appendText("\n Arg3: " + mp.getArg(3) );
}//ctor
}//classend
}
internal class MiniParser
{
public var result:Array;
public var num:int = 0;
public function getCommand():String
{
if (result == null) { return "none"; }
if (num <= 0) { return "none"; }
return result[0];
}//getcmnd
//0 is the command
public function getArg(arg:int):String
{
if (result == null) { return "none"; }
if (num <= arg) { return "none"; }
return result[arg];
}//getarg
public function parseCommand(str:String, div:String=" ", max:int=16):void
{
result = str.split(div, max);
num = result.length;
}//parsecommand
};//classend