as3 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "sprout", '>= 1.0.0.pre'
4
+ gem "flex3sdk", '>= 3.5.0.pre'
5
+
6
+ group :development do
7
+ gem "shoulda"
8
+ gem "mocha"
9
+
10
+ # rcov doesn't appear to install on
11
+ # debian/ubuntu. Boo. Ideas?
12
+ if RUBY_PLATFORM =~ /darwin/i
13
+ gem "rcov"
14
+ end
15
+ end
16
+
data/README.rdoc ADDED
@@ -0,0 +1,35 @@
1
+ = Project Sprouts ActionScript 3 Language Bundle
2
+
3
+ This RubyGem includes (or references) everything you need to build SWF or AIR content with ActionScript 3.0.
4
+
5
+ == Description:
6
+
7
+ This is the bundle that represents the entry point to ActionScript 3 development with Project Sprouts.
8
+
9
+ == Install:
10
+
11
+ gem install sprout-as3
12
+ sprout-as3 SomeProject
13
+
14
+ == MIT License
15
+
16
+ Copyright (c) 2007 Luke Bayes
17
+
18
+ Permission is hereby granted, free of charge, to any person obtaining
19
+ a copy of this software and associated documentation files (the
20
+ 'Software'), to deal in the Software without restriction, including
21
+ without limitation the rights to use, copy, modify, merge, publish,
22
+ distribute, sublicense, and/or sell copies of the Software, and to
23
+ permit persons to whom the Software is furnished to do so, subject to
24
+ the following conditions:
25
+
26
+ The above copyright notice and this permission notice shall be
27
+ included in all copies or substantial portions of the Software.
28
+
29
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
30
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
31
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
32
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
33
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
34
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
35
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/as3.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path File.join(File.dirname(__FILE__), 'lib')
3
+ $:.unshift lib unless $:.include?(lib)
4
+
5
+ require 'rubygems'
6
+ require 'bundler'
7
+ Bundler.setup
8
+
9
+ require 'as3'
10
+
11
+ Gem::Specification.new do |s|
12
+ s.name = AS3::NAME
13
+ s.version = AS3::VERSION::STRING
14
+ s.author = 'Luke Bayes'
15
+ s.email = 'lbayes@patternpark.com'
16
+ s.description = 'This is the project generator for ActionScript 3.0 projects'
17
+ s.homepage = 'http://projectsprouts.org'
18
+ s.rubyforge_project = 'sprout'
19
+ s.summary = 'Project Generator for an ActionScript 3.0 project'
20
+ s.executable = 'sprout-as3'
21
+ s.files = FileList['**/**/*'].exclude /.git|.svn|.DS_Store/
22
+ s.add_bundler_dependencies
23
+ end
24
+
data/bin/sprout-as3 ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'as3'
5
+
6
+ generator = AS3::ProjectGenerator.new
7
+ generator.parse! ARGV
8
+ generator.execute
9
+
data/lib/as3.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'sprout'
2
+
3
+ lib = File.expand_path File.dirname(__FILE__)
4
+ $:.unshift lib unless $:.include?(lib)
5
+
6
+ require 'as3/generators/class_generator'
7
+ require 'as3/generators/project_generator'
8
+ require 'as3/tasks/mxmlc'
9
+
10
+ module AS3
11
+ NAME = 'as3'
12
+
13
+ if(!defined? AS3::VERSION)
14
+ module VERSION #:nodoc:
15
+ MAJOR = 1
16
+ MINOR = 0
17
+ TINY = '0.pre'
18
+
19
+ STRING = [MAJOR, MINOR, TINY].join('.')
20
+ MAJOR_MINOR = [MAJOR, MINOR].join('.')
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,55 @@
1
+ module AS3
2
+ class ClassGenerator < Sprout::Generator::Base
3
+
4
+ ##
5
+ # The path where source files should be created.
6
+ add_param :src, String, { :default => 'src' }
7
+
8
+ def manifest
9
+ directory class_directory do
10
+ template "#{class_name}.as", 'ActionScript3Class.as'
11
+ end
12
+ end
13
+
14
+ protected
15
+
16
+ def class_directory
17
+ parts = input_in_parts
18
+ if parts.size > 1
19
+ parts.pop
20
+ return File.join src, *parts
21
+ end
22
+ return src
23
+ end
24
+
25
+ def package_name
26
+ parts = input_in_parts
27
+ if parts.size > 1
28
+ parts.pop
29
+ return "#{parts.join('.')} "
30
+ end
31
+ return ""
32
+ end
33
+
34
+ def class_name
35
+ parts = input_in_parts
36
+ parts.pop.camel_case
37
+ end
38
+
39
+ def input_in_parts
40
+ provided_input = input
41
+ if provided_input.include?('/')
42
+ provided_input.gsub! /^#{src}\//, ''
43
+ provided_input = provided_input.split('/').join('.')
44
+ end
45
+
46
+ provided_input.gsub!(/\.as$/, '')
47
+ provided_input.gsub!(/\.mxml$/, '')
48
+ provided_input.gsub!(/\.xml$/, '')
49
+
50
+ provided_input.split('.')
51
+ end
52
+
53
+ end
54
+
55
+ end
@@ -0,0 +1,53 @@
1
+ module AS3
2
+ class ProjectGenerator < ClassGenerator
3
+
4
+ ##
5
+ # The path where assets will be created.
6
+ add_param :assets, String, { :default => 'assets' }
7
+
8
+ ##
9
+ # The path where skins will be created.
10
+ add_param :skins, String, { :default => 'skins' }
11
+
12
+ ##
13
+ # The path where test cases should be created.
14
+ add_param :test, String, { :default => 'test' }
15
+
16
+ ##
17
+ # The path where libraries should be added.
18
+ add_param :lib, String, { :default => 'lib' }
19
+
20
+ ##
21
+ # The path where binaries should be created.
22
+ add_param :bin, String, { :default => 'bin' }
23
+
24
+ def manifest
25
+ directory input do
26
+ template 'rakefile.rb'
27
+ template 'Gemfile'
28
+
29
+ directory src do
30
+ template "#{input}.as", 'ActionScript3MainClass.as'
31
+ end
32
+
33
+ directory assets do
34
+ directory skins do
35
+ file 'DefaultProjectImage.png'
36
+ end
37
+ end
38
+
39
+ # Create empty directories:
40
+ directory lib
41
+ directory bin
42
+ end
43
+ end
44
+
45
+ protected
46
+
47
+ def debug_swf_name
48
+ "#{class_name}.swf"
49
+ end
50
+
51
+ end
52
+
53
+ end
@@ -0,0 +1,9 @@
1
+ package <%= package_name %>{
2
+
3
+ public class <%= class_name %> {
4
+
5
+ public function <%= class_name %>() {
6
+ }
7
+ }
8
+ }
9
+
@@ -0,0 +1,11 @@
1
+ package <%= package_name %>{
2
+ import flash.display.Sprite;
3
+
4
+ public class <%= class_name %> extends Sprite {
5
+
6
+ public function <%= class_name %>() {
7
+ trace(">> <%= class_name %> Instantiated!");
8
+ }
9
+ }
10
+ }
11
+
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "as3", ">= 1.0.pre"
4
+ gem "asunit4", ">= 4.2.pre"
5
+
@@ -0,0 +1,15 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup
4
+
5
+ require 'as3'
6
+
7
+ library :asunit4
8
+
9
+ mxmlc "<%= bin %>/<%= debug_swf_name %>" => :asunit4 do |t|
10
+ t.input = "<%= src %>/<%= class_name %>.as"
11
+ end
12
+
13
+ desc "Compile a debuggable SWF"
14
+ task :debug => "<%= bin %>/<%= debug_swf_name %>"
15
+
@@ -0,0 +1,821 @@
1
+ module AS3
2
+
3
+ # The MXMLC task provides a rake front end to the Flex MXMLC command line compiler.
4
+ # This task is integrated with the LibraryTask so that if any dependencies are
5
+ # library tasks, they will be automatically added to the library_path or source_path
6
+ # depending on whether they provide a swc or sources.
7
+ #
8
+ # The entire MXMLC advanced interface has been provided here. All parameter names should be
9
+ # identical to what is available on the regular compiler except dashes have been replaced
10
+ # by underscores.
11
+ #
12
+ # The following example can be pasted in a file named 'rakefile.rb' which should be placed in
13
+ # the same folder as an ActionScript 3.0 class named 'SomeProject.as' that extends
14
+ # flash.display.Sprite.
15
+ #
16
+ # # Create a remote library dependency on the corelib swc.
17
+ # library :corelib
18
+ #
19
+ # # Alias the compilation task with one that is easier to type
20
+ # task :compile => 'SomeProject.swf'
21
+ #
22
+ # # Create an MXMLC named for the output file that it creates. This task depends on the
23
+ # # corelib library and will automatically add the corelib.swc to it's library_path
24
+ # mxmlc 'SomeProject.swf' => :corelib do |t|
25
+ # t.input = 'SomeProject.as'
26
+ # t.default_size = '800 600'
27
+ # t.default_background_color = "#FFFFFF"
28
+ # end
29
+ #
30
+ # Note: Be sure to check out the features of the Executable to learn more about gem_version and preprocessor
31
+ #
32
+ # Interface and descriptions found here:
33
+ # http://livedocs.adobe.com/flex/2/docs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001481.html
34
+ #
35
+ class MXMLC
36
+ include Sprout::Executable
37
+
38
+ ##
39
+ # Enables accessibility features when compiling the Flex application or SWC file. The default value is false.
40
+ #
41
+ add_param :accessible, Boolean, { :hidden_value => true }
42
+
43
+ ##
44
+ # Sets the file encoding for ActionScript files. For more information see: http://livedocs.adobe.com/flex/2/docs/00001503.html#149244
45
+ #
46
+ add_param :actionscript_file_encoding, String
47
+
48
+ ##
49
+ # Checks if a source-path entry is a subdirectory of another source-path entry. It helps make the package names of MXML components unambiguous. This is an advanced option.
50
+ #
51
+ add_param :allow_source_path_overlap, Boolean, { :hidden_value => true }
52
+
53
+ ##
54
+ # Use the ActionScript 3.0 class-based object model for greater performance and better error reporting. In the class-based object model, most built-in functions are implemented as fixed methods of classes.
55
+ #
56
+ # The default value is true. If you set this value to false, you must set the es option to true.
57
+ #
58
+ # This is an advanced option.
59
+ add_param :as3, Boolean, { :default => true, :show_on_false => true }
60
+
61
+ ##
62
+ # Prints detailed compile times to the standard output. The default value is true.
63
+ #
64
+ add_param :benchmark, Boolean, { :default => true, :show_on_false => true }
65
+
66
+ ##
67
+ # Sets the value of the {context.root} token in channel definitions in the flex-services.xml file. If you do not specify the value of this option, Flex uses an empty string.
68
+ #
69
+ # For more information on using the {context.root} token, see http://livedocs.adobe.com/flex/2/docs/00001446.html#205687.
70
+ #
71
+ add_param :context_root, Path
72
+
73
+ ##
74
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380).
75
+ #
76
+ add_param :contributor, String
77
+
78
+ ##
79
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380)
80
+ #
81
+ add_param :creator, String
82
+
83
+ ##
84
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files. (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380)
85
+ #
86
+ add_param :date, String
87
+
88
+ ##
89
+ # Generates a debug SWF file. This file includes line numbers and filenames of all the source files. When a run-time error occurs, the stacktrace shows these line numbers and filenames. This information is also used by the command-line debugger and the Flex Builder debugger. Enabling the debug option generates larger SWF files.
90
+ #
91
+ # For the mxmlc compiler, the default value is false. For the compc compiler, the default value is true.
92
+ #
93
+ # For SWC files generated with the compc compiler, set this value to true, unless the target SWC file is an RSL. In that case, set the debug option to false.
94
+ #
95
+ # For information about the command-line debugger, see Using the Command-Line Debugger (http://livedocs.adobe.com/flex/2/docs/00001540.html#181846).
96
+ #
97
+ # Flex also uses the verbose-stacktraces setting to determine whether line numbers are added to the stacktrace.
98
+ #
99
+ add_param :debug, Boolean, { :hidden_value => true }
100
+
101
+ ##
102
+ # Lets you engage in remote debugging sessions with the Flash IDE. This is an advanced option.
103
+ #
104
+ add_param :debug_password, String
105
+
106
+ ##
107
+ # Sets the application's background color. You use the 0x notation to set the color, as the following example shows:
108
+ #
109
+ # -default-background-color=0xCCCCFF
110
+ #
111
+ # The default value is null. The default background of a Flex application is an image of a gray gradient. You must override this image for the value of the default-background-color option to be visible. For more information, see Editing application settings (http://livedocs.adobe.com/flex/2/docs/00001504.html#138781).
112
+ #
113
+ # This is an advanced option.
114
+ #
115
+ add_param :default_background_color, String
116
+
117
+ ##
118
+ # Sets the application's frame rate. The default value is 24. This is an advanced option.
119
+ #
120
+ add_param :default_frame_rate, Number
121
+
122
+ ##
123
+ # Defines the application's script execution limits.
124
+ #
125
+ # The max-recursion-depth value specifies the maximum depth of Adobe Flash Player call stack before Flash Player stops. This is essentially the stack overflow limit. The default value is 1000.
126
+ #
127
+ # The max-execution-time value specifies the maximum duration, in seconds, that an ActionScript event handler can execute before Flash Player assumes that it is hung, and aborts it. The default value is 60 seconds. You cannot set this value above 60 seconds.
128
+ #
129
+ # Example:
130
+ #
131
+ # # 900 is new max-recursion-depth
132
+ # # 20 is new max-execution-time
133
+ # t.default_script_limits = '900 20'
134
+ #
135
+ # You can override these settings in the application.
136
+ #
137
+ # This is an advanced option.
138
+ #
139
+ add_param :default_script_limits, String
140
+
141
+ ##
142
+ # Defines the default application size, in pixels for example: default_size = '950 550'. This is an advanced option.
143
+ #
144
+ add_param :default_size, String, { :delimiter => ' ' }
145
+
146
+ ##
147
+ # Defines the location of the default style sheet. Setting this option overrides the implicit use of the defaults.css style sheet in the framework.swc file.
148
+ #
149
+ # For more information on the defaults.css file, see Using Styles and Themes (http://livedocs.adobe.com/flex/2/docs/00000751.html#241755) in Flex 2 Developer's Guide.
150
+ #
151
+ # This is an advanced option.
152
+ #
153
+ add_param :default_css_url, Url
154
+
155
+ ##
156
+ # This parameter is normally called 'define' but thanks to scoping issues with Sprouts and Rake, we needed to rename it and chose: 'define_conditional'.
157
+ #
158
+ # Define a global AS3 conditional compilation definition, e.g. -define=CONFIG::debugging,true or -define+=CONFIG::debugging,true (to append to existing definitions in flex-config.xml) (advanced, repeatable)
159
+ #
160
+ add_param :define_conditional, Strings, { :shell_name => "-define" }
161
+
162
+ ##
163
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380).
164
+ #
165
+ add_param :description, String
166
+
167
+ ##
168
+ # Outputs the compiler options in the flex-config.xml file to the target path; for example:
169
+ #
170
+ # mxmlc -dump-config myapp-config.xml
171
+ #
172
+ # This is an advanced option.
173
+ #
174
+ add_param :dump_config, File
175
+
176
+ ##
177
+ # Use the ECMAScript edition 3 prototype-based object model to allow dynamic overriding of prototype properties. In the prototype-based object model, built-in functions are implemented as dynamic properties of prototype objects.
178
+ #
179
+ # You can set the strict option to true when you use this model, but it might result in compiler errors for references to dynamic properties.
180
+ #
181
+ # The default value is false. If you set this option to true, you must set the es3 option to false.
182
+ #
183
+ # This is an advanced option.
184
+ #
185
+ add_param :es, Boolean
186
+
187
+ ##
188
+ # Sets a list of symbols to exclude from linking when compiling a SWF file.
189
+ #
190
+ # This option provides compile-time link checking for external references that are dynamically linked.
191
+ #
192
+ # For more information about dynamic linking, see About linking (http://livedocs.adobe.com/flex/2/docs/00001521.html#205852).
193
+ #
194
+ # This is an advanced option.
195
+ #
196
+ add_param :externs, Strings
197
+
198
+ ##
199
+ # Specifies a list of SWC files or directories to exclude from linking when compiling a SWF file. This option provides compile-time link checking for external components that are dynamically linked.
200
+ #
201
+ # For more information about dynamic linking, see About linking (http://livedocs.adobe.com/flex/2/docs/00001521.html#205852).
202
+ #
203
+ # You can use the += operator to append the new SWC file to the list of external libraries.
204
+ #
205
+ # This parameter has been aliased as +el+.
206
+ #
207
+ add_param :external_library_path, Files
208
+
209
+ ##
210
+ # Alias for external_library_path
211
+ #
212
+ add_param_alias :el, :external_library_path
213
+
214
+ ##
215
+ # Specifies source files to compile. This is the default option for the mxmlc compiler.
216
+ #
217
+ add_param :file_specs, Files
218
+
219
+ ##
220
+ # Specifies the range of Unicode settings for that language. For more information, see Using Styles and Themes (http://livedocs.adobe.com/flex/2/docs/00000751.html#241755) in Flex 2 Developer's Guide.
221
+ #
222
+ # This is an advanced option.
223
+ #
224
+ add_param :fonts_languages_language_range, String, { :shell_name => "-compiler.fonts.languages.language-range" }
225
+
226
+ ##
227
+ # Defines the font manager. The default is flash.fonts.JREFontManager. You can also use the flash.fonts.BatikFontManager. For more information, see Using Styles and Themes in Flex 2 Developer's Guide (http://livedocs.adobe.com/flex/2/docs/00000751.html#241755).
228
+ #
229
+ # This is an advanced option.
230
+ #
231
+ add_param :fonts_managers, Strings
232
+
233
+ ##
234
+ # Sets the maximum number of fonts to keep in the server cache. For more information, see Caching fonts and glyphs (http://livedocs.adobe.com/flex/2/docs/00001469.html#208457).
235
+ #
236
+ # This is an advanced option.
237
+ #
238
+ add_param :fonts_max_cached_fonts, Number
239
+
240
+ ##
241
+ # Sets the maximum number of character glyph-outlines to keep in the server cache for each font face. For more information, see Caching fonts and glyphs (http://livedocs.adobe.com/flex/2/docs/00001469.html#208457).
242
+ #
243
+ # This is an advanced option.
244
+ #
245
+ add_param :fonts_max_glyphs_per_face, Number
246
+
247
+ ##
248
+ # Specifies a SWF file frame label with a sequence of class names that are linked onto the frame.
249
+ #
250
+ # For example: frames_frame = 'someLabel MyProject OtherProject FoodProject'
251
+ #
252
+ # This is an advanced option.
253
+ #
254
+ add_param :frames_frame, String, { :shell_name => '-frames.frame' }
255
+
256
+ ##
257
+ # Toggles the generation of an IFlexBootstrap-derived loader class.
258
+ #
259
+ # This is an advanced option.
260
+ #
261
+ add_param :generate_frame_loader, Boolean
262
+
263
+ ##
264
+ # Enables the headless implementation of the Flex compiler. This sets the following:
265
+ #
266
+ # System.setProperty('java.awt.headless', 'true')
267
+ #
268
+ # The headless setting (java.awt.headless=true) is required to use fonts and SVG on UNIX systems without X Windows.
269
+ #
270
+ # This is an advanced option.
271
+ #
272
+ add_param :headless_server, Boolean
273
+
274
+ ##
275
+ # Links all classes inside a SWC file to the resulting application SWF file, regardless of whether or not they are used.
276
+ #
277
+ # Contrast this option with the library-path option that includes only those classes that are referenced at compile time.
278
+ #
279
+ # To link one or more classes whether or not they are used and not an entire SWC file, use the includes option.
280
+ #
281
+ # This option is commonly used to specify resource bundles.
282
+ #
283
+ add_param :include_libraries, Files
284
+
285
+ ##
286
+ # Links one or more classes to the resulting application SWF file, whether or not those classes are required at compile time.
287
+ #
288
+ # To link an entire SWC file rather than individual classes, use the include-libraries option.
289
+ #
290
+ add_param :includes, Strings
291
+
292
+ ##
293
+ # Define one or more directory paths for include processing. For each path that is provided, all .as and .mxml files found forward of that path will
294
+ # be included in the SWF regardless of whether they are imported or not.
295
+ add_param :include_path, Paths
296
+
297
+ ##
298
+ # Enables incremental compilation. For more information, see About incremental compilation (http://livedocs.adobe.com/flex/2/docs/00001506.html#153980).
299
+ #
300
+ # This option is true by default for the Flex Builder application compiler. For the command-line compiler, the default is false. The web-tier compiler does not support incremental compilation.
301
+ #
302
+ add_param :incremental, Boolean
303
+
304
+ ##
305
+ # Keep the specified metadata in the SWF (advanced, repeatable).
306
+ #
307
+ # Example:
308
+ #
309
+ # Rakefile:
310
+ #
311
+ # mxmlc 'bin/SomeProject.swf' do |t|
312
+ # t.keep_as3_metadata << 'Orange'
313
+ # end
314
+ #
315
+ # Source Code:
316
+ #
317
+ # [Orange(isTasty=true)]
318
+ # public function eatOranges():void {
319
+ # // do something
320
+ # }
321
+ #
322
+ add_param :keep_as3_metadata, Strings
323
+
324
+ ##
325
+ # Determines whether to keep the generated ActionScript class files.
326
+ #
327
+ # The generated class files include stubs and classes that are generated by the compiler and used to build the SWF file.
328
+ #
329
+ # The default location of the files is the /generated subdirectory, which is directly below the target MXML file. If the /generated directory does not exist, the compiler creates one.
330
+ #
331
+ # The default names of the primary generated class files are filename-generated.as and filename-interface.as.
332
+ #
333
+ # The default value is false.\nThis is an advanced option.
334
+ #
335
+ add_param :keep_generated_actionscript, Boolean
336
+
337
+ ##
338
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380).
339
+ #
340
+ add_param :language, String
341
+
342
+ ##
343
+ # Enables ABC bytecode lazy initialization.
344
+ #
345
+ # The default value is false.
346
+ #
347
+ # This is an advanced option.
348
+ #
349
+ add_param :lazy_init, Boolean
350
+
351
+
352
+ ##
353
+ # <product> <serial-number>
354
+ #
355
+ # Specifies a product and a serial number. (repeatable)
356
+ #
357
+ # This is an advanced option.
358
+ #
359
+ add_param :license, String
360
+
361
+ ##
362
+ # Links SWC files to the resulting application SWF file. The compiler only links in those classes for the SWC file that are required.
363
+ #
364
+ # The default value of the library-path option includes all SWC files in the libs directory and the current locale. These are required.
365
+ #
366
+ # To point to individual classes or packages rather than entire SWC files, use the source-path option.
367
+ #
368
+ # If you set the value of the library_path using the '=' operator, you must also explicitly add the framework.swc and
369
+ # locale SWC files. Your new entry is not appended to the library-path but replaces it.
370
+ #
371
+ # mxmlc 'bin/SomeProject.swf' do |t|
372
+ # t.input = 'src/SomeProject.as'
373
+ # t.library_path = ['lib/SomeLib.swc']
374
+ # end
375
+ #
376
+ # You can use the << operator to append the new argument to the list of existing SWC files.
377
+ #
378
+ # mxmlc 'bin/SomeProject.swf' do |t|
379
+ # t.input = 'src/SomeProject.as'
380
+ # t.library_path << 'lib/SomeLib.swc'
381
+ # end
382
+ #
383
+ # In a configuration file, you can set the append attribute of the library-path tag to true to indicate that the values should be appended to the library path rather than replace it.
384
+ #
385
+ add_param :library_path, Files
386
+
387
+ ##
388
+ # Alias to library_path
389
+ #
390
+ add_param_alias :l, :library_path
391
+
392
+ ##
393
+ # Prints linking information to the specified output file.
394
+ # This file is an XML file that contains
395
+ #
396
+ # <def>, <pre>, and <ext>
397
+ #
398
+ # symbols showing linker dependencies in the final SWF file.
399
+ #
400
+ # The file format output by this command can be used to write a file for input to the load-externs option.
401
+ #
402
+ # For more information on the report, see Examining linker dependencies (http://livedocs.adobe.com/flex/2/docs/00001394.html#211202).
403
+ #
404
+ # This is an advanced option.
405
+ #
406
+ add_param :link_report, File
407
+
408
+ ##
409
+ # Specifies the location of the configuration file that defines compiler options.
410
+ #
411
+ # If you specify a configuration file, you can override individual options by setting them on the command line.
412
+ #
413
+ # All relative paths in the configuration file are relative to the location of the configuration file itself.
414
+ #
415
+ # Use the += operator to chain this configuration file to other configuration files.
416
+ #
417
+ # For more information on using configuration files to provide options to the command-line compilers, see About configuration files (http://livedocs.adobe.com/flex/2/docs/00001490.html#138195).
418
+ #
419
+ add_param :load_config, Files
420
+
421
+ ##
422
+ # Specifies the location of an XML file that contains
423
+ #
424
+ # <def>, <pre>, and <ext>
425
+ #
426
+ # symbols to omit from linking when compiling a SWF file.
427
+ #
428
+ # The XML file uses the same syntax as the one produced by the link-report option.
429
+ #
430
+ # For more information on the report, see Examining linker dependencies (http://livedocs.adobe.com/flex/2/docs/00001394.html#211202).
431
+ #
432
+ # This option provides compile-time link checking for external components that are dynamically linked.
433
+ #
434
+ # For more information about dynamic linking, see About linking (http://livedocs.adobe.com/flex/2/docs/00001521.html#205852).
435
+ #
436
+ # This is an advanced option.
437
+ #
438
+ add_param :load_externs, File
439
+
440
+ ##
441
+ # Specifies the locale that should be packaged in the SWF file (for example, en_EN).
442
+ #
443
+ # You run the mxmlc compiler multiple times to create SWF files for more than one locale,
444
+ # with only the locale option changing.
445
+ #
446
+ # You must also include the parent directory of the individual locale directories,
447
+ # plus the token {locale}, in the source-path; for example:
448
+ #
449
+ # mxmlc -locale en_EN -source-path locale/{locale} -file-specs MainApp.mxml
450
+ #
451
+ # For more information, see Localizing Flex Applicationsin (http://livedocs.adobe.com/flex/2/docs/00000898.html#129288) Flex 2 Developer's Guide.
452
+ #
453
+ add_param :locale, String
454
+
455
+ ##
456
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380).
457
+ #
458
+ add_param :localized_description, String
459
+
460
+ ##
461
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380)."
462
+ #
463
+ add_param :localized_title, String
464
+
465
+ ##
466
+ # Specifies a namespace for the MXML file. You must include a URI and the location of the manifest file that defines the contents of this namespace. This path is relative to the MXML file.
467
+ #
468
+ # For more information about manifest files, see About manifest files (http://livedocs.adobe.com/flex/2/docs/00001519.html#134676).
469
+ #
470
+ add_param :namespaces_namespace, String
471
+
472
+ ##
473
+ # Enables the ActionScript optimizer. This optimizer reduces file size and increases performance by optimizing the SWF file's bytecode.
474
+ #
475
+ # The default value is false.
476
+ #
477
+ add_param :optimize, Boolean
478
+
479
+ ##
480
+ # Specifies the output path and filename for the resulting file. If you omit this option, the compiler saves the SWF file to the directory where the target file is located.
481
+ #
482
+ # The default SWF filename matches the target filename, but with a SWF file extension.
483
+ #
484
+ # If you use a relative path to define the filename, it is always relative to the current working directory, not the target MXML application root.
485
+ #
486
+ # The compiler creates extra directories based on the specified filename if those directories are not present.
487
+ #
488
+ # When using this option with the component compiler, the output is a SWC file rather than a SWF file.
489
+ #
490
+ add_param :output, File, { :file_task_name => true }
491
+
492
+ ##
493
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380).
494
+ #
495
+ add_param :publisher, String
496
+
497
+ ##
498
+ # XML text to store in the SWF metadata (overrides metadata.* configuration) (advanced)
499
+ #
500
+ add_param :raw_metadata, String
501
+
502
+ ##
503
+ # Prints a list of resource bundles to input to the compc compiler to create a resource bundle SWC file. The filename argument is the name of the file that contains the list of bundles.
504
+ #
505
+ # For more information, see Localizing Flex Applications (http://livedocs.adobe.com/flex/2/docs/00000898.html#129288) in Flex 2 Developer's Guide.
506
+ #
507
+ add_param :resource_bundle_list, File
508
+
509
+ ##
510
+ # Specifies a list of run-time shared libraries (RSLs) to use for this application. RSLs are dynamically-linked at run time.
511
+ #
512
+ # You specify the location of the SWF file relative to the deployment location of the application. For example, if you store a file named library.swf file in the web_root/libraries directory on the web server, and the application in the web root, you specify libraries/library.swf.
513
+ #
514
+ # For more information about RSLs, see Using Runtime Shared Libraries. (http://livedocs.adobe.com/flex/2/docs/00001520.html#168690)
515
+ #
516
+ add_param :runtime_shared_libraries, Strings
517
+
518
+ ##
519
+ # Alias for runtime_shared_libraries
520
+ #
521
+ add_param_alias :rsl, :runtime_shared_libraries
522
+
523
+ ##
524
+ # [path-element] [rsl-url] [policy-file-url] [rsl-url] [policy-file-url]
525
+ # alias -rslp
526
+ # (repeatable)
527
+ add_param :runtime_shared_library_path, Strings
528
+
529
+ ##
530
+ # Alias for runtime_shared_library_path
531
+ #
532
+ add_param_alias :rslp, :runtime_shared_library_path
533
+
534
+ ##
535
+ # Specifies the location of the services-config.xml file. This file is used by Flex Data Services.
536
+ #
537
+ add_param :services, File
538
+
539
+ ##
540
+ # Shows warnings for ActionScript classes.
541
+ #
542
+ # The default value is true.
543
+ #
544
+ # For more information about viewing warnings and errors, see Viewing warnings and errors (http://livedocs.adobe.com/flex/2/docs/00001517.html#182413).
545
+ #
546
+ add_param :show_actionscript_warnings, Boolean, { :default => true, :show_on_false => true }
547
+
548
+ ##
549
+ # Shows a warning when Flash Player cannot detect changes to a bound property.
550
+ #
551
+ # The default value is true.
552
+ #
553
+ # For more information about compiler warnings, see Using SWC files (http://livedocs.adobe.com/flex/2/docs/00001505.html#158337).
554
+ #
555
+ add_param :show_binding_warnings, Boolean, { :default => true, :show_on_false => true }
556
+
557
+ ##
558
+ # Shows deprecation warnings for Flex components. To see warnings for ActionScript classes, use the show-actionscript-warnings option.
559
+ #
560
+ # The default value is true.
561
+ #
562
+ # For more information about viewing warnings and errors, see Viewing warnings and errors.
563
+ #
564
+ add_param :show_deprecation_warnings, Boolean, { :default => true, :show_on_false => true }
565
+
566
+ ##
567
+ # Adds directories or files to the source path. The Flex compiler searches directories in the source path for MXML or AS source files that are used in your Flex applications and includes those that are required at compile time.
568
+ #
569
+ # You can use wildcards to include all files and subdirectories of a directory.
570
+ #
571
+ # To link an entire library SWC file and not individual classes or directories, use the library-path option.
572
+ #
573
+ # The source path is also used as the search path for the component compiler's include-classes and include-resource-bundles options.
574
+ #
575
+ # You can also use the += operator to append the new argument to the list of existing source path entries.
576
+ #
577
+ add_param :source_path, Paths
578
+
579
+ add_param_alias :sp, :source_path
580
+
581
+ ##
582
+ # Statically link the libraries specified by the -runtime-shared-libraries-path option.
583
+ #
584
+ # alias -static-rsls
585
+ #
586
+ add_param :static_link_runtime_shared_libraries, Boolean
587
+
588
+ ##
589
+ # Alias for static_link_runtime_shared_libraries
590
+ #
591
+ add_param_alias :static_rsls, :static_link_runtime_shared_libraries
592
+
593
+ ##
594
+ # Prints undefined property and function calls; also performs compile-time type checking on assignments and options supplied to method calls.
595
+ #
596
+ # The default value is true.
597
+ #
598
+ # For more information about viewing warnings and errors, see Viewing warnings and errors (http://livedocs.adobe.com/flex/2/docs/00001517.html#182413).
599
+ #
600
+ add_param :strict, Boolean, { :default => true, :show_on_false => true }
601
+
602
+ ##
603
+ # Specifies the version of the player the application is targeting.
604
+ #
605
+ # Features requiring a later version will not be compiled into the application. The minimum value supported is "9.0.0".
606
+ #
607
+ add_param :target_player, String
608
+
609
+ ##
610
+ # Specifies a list of theme files to use with this application. Theme files can be SWC files with CSS files inside them or CSS files.
611
+ #
612
+ # For information on compiling a SWC theme file, see Using Styles and Themes (http://livedocs.adobe.com/flex/2/docs/00000751.html#241755) in Flex 2 Developer's Guide.
613
+ #
614
+ add_param :theme, Files
615
+
616
+ ##
617
+ # Sets metadata in the resulting SWF file. For more information, see Adding metadata to SWF files (http://livedocs.adobe.com/flex/2/docs/00001502.html#145380).
618
+ #
619
+ add_param :title, String
620
+
621
+ ##
622
+ # Specifies that the current application uses network services.
623
+ #
624
+ # The default value is true.
625
+ #
626
+ # When the use-network property is set to false, the application can access the local filesystem (for example, use the XML.load() method with file: URLs) but not network services. In most circumstances, the value of this property should be true.
627
+ #
628
+ # For more information about the use-network property, see Applying Flex Security (http://livedocs.adobe.com/flex/2/docs/00001328.html#137544).
629
+ #
630
+ add_param :use_network, Boolean, { :default => true, :show_on_false => true }
631
+
632
+ ##
633
+ # Generates source code that includes line numbers. When a run-time error occurs, the stacktrace shows these line numbers.
634
+ #
635
+ # Enabling this option generates larger SWF files.\nThe default value is false.
636
+ #
637
+ add_param :verbose_stacktraces, Boolean
638
+
639
+ ##
640
+ # Verifies the libraries loaded at runtime are the correct ones.
641
+ #
642
+ add_param :verify_digests, Boolean
643
+
644
+ ##
645
+ # Enables specified warnings. For more information, see Viewing warnings and errors (http://livedocs.adobe.com/flex/2/docs/00001517.html#182413).
646
+ #
647
+ add_param :warn_warning_type, Boolean
648
+
649
+ ##
650
+ # Enables all warnings. Set to false to disable all warnings. This option overrides the warn-warning_type options.
651
+ #
652
+ # The default value is true.
653
+ #
654
+ add_param :warnings, Boolean
655
+
656
+ ##
657
+ # Main source file to send compiler"
658
+ # This must be the last item in this list
659
+ add_param :input, File, { :required => true, :hidden_name => true }
660
+
661
+ set :default_prefix, '-'
662
+
663
+ ##
664
+ # The default gem name is sprout-flex3sdk
665
+ #
666
+ set :pkg_name, 'flex3sdk'
667
+
668
+ ##
669
+ # The default gem version
670
+ #
671
+ set :pkg_version, '>= 3.5.pre'
672
+
673
+ ##
674
+ # The default executable target
675
+ #
676
+ set :executable, :mxmlc
677
+
678
+ end
679
+ end
680
+
681
+ =begin
682
+ def define # :nodoc:
683
+ super
684
+
685
+ if(!output)
686
+ if(name.match(/.swf/) || name.match(/swc/))
687
+ self.output = name
688
+ end
689
+ end
690
+
691
+ if(input && !input.match(/.css/) && File.exists?(input))
692
+ source_path << File.dirname(input)
693
+ end
694
+
695
+ if(include_path)
696
+ include_path.each do |path|
697
+ process_include_path(path) if(File.directory?(path))
698
+ end
699
+ end
700
+
701
+ self.include_path = []
702
+
703
+ if(link_report)
704
+ CLEAN.add(link_report)
705
+ end
706
+
707
+ source_path.uniq!
708
+ param_hash['source_path'].value = clean_nested_source_paths(source_path)
709
+
710
+ CLEAN.add(output)
711
+ if(incremental)
712
+ CLEAN.add(FileList['**/**/*.cache'])
713
+ end
714
+
715
+ self
716
+ end
717
+
718
+ protected
719
+
720
+ def process_include_path(path)
721
+ symbols = []
722
+ FileList["#{path}/**/*[.as|.mxml]"].each do |file|
723
+ next if File.directory?(file)
724
+ file.gsub!(path, '')
725
+ file.gsub!(/^\//, '')
726
+ file.gsub!('/', '.')
727
+ file.gsub!(/.as$/, '')
728
+ file.gsub!(/.mxml$/, '')
729
+ file.gsub!(/.css$/, '')
730
+ symbols << file
731
+ end
732
+
733
+ symbols.each do |symbol|
734
+ self.includes << symbol
735
+ end
736
+ end
737
+
738
+ def clean_nested_source_paths(paths)
739
+ results = []
740
+ paths.each do |path|
741
+ # TODO: This should only happen if: allow_source_path_overlap != true
742
+ if(check_nested_source_path(results, path))
743
+ results << path
744
+ end
745
+ end
746
+ return results
747
+ end
748
+
749
+ def check_nested_source_path(array, path)
750
+ array.each_index do |index|
751
+ item = array[index]
752
+ if(item =~ /^#{path}/)
753
+ array.slice!(index, 1)
754
+ elsif(path =~ /^#{item}/)
755
+ return false
756
+ end
757
+ end
758
+ return true
759
+ end
760
+
761
+ # Use the swc path if possible
762
+ # Otherwise add to source
763
+ def resolve_library(library_task)
764
+ #TODO: Add support for libraries that don't get
765
+ # copied into the project
766
+ path = library_task.project_path
767
+ if(path.match(/.swc$/))
768
+ library_path << library_task.project_path
769
+ else
770
+ source_path << library_task.project_path
771
+ end
772
+ end
773
+
774
+ def execute_with_fcsh(command)
775
+ begin
776
+ display_preprocess_message
777
+ puts FCSHSocket.execute("mxmlc #{command}")
778
+ rescue FCSHError => fcsh_error
779
+ raise fcsh_error
780
+ rescue StandardError => std_error
781
+ # TODO: Capture a more concrete error here...
782
+ raise MXMLCError.new("[ERROR] There was a problem connecting to the Flex Compiler SHell, run 'rake fcsh:start' in another terminal.")
783
+ end
784
+ end
785
+
786
+ def execute(*args)
787
+ begin
788
+ start = Time.now.to_i
789
+ if(@use_fcsh)
790
+ execute_with_fcsh(to_shell)
791
+ else
792
+ super
793
+ end
794
+ Log.puts "mxmlc finished compiling #{name} in #{Time.now.to_i - start} seconds"
795
+ rescue ExecutionError => e
796
+ if(e.message.index('Warning:'))
797
+ # MXMLC sends warnings to stderr....
798
+ Log.puts(e.message.gsub('[ERROR]', '[WARNING]'))
799
+ else
800
+ raise e
801
+ end
802
+ end
803
+ end
804
+
805
+ end
806
+ end
807
+
808
+ # Helper method for definining and accessing MXMLC instances in a rakefile
809
+ def mxmlc(args, &block)
810
+ AS3::MXMLC.define_task(args, &block)
811
+ end
812
+
813
+ =end
814
+
815
+ # TODO: Assign mxmlc.output = args || args.first_key
816
+ def mxmlc args, &block
817
+ mxmlc_tool = AS3::MXMLC.new
818
+ mxmlc_tool.to_rake(args, &block)
819
+ mxmlc_tool
820
+ end
821
+