fixed bug in jpeg2000 decoding
[swftools.git] / doc / examples / textselect.sc
1 .flash version=6
2
3     .font Arial "../doc/Arial.swf"
4     .edittext et width=600 height=50 color=black font=Arial size=40pt border text=test variable=text_selection 
5
6     .frame 1
7
8         .swf TextBox document.swf
9         .put TextBox
10         .put et x=10 y=10
11
12     .frame 2
13
14     .action:
15         str = TextBox.getTextSnapShot();
16         str.setSelectColor(0xffff00);
17         firstChar = -1;
18
19         TextBox.onMouseDown = function() {
20             firstChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0);
21             str.setSelected(0, str.getCount(), false);
22             _root.text_selection = str.getSelectedText(true);
23         };
24
25         TextBox.onMouseUp = function() {
26             if (firstChar >= 0) {
27                 lastChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0);
28                 if (firstChar != lastChar) {
29                      if (firstChar < lastChar) {
30                          str.setSelected(firstChar, lastChar+1, true);
31                          _root.text_selection = str.getSelectedText(true);
32                      } else {
33                          str.setSelected(lastChar, firstChar+1, true);
34                      }
35                  }
36                  _root.text_selection = str.getSelectedText(true);
37                  firstChar = -1;
38                  lastChar = -1;
39             }
40         };
41
42         TextBox.onMouseMove = function() {
43             if(firstChar != -1) {
44                 str.setSelected(0, str.getCount(), false); //unselect everything
45
46                 lastChar = str.hitTestTextNearPos(_xmouse, _ymouse, 0);
47                 if (firstChar < lastChar) {
48                     str.setSelected(firstChar, lastChar+1, true);
49                 } else if(lastChar >= 0) {
50                     str.setSelected(lastChar, firstChar+1, true);
51                 }
52                 _root.text_selection = str.getSelectedText(true);
53             }
54         };
55     .end
56
57     .frame 3
58         .action:
59             Stop();
60         .end
61
62 .end
63