| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SWF::Builder::ActionScript; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
5
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
6
|
1
|
|
|
1
|
|
6
|
use SWF::Element; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
7
|
1
|
|
|
1
|
|
6
|
use SWF::Builder; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
19
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use SWF::Builder::ExElement; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
1347
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = "0.041"; |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
|
13
|
1
|
|
|
1
|
0
|
3
|
my ($class, %param) = @_; |
|
14
|
1
|
|
50
|
|
|
13
|
bless { |
|
15
|
|
|
|
|
|
|
_version => $param{Version}||6, |
|
16
|
|
|
|
|
|
|
_actions => SWF::Element::Array::ACTIONRECORDARRAY->new, |
|
17
|
|
|
|
|
|
|
}, $class; |
|
18
|
|
|
|
|
|
|
} |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub _add_tags { |
|
21
|
1
|
|
|
1
|
|
163
|
my $self = shift; |
|
22
|
1
|
|
|
|
|
2
|
my $actions = $self->{_actions}; |
|
23
|
|
|
|
|
|
|
|
|
24
|
1
|
50
|
33
|
|
|
5
|
if ($actions->[-1] and $actions->[-1]->Tag == 0) { |
|
25
|
0
|
0
|
|
|
|
0
|
if (my $label = pop(@$actions)->LocalLabel) { |
|
26
|
0
|
|
|
|
|
0
|
push @$actions, SWF::Element::ACTIONRECORD->new( 'Tag', @{+shift}, LocalLabel => $label ); |
|
|
0
|
|
|
|
|
0
|
|
|
27
|
|
|
|
|
|
|
} |
|
28
|
|
|
|
|
|
|
} |
|
29
|
1
|
|
|
|
|
2
|
push @$actions, map { SWF::Element::ACTIONRECORD->new( 'Tag', @$_)} @_; |
|
|
5
|
|
|
|
|
543
|
|
|
30
|
1
|
|
|
|
|
52
|
$self; |
|
31
|
|
|
|
|
|
|
} |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _adata { |
|
34
|
5
|
|
|
5
|
|
374
|
SWF::Element::ACTIONDATA->new(@_); |
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub _get_type { |
|
38
|
1
|
|
|
1
|
|
24
|
my $value = shift; |
|
39
|
|
|
|
|
|
|
|
|
40
|
1
|
50
|
|
|
|
6
|
if ($value =~ /^\d+$/) { |
|
|
|
0
|
|
|
|
|
|
|
41
|
1
|
|
|
|
|
3
|
return 'Integer'; |
|
42
|
|
|
|
|
|
|
} elsif ($value =~ /^[+-]?(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/) { |
|
43
|
0
|
|
|
|
|
0
|
return 'Double'; |
|
44
|
|
|
|
|
|
|
} else { |
|
45
|
0
|
|
|
|
|
0
|
return 'String'; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
} |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub tellTarget { |
|
50
|
0
|
|
|
0
|
1
|
0
|
my ($self, $target, $code) = @_; |
|
51
|
|
|
|
|
|
|
|
|
52
|
0
|
0
|
|
|
|
0
|
if (UNIVERSAL::isa($target, 'SWF::Builder::DisplayInstance')) { |
|
53
|
0
|
|
|
|
|
0
|
$target = $target->name; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
0
|
|
|
|
|
0
|
utf2bin($target); |
|
56
|
0
|
|
|
|
|
0
|
$self->_add_tags( [ 'SetTarget', TargetName => $target ] ); |
|
57
|
0
|
|
|
|
|
0
|
&$code($self); |
|
58
|
0
|
|
|
|
|
0
|
$self->_add_tags( [ 'SetTarget', TargetName => '' ] ); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub gotoAndPlay { |
|
62
|
0
|
|
|
0
|
1
|
0
|
&gotoAndStop; |
|
63
|
0
|
|
|
|
|
0
|
shift->_add_tags( ['Play'] ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub gotoAndStop { |
|
67
|
0
|
|
|
0
|
1
|
0
|
my ($self, $frame) = @_; |
|
68
|
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
0
|
if ($frame =~ /^\d+$/) { |
|
70
|
0
|
|
|
|
|
0
|
$self->_add_tags( [ 'GotoFrame', Frame => $frame-1 ] ); |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
0
|
|
|
|
|
0
|
utf2bin($frame); |
|
73
|
0
|
|
|
|
|
0
|
$self->_add_tags( [ 'GotoLabel', Label => $frame ] ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub play { |
|
78
|
0
|
|
|
0
|
1
|
0
|
shift->_add_tags( ['Play'] ); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub stop { |
|
82
|
0
|
|
|
0
|
1
|
0
|
shift->_add_tags( ['Stop'] ); |
|
83
|
|
|
|
|
|
|
} |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub setProperty { |
|
86
|
0
|
|
|
0
|
1
|
0
|
my ($self, $property, $value) = @_; |
|
87
|
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
0
|
utf2bin($value); |
|
89
|
0
|
|
|
|
|
0
|
$self->_add_tags |
|
90
|
|
|
|
|
|
|
( [ 'Push', |
|
91
|
|
|
|
|
|
|
DataList => [ _adata( String => '' ), |
|
92
|
|
|
|
|
|
|
_adata( Property => $property ), |
|
93
|
|
|
|
|
|
|
_adata( _get_type($value) => $value ), |
|
94
|
|
|
|
|
|
|
], |
|
95
|
|
|
|
|
|
|
], |
|
96
|
|
|
|
|
|
|
[ 'SetProperty' ], |
|
97
|
|
|
|
|
|
|
); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub calcProperty { |
|
101
|
1
|
|
|
1
|
0
|
2
|
my ($self, $property, $op, $value) = @_; |
|
102
|
|
|
|
|
|
|
|
|
103
|
1
|
|
|
|
|
4
|
utf2bin($value); |
|
104
|
1
|
|
|
|
|
2
|
$self->_add_tags |
|
105
|
|
|
|
|
|
|
( [ 'Push', |
|
106
|
|
|
|
|
|
|
DataList => [ _adata( String => '' ), |
|
107
|
|
|
|
|
|
|
_adata( Property => $property ), |
|
108
|
|
|
|
|
|
|
_adata( String => '' ), |
|
109
|
|
|
|
|
|
|
_adata( Property => $property ), |
|
110
|
|
|
|
|
|
|
], |
|
111
|
|
|
|
|
|
|
], |
|
112
|
|
|
|
|
|
|
[ 'GetProperty' ], |
|
113
|
|
|
|
|
|
|
[ 'Push', |
|
114
|
|
|
|
|
|
|
DataList => [ _adata( _get_type($value) => $value ), |
|
115
|
|
|
|
|
|
|
], |
|
116
|
|
|
|
|
|
|
], |
|
117
|
|
|
|
|
|
|
[ $op ], |
|
118
|
|
|
|
|
|
|
[ 'SetProperty' ], |
|
119
|
|
|
|
|
|
|
); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub moveto { |
|
124
|
0
|
|
|
0
|
1
|
0
|
my ($self, $x, $y) = @_; |
|
125
|
|
|
|
|
|
|
|
|
126
|
0
|
|
|
|
|
0
|
$self->setProperty('_x', $x); |
|
127
|
0
|
|
|
|
|
0
|
$self->setProperty('_y', $y); |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub r_moveto { |
|
131
|
0
|
|
|
0
|
1
|
0
|
my ($self, $x, $y) = @_; |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
0
|
$self->calcProperty('_x', 'Add2', $x); |
|
134
|
0
|
|
|
|
|
0
|
$self->calcProperty('_y', 'Add2', $y); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
sub rotate { |
|
138
|
0
|
|
|
0
|
1
|
0
|
my ($self, $r) = @_; |
|
139
|
|
|
|
|
|
|
|
|
140
|
0
|
|
|
|
|
0
|
$self->setProperty('_rotation', $r); |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub r_rotate { |
|
144
|
1
|
|
|
1
|
1
|
2
|
my ($self, $r) = @_; |
|
145
|
|
|
|
|
|
|
|
|
146
|
1
|
|
|
|
|
3
|
$self->calcProperty('_rotation', 'Add2', $r); |
|
147
|
|
|
|
|
|
|
} |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub scale { |
|
150
|
0
|
|
|
0
|
1
|
|
my ($self, $xscale, $yscale) = @_; |
|
151
|
|
|
|
|
|
|
|
|
152
|
0
|
|
0
|
|
|
|
$yscale ||= $xscale; |
|
153
|
0
|
|
|
|
|
|
$self->setProperty('_xscale', $xscale); |
|
154
|
0
|
|
|
|
|
|
$self->setProperty('_yscale', $yscale); |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
sub show { |
|
158
|
0
|
|
|
0
|
1
|
|
shift->setProperty('_visible', 1); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
sub hide { |
|
162
|
0
|
|
|
0
|
1
|
|
shift->setProperty('_visible', 0); |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
# compiler |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
sub compile { |
|
170
|
0
|
|
|
0
|
1
|
|
require SWF::Builder::ActionScript::Compiler; |
|
171
|
|
|
|
|
|
|
|
|
172
|
0
|
|
|
|
|
|
my $self = shift; |
|
173
|
0
|
|
|
|
|
|
my $c = SWF::Builder::ActionScript::Compiler->new(@_, Version => $self->{_version}); |
|
174
|
|
|
|
|
|
|
|
|
175
|
0
|
|
|
|
|
|
$c->compile($self->{_actions}); |
|
176
|
|
|
|
|
|
|
} |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
sub load { |
|
179
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
180
|
0
|
|
|
|
|
|
my $file = shift; |
|
181
|
|
|
|
|
|
|
|
|
182
|
0
|
|
|
|
|
|
open my $f, '<', $file; |
|
183
|
0
|
|
|
|
|
|
select((select($f), undef $/)[0]); |
|
184
|
0
|
|
|
|
|
|
$self->compile(<$f>, @_); |
|
185
|
|
|
|
|
|
|
} |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
1; |
|
188
|
|
|
|
|
|
|
__END__ |