Tuesday, May 19, 2009

Some good progress today but have gotten sleepy. I built two classes: one for creating pieces of text on a page (TextFields) and one for drawing graphics (Sprites) such as circle on a page. I was then able to add an event listener to one of the sprite, read in the resulting word, string split the word and display the first element of the word.
package {
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
public class ParseString extends Sprite
{
public var theTextField:TextField = new TextField();

public function ParseString()
{
var sT:ShowText = new ShowText();
theTextField = sT.makeInputText( 10, 10, 20, 400, true, true );
this.addChild(theTextField);
var s:ShowCircle = new ShowCircle(50, 150, 15);
s.addEventListener(MouseEvent.CLICK, showText);
this.addChild(s);
}

public function showText(e:Event):void
{
var sT:ShowText = new ShowText();
var um:String = theTextField.text.toString();
var guy:Array = um.split(" ");
var result:TextField = sT.makeDynamicText( guy[0], 10, 50, 20, 400, false, true );
this.addChild(result);
}
}
}


Sweetness. From here I need to count all the words and how many times each one is used.

0 comments: