-
Notifications
You must be signed in to change notification settings - Fork 0
/
Pron.as
executable file
·91 lines (78 loc) · 2.6 KB
/
Pron.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*
This file is part of the matbury.com Actionscript library
matbury.com Multimedia Interactive Learning Applications (MILAs) are
free software: you can redistribute them and/or modify them under
the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
MILAs are distributed in the hope that they will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MILAs. If not, see <http://www.gnu.org/licenses/>.
@copyright © 2011 Matt Bury
@link https://matbury.com/
@email matbury@gmail.com
@license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
/*
Pron.as class creates a 200x150 white rectangle with a TextField in the centre.
For displaying text as images, especially for IPA tokens.
Copyright © 2012 Matt Bury .
http://matbury.com/
matbury@gmail.com
Constructor:
var pron:Pron = new Pron(token:String);
addChild(pron);
Requires Charis SIL font embedded including characters: /i:ɪʊuəeˈˌɜɔæʌɑɒapbtdʧʤkgfvθðszʃʒmnŋhlrwj (British English PA).
*/
package com.matbury {
import flash.display.Sprite;
import flash.display.Shape;
import flash.text.*;
import flash.filters.DropShadowFilter;
public class Pron extends Sprite {
private var _bg:Shape;
private var _t:TextField;
private var _token:String;
public function Pron(token:String) {
_token = token;
initBg();
initText();
filters = [new DropShadowFilter(2,45,0,1,2,2)];
mouseChildren = false;
}
private function initBg():void {
_bg = new Shape();
_bg.graphics.beginFill(0xFFFFFF,1);
_bg.graphics.drawRect(0,0,20,20);
_bg.graphics.endFill();
addChild(_bg);
}
private function initText():void {
var size:int = 20;
var f:TextFormat = new TextFormat("Charis SIL",size);
_t = new TextField();
_t.defaultTextFormat = f;
_t.autoSize = TextFieldAutoSize.LEFT;
_t.embedFonts = true;
_t.text = _token;
_t.selectable = false;
_t.x = 15;
_t.y = 15;
addChild(_t);
}
private function resizeBg():void {
_bg.width = _t.width;
_bg.height = _t.height;
_bg.x = _t.x;
_bg.y = _t.y;
}
public function set tokens(s:String):void {
_token = s;
_t.text = _token;
resizeBg();
}
}
}