Thursday, September 20, 2007
Thursday, September 20, 2007    

Okay cool, thanks to Mark Walters I now have AS3 syntax highlighting support here. I may play with the javascript file though and make some tweaks here and there.
package {

import flash.display.TextField;
import flash.text.TextFormat;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.EventType;

public class TestTextPosition extends Sprite {

var textfield1:TextField = new TextField();
var textfield2:TextField = new TextField();
var textformat1:TextFormat = new TextFormat();
var textformat2:TextFormat = new TextFormat();
var textformat3:TextFormat = new TextFormat();

public function TestTextPosition () {
textformat1.font = "Arial";
textformat1.color = 0x0000ff;
textformat1.size = 60;

textformat2.font = "Arial";
textformat2.color = 0x0000ff;
textformat2.size = 20;

textformat3.font = "Arial";
textformat3.color = 0x000000;
textformat3.size = 14;

textfield1.width = 400;
textfield1.height = 55;
textfield1.multiline = true;
textfield1.wordWrap = true;
textfield1.type = "input";
textfield1.text = "Roll your mouse over this text to see something neat.\n";
textfield1.text += "Change the text to see that it is really dynamic.";
addChild(textfield1);

textfield2.x = 10;
textfield2.y = 50;
textfield2.width = 100;
textfield2.height = 100;
textfield2.selectable = false;
textfield2.border = true;
textfield2.background = true;
textfield2.backgroundColor = 0xffffaa;
textfield2.defaultTextFormat = textformat1;
addChild(textfield2);

this.addEventListener(EventType.ENTER_FRAME, enterFrameListener);
}

public function enterFrameListener(event:Event) {
textfield1.setTextFormat(textformat3);
var charIndex:int = textfield1.getCharIndexAtPoint(stage.mouseX,stage.mouseY);
textfield1.setTextFormat(textformat2,charIndex,charIndex+1);
textfield2.text = textfield1.text.charAt(charIndex);
}
}
}


0 Comments:

Post comment

Links to this post:


Create a Link

gotoAndStop( topOfPage );