semillagen 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +27 -0
- data/bin/semillagen +65 -0
- data/default_templates/class/default/classTemplate.as.tpl +22 -0
- data/default_templates/class/default/info.semilla +8 -0
- data/default_templates/class/default/testClassTemplate.as.tpl +30 -0
- data/default_templates/project/default/Gemfile +5 -0
- data/default_templates/project/default/Gemfile.lock +24 -0
- data/default_templates/project/default/MagicBox.as3proj +96 -0
- data/default_templates/project/default/lib/flexunit4/FlexUnit1Lib.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8-javadoc.jar +0 -0
- data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8-sources.jar +0 -0
- data/default_templates/project/default/lib/flexunit4/flexUnitTasks-4.1.0-8.jar +0 -0
- data/default_templates/project/default/lib/flexunit4/flexunit-4.1.0-8-as3_4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/fluint-extensions-4.1.0-8-4.1.0.16076.swc +0 -0
- data/default_templates/project/default/lib/flexunit4/hamcrest-as3-flex-1.1.3.swc +0 -0
- data/default_templates/project/default/rakefile.rb +128 -0
- data/default_templates/project/default/src/MagicBox.as +104 -0
- data/default_templates/project/default/src/PlainButton.as +72 -0
- data/default_templates/project/default/src/transforms/LeetTransform.as +40 -0
- data/default_templates/project/default/src/transforms/LowerCaseTransform.as +22 -0
- data/default_templates/project/default/src/transforms/ReverseTransform.as +22 -0
- data/default_templates/project/default/src/transforms/SplitTransform.as +22 -0
- data/default_templates/project/default/src/transforms/UpperCaseTransform.as +22 -0
- data/default_templates/project/default/test-src/TestRunner.template +66 -0
- data/default_templates/project/default/test-src/TextFieldListener.as +66 -0
- data/default_templates/project/default/test-src/listeners/SemillaCIListener.as +389 -0
- data/default_templates/project/default/test-src/listeners/TraceListener.as +79 -0
- data/default_templates/project/default/test-src/transforms/LeetTransformTest.as +45 -0
- data/default_templates/project/default/test-src/transforms/LowerCaseTransformTest.as +44 -0
- data/default_templates/project/default/test-src/transforms/ReverseTransformTest.as +31 -0
- data/default_templates/project/default/test-src/transforms/SplitTransformTest.as +37 -0
- data/default_templates/project/default/test-src/transforms/UpperCaseTransformTest.as +45 -0
- data/doc/SemillaGen/TemplateItem.html +340 -0
- data/doc/SemillaGen.html +916 -0
- data/doc/_index.html +112 -0
- data/doc/class_list.html +47 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +55 -0
- data/doc/css/style.css +322 -0
- data/doc/file_list.html +46 -0
- data/doc/frames.html +13 -0
- data/doc/index.html +112 -0
- data/doc/js/app.js +205 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +16 -0
- data/doc/method_list.html +110 -0
- data/doc/top-level-namespace.html +105 -0
- data/lib/semillagen/generator.rb +248 -0
- data/lib/semillagen/utils.rb +40 -0
- data/lib/semillagen/version.rb +3 -0
- data/lib/semillagen.rb +33 -0
- data/rakefile.rb +39 -0
- data/semillagen.gemspec +76 -0
- metadata +136 -0
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# SemillaGen (Semilla Generator) Gem #
|
2
|
+
|
3
|
+
This gem helps creating the base code for projects in ActionScript. The gem comes with some default templates used for Project or Class/TestCase generation but you can also create your own custom templates for either Projects or Classes.
|
4
|
+
|
5
|
+
## Install ##
|
6
|
+
|
7
|
+
Pending
|
8
|
+
|
9
|
+
|
10
|
+
## Usage ##
|
11
|
+
|
12
|
+
Generating a new project with the default template.
|
13
|
+
|
14
|
+
$ cd ~/myprojects
|
15
|
+
|
16
|
+
$ semillagen project MyFancyApp
|
17
|
+
|
18
|
+
Generating a new class and test case with the default template.
|
19
|
+
|
20
|
+
$ semillagen class com.semilla.TimeMachine
|
21
|
+
Template found at: ./default_templates/class/default
|
22
|
+
|
23
|
+
Generating files for: com.semilla.TimeMachine
|
24
|
+
=> src/com/semilla/TimeMachine.as
|
25
|
+
=> test-src/com/semilla/TestTimeMachine.as
|
26
|
+
|
27
|
+
|
data/bin/semillagen
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# -- TEMP
|
4
|
+
#Setup the gem loading path for testing the code without installing it.
|
5
|
+
#This should be removed when the gem is properly installed.
|
6
|
+
#$LOAD_PATH.unshift( File.expand_path('../lib', File.dirname(__FILE__)) )
|
7
|
+
# -- TEMP
|
8
|
+
|
9
|
+
require 'optparse'
|
10
|
+
require 'semillagen'
|
11
|
+
require 'pp'
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
options = {}
|
16
|
+
parser = OptionParser.new do |opts|
|
17
|
+
|
18
|
+
opts.banner = 'Usage: semillagen project|class NAME'
|
19
|
+
|
20
|
+
#Project option
|
21
|
+
opts.on("--project FILE", "Project name.") do |n|
|
22
|
+
options[:project] = n
|
23
|
+
end
|
24
|
+
|
25
|
+
opts.on("--class FILE", "Class name.") do |n|
|
26
|
+
options[:class] = n
|
27
|
+
end
|
28
|
+
|
29
|
+
options[:template] = :default
|
30
|
+
opts.on('-t', '--template TEMPLATENAME', 'Template name.') do |t|
|
31
|
+
options[:template] = t
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
#Expand keywords, to convert them to the following format:
|
38
|
+
# 'keyword' => '--keyword'
|
39
|
+
keywords = %w{project class}
|
40
|
+
ARGV.map! { |element|
|
41
|
+
keywords.include?(element) ? "--#{element}" : element
|
42
|
+
}
|
43
|
+
|
44
|
+
#pp ARGV
|
45
|
+
|
46
|
+
parser.parse!
|
47
|
+
|
48
|
+
#----------------------------------------------------
|
49
|
+
|
50
|
+
#Generate our files!
|
51
|
+
is_project = !options[:project].nil?
|
52
|
+
is_class = !options[:class].nil?
|
53
|
+
|
54
|
+
if is_project and is_class
|
55
|
+
puts "Only one item please."
|
56
|
+
elsif is_class
|
57
|
+
#Generate a class in the current dir
|
58
|
+
SemillaGen::generate(:class, options[:template], options[:class])
|
59
|
+
elsif is_project
|
60
|
+
#Generate a project under the current dir
|
61
|
+
SemillaGen::generate(:project, options[:template], options[:project])
|
62
|
+
else
|
63
|
+
puts "No item specified."
|
64
|
+
end
|
65
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
package @@PACKAGE@@
|
2
|
+
{
|
3
|
+
import org.flexunit.Assert;
|
4
|
+
|
5
|
+
/**
|
6
|
+
* ...
|
7
|
+
* @author @@AUTHOR@@
|
8
|
+
*/
|
9
|
+
public class @@NAME@@Test
|
10
|
+
{
|
11
|
+
|
12
|
+
[Test]
|
13
|
+
public function myTest1():void
|
14
|
+
{
|
15
|
+
//Test something here
|
16
|
+
Assert.assertEquals(1, 1);
|
17
|
+
}
|
18
|
+
|
19
|
+
[Test]
|
20
|
+
public function myTest2():void
|
21
|
+
{
|
22
|
+
//Test something else here
|
23
|
+
Assert.assertTrue(true);
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
}
|
29
|
+
|
30
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
archive-tar-minitar (0.5.2)
|
5
|
+
flashsdk (1.1.36.pre)
|
6
|
+
sprout (>= 1.1.18.pre)
|
7
|
+
open4 (1.3.0)
|
8
|
+
rake (0.9.2.2)
|
9
|
+
rubyzip (0.9.4)
|
10
|
+
semilla (0.0.5)
|
11
|
+
flashsdk (~> 1.1.0.pre)
|
12
|
+
sprout (1.1.18.pre)
|
13
|
+
archive-tar-minitar (= 0.5.2)
|
14
|
+
bundler (>= 0.9.19)
|
15
|
+
open4 (>= 0.9.6)
|
16
|
+
rake (>= 0.9.2)
|
17
|
+
rubyzip (= 0.9.4)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
flashsdk (>= 1.1.0.pre)
|
24
|
+
semilla (~> 0.0.5)
|
@@ -0,0 +1,96 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<project version="2">
|
3
|
+
<!-- Output SWF options -->
|
4
|
+
<output>
|
5
|
+
<movie outputType="Application" />
|
6
|
+
<movie input="" />
|
7
|
+
<movie path="bin\MagicBox.swf" />
|
8
|
+
<movie fps="30" />
|
9
|
+
<movie width="800" />
|
10
|
+
<movie height="600" />
|
11
|
+
<movie version="10" />
|
12
|
+
<movie minorVersion="0" />
|
13
|
+
<movie platform="Flash Player" />
|
14
|
+
<movie background="#FFFFFF" />
|
15
|
+
</output>
|
16
|
+
<!-- Other classes to be compiled into your SWF -->
|
17
|
+
<classpaths>
|
18
|
+
<class path="src" />
|
19
|
+
<class path="test-src" />
|
20
|
+
</classpaths>
|
21
|
+
<!-- Build options -->
|
22
|
+
<build>
|
23
|
+
<option accessible="False" />
|
24
|
+
<option allowSourcePathOverlap="False" />
|
25
|
+
<option benchmark="False" />
|
26
|
+
<option es="False" />
|
27
|
+
<option locale="" />
|
28
|
+
<option loadConfig="" />
|
29
|
+
<option optimize="True" />
|
30
|
+
<option omitTraces="True" />
|
31
|
+
<option showActionScriptWarnings="True" />
|
32
|
+
<option showBindingWarnings="True" />
|
33
|
+
<option showInvalidCSS="True" />
|
34
|
+
<option showDeprecationWarnings="True" />
|
35
|
+
<option showUnusedTypeSelectorWarnings="True" />
|
36
|
+
<option strict="True" />
|
37
|
+
<option useNetwork="True" />
|
38
|
+
<option useResourceBundleMetadata="True" />
|
39
|
+
<option warnings="True" />
|
40
|
+
<option verboseStackTraces="False" />
|
41
|
+
<option linkReport="" />
|
42
|
+
<option loadExterns="" />
|
43
|
+
<option staticLinkRSL="True" />
|
44
|
+
<option additional="" />
|
45
|
+
<option compilerConstants="" />
|
46
|
+
<option minorVersion="" />
|
47
|
+
</build>
|
48
|
+
<!-- SWC Include Libraries -->
|
49
|
+
<includeLibraries>
|
50
|
+
<!-- example: <element path="..." /> -->
|
51
|
+
</includeLibraries>
|
52
|
+
<!-- SWC Libraries -->
|
53
|
+
<libraryPaths>
|
54
|
+
<element path="lib\flexunit4\FlexUnit1Lib.swc" />
|
55
|
+
<element path="lib\flexunit4\flexunit-4.1.0-8-as3_4.1.0.16076.swc" />
|
56
|
+
<element path="lib\flexunit4\flexunit-cilistener-4.1.0-8-4.1.0.16076.swc" />
|
57
|
+
<element path="lib\flexunit4\flexunit-uilistener-4.1.0-8-4.1.0.16076.swc" />
|
58
|
+
<element path="lib\flexunit4\fluint-extensions-4.1.0-8-4.1.0.16076.swc" />
|
59
|
+
<element path="lib\flexunit4\hamcrest-as3-flex-1.1.3.swc" />
|
60
|
+
</libraryPaths>
|
61
|
+
<!-- External Libraries -->
|
62
|
+
<externalLibraryPaths>
|
63
|
+
<!-- example: <element path="..." /> -->
|
64
|
+
</externalLibraryPaths>
|
65
|
+
<!-- Runtime Shared Libraries -->
|
66
|
+
<rslPaths>
|
67
|
+
<!-- example: <element path="..." /> -->
|
68
|
+
</rslPaths>
|
69
|
+
<!-- Intrinsic Libraries -->
|
70
|
+
<intrinsics>
|
71
|
+
<!-- example: <element path="..." /> -->
|
72
|
+
</intrinsics>
|
73
|
+
<!-- Assets to embed into the output SWF -->
|
74
|
+
<library>
|
75
|
+
<!-- example: <asset path="..." id="..." update="..." glyphs="..." mode="..." place="..." sharepoint="..." /> -->
|
76
|
+
</library>
|
77
|
+
<!-- Class files to compile (other referenced classes will automatically be included) -->
|
78
|
+
<compileTargets>
|
79
|
+
<compile path="src\MagicBox.as" />
|
80
|
+
</compileTargets>
|
81
|
+
<!-- Paths to exclude from the Project Explorer tree -->
|
82
|
+
<hiddenPaths>
|
83
|
+
<!-- example: <hidden path="..." /> -->
|
84
|
+
</hiddenPaths>
|
85
|
+
<!-- Executed before build -->
|
86
|
+
<preBuildCommand />
|
87
|
+
<!-- Executed after build -->
|
88
|
+
<postBuildCommand alwaysRun="False" />
|
89
|
+
<!-- Other project options -->
|
90
|
+
<options>
|
91
|
+
<option showHiddenPaths="False" />
|
92
|
+
<option testMovie="Default" />
|
93
|
+
</options>
|
94
|
+
<!-- Plugin storage -->
|
95
|
+
<storage />
|
96
|
+
</project>
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/default_templates/project/default/lib/flexunit4/flexunit-cilistener-4.1.0-8-4.1.0.16076.swc
ADDED
Binary file
|
data/default_templates/project/default/lib/flexunit4/flexunit-uilistener-4.1.0-8-4.1.0.16076.swc
ADDED
Binary file
|
data/default_templates/project/default/lib/flexunit4/fluint-extensions-4.1.0-8-4.1.0.16076.swc
ADDED
Binary file
|
@@ -0,0 +1,128 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'rubygems'
|
3
|
+
require 'bundler'
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rake/clean'
|
6
|
+
require 'flashsdk'
|
7
|
+
require 'semilla'
|
8
|
+
|
9
|
+
|
10
|
+
##########
|
11
|
+
# Project name
|
12
|
+
# This is the name used in generated binaries, and other files.
|
13
|
+
# Also the name of the main class.
|
14
|
+
PROJECT_NAME = "MagicBox"
|
15
|
+
##########
|
16
|
+
|
17
|
+
#Define some names
|
18
|
+
DEBUG_BIN = "bin/#{PROJECT_NAME}-debug.swf"
|
19
|
+
RELEASE_BIN = "bin/#{PROJECT_NAME}-release.swf"
|
20
|
+
MAIN_AS = "src/#{PROJECT_NAME}.as"
|
21
|
+
TEST_AS = "test-src/TestRunner.as"
|
22
|
+
TEST_BIN = "bin/#{PROJECT_NAME}-flexunit.swf"
|
23
|
+
REPORT_PATH = "test-report"
|
24
|
+
TEST_PORT = 1026
|
25
|
+
|
26
|
+
#Files to remove on CLEAN.
|
27
|
+
CLEAN << FileList["bin/*.swf"] #Binaries
|
28
|
+
CLEAN << FileList["#{REPORT_PATH}/*"] #Test results
|
29
|
+
CLEAN << FileList[TEST_AS] #Auto-generated Test Script
|
30
|
+
|
31
|
+
##Create directory tasks
|
32
|
+
directory "bin"
|
33
|
+
directory REPORT_PATH #Dependency for the test task
|
34
|
+
|
35
|
+
|
36
|
+
# Set some shared config options to the passed compiler.
|
37
|
+
def config_common_options compiler
|
38
|
+
compiler.static_link_runtime_shared_libraries = true
|
39
|
+
compiler.source_path << "src"
|
40
|
+
compiler.library_path << "lib"
|
41
|
+
end
|
42
|
+
|
43
|
+
##############################
|
44
|
+
# Debug
|
45
|
+
|
46
|
+
# Compile the debug swf
|
47
|
+
mxmlc DEBUG_BIN do |t|
|
48
|
+
t.input = MAIN_AS
|
49
|
+
t.debug = true
|
50
|
+
config_common_options t
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Compile a debug version of the project."
|
54
|
+
task :compile => DEBUG_BIN
|
55
|
+
|
56
|
+
desc "Compile and run the debug swf"
|
57
|
+
flashplayer :run => DEBUG_BIN
|
58
|
+
|
59
|
+
##############################
|
60
|
+
# Release
|
61
|
+
|
62
|
+
# Compile the debug swf
|
63
|
+
mxmlc RELEASE_BIN do |t|
|
64
|
+
t.input = MAIN_AS
|
65
|
+
t.debug = false
|
66
|
+
config_common_options t
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "Compile a release version of the project."
|
70
|
+
task :compile_release => RELEASE_BIN
|
71
|
+
|
72
|
+
|
73
|
+
##############################
|
74
|
+
# FLEXUNIT TESTS
|
75
|
+
|
76
|
+
# The list of FlexUnit test cases.
|
77
|
+
test_cases = FileList["test-src/**/*Test.as"]
|
78
|
+
# FileTask: Generate a script that runs all the test cases.
|
79
|
+
Semilla::test_runner TEST_AS, test_cases, TEST_PORT
|
80
|
+
|
81
|
+
desc "Generate the TestRunner script"
|
82
|
+
task :testrunner => TEST_AS
|
83
|
+
|
84
|
+
# Compile the TestRunner
|
85
|
+
mxmlc TEST_BIN => TEST_AS do |t|
|
86
|
+
t.input = TEST_AS
|
87
|
+
t.debug = true
|
88
|
+
config_common_options t
|
89
|
+
t.library_path << "lib/flexunit4"
|
90
|
+
end
|
91
|
+
|
92
|
+
task :compile_flexunit => TEST_BIN
|
93
|
+
|
94
|
+
# Run the Tests.
|
95
|
+
desc "Test with FlexUnit"
|
96
|
+
Semilla::flex_unit :test => [:compile_flexunit, REPORT_PATH] do |t|
|
97
|
+
t.serverPort = TEST_PORT
|
98
|
+
t.swf = TEST_BIN
|
99
|
+
t.reportpath = REPORT_PATH
|
100
|
+
t.timeout = 15 #seconds
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
##############################
|
105
|
+
# SWC
|
106
|
+
|
107
|
+
compc "bin/#{PROJECT_NAME}.swc" do |t|
|
108
|
+
t.input_class = "#{PROJECT_NAME}"
|
109
|
+
config_common_options t
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Compile the SWC file"
|
113
|
+
task :swc => 'bin/#{PROJECT_NAME}.swc'
|
114
|
+
|
115
|
+
##############################
|
116
|
+
# DOC
|
117
|
+
|
118
|
+
desc "Generate documentation at doc/"
|
119
|
+
asdoc 'doc' do |t|
|
120
|
+
t.doc_sources << "src"
|
121
|
+
#t.exclude_sources << "src/#{PROJECT_NAME}Runner.as"
|
122
|
+
end
|
123
|
+
|
124
|
+
##############################
|
125
|
+
# DEFAULT, compile the debug & release versions, run tests.
|
126
|
+
task :default => [:compile, :compile_release, :test]
|
127
|
+
|
128
|
+
|
@@ -0,0 +1,104 @@
|
|
1
|
+
package {
|
2
|
+
import flash.display.Sprite;
|
3
|
+
import flash.events.MouseEvent;
|
4
|
+
import flash.text.*;
|
5
|
+
import transforms.*;
|
6
|
+
|
7
|
+
public class MagicBox extends Sprite {
|
8
|
+
|
9
|
+
private var txt1:TextField;
|
10
|
+
private var txt2:TextField;
|
11
|
+
|
12
|
+
public function MagicBox() {
|
13
|
+
trace(">> MagicBox Started!");
|
14
|
+
|
15
|
+
//Create buttons
|
16
|
+
var btn1:PlainButton = new PlainButton("UpperCase");
|
17
|
+
var btn2:PlainButton = new PlainButton("LowerCase");
|
18
|
+
var btn3:PlainButton = new PlainButton("Reverse");
|
19
|
+
var btn4:PlainButton = new PlainButton("Split");
|
20
|
+
var btn5:PlainButton = new PlainButton("2337");
|
21
|
+
|
22
|
+
//Layout buttons
|
23
|
+
btn1.x = 10; btn1.y = 30;
|
24
|
+
btn2.x = 10; btn2.y = 70;
|
25
|
+
btn3.x = 10; btn3.y = 110;
|
26
|
+
btn4.x = 10; btn4.y = 150;
|
27
|
+
btn5.x = 10; btn5.y = 190;
|
28
|
+
|
29
|
+
//Add to stage
|
30
|
+
addChild(btn1);
|
31
|
+
addChild(btn2);
|
32
|
+
addChild(btn3);
|
33
|
+
addChild(btn4);
|
34
|
+
addChild(btn5);
|
35
|
+
|
36
|
+
//Add handlers
|
37
|
+
btn1.addEventListener(MouseEvent.CLICK, clickHandler);
|
38
|
+
btn2.addEventListener(MouseEvent.CLICK, clickHandler);
|
39
|
+
btn3.addEventListener(MouseEvent.CLICK, clickHandler);
|
40
|
+
btn4.addEventListener(MouseEvent.CLICK, clickHandler);
|
41
|
+
btn5.addEventListener(MouseEvent.CLICK, clickHandler);
|
42
|
+
|
43
|
+
//Create textfields
|
44
|
+
txt1 = new TextField();
|
45
|
+
txt2 = new TextField();
|
46
|
+
|
47
|
+
//Layout textfields
|
48
|
+
txt1.x = 160; txt1.y = 30; txt1.width = 200; txt1.height = 20;
|
49
|
+
txt2.x = 160; txt2.y = 70; txt2.width = 200; txt2.height = 20;
|
50
|
+
|
51
|
+
txt1.border = true; txt1.type = TextFieldType.INPUT;
|
52
|
+
txt2.border = true; txt2.type = TextFieldType.INPUT;
|
53
|
+
|
54
|
+
//Add to stage
|
55
|
+
addChild(txt1);
|
56
|
+
addChild(txt2);
|
57
|
+
}
|
58
|
+
|
59
|
+
private function clickHandler(e:MouseEvent):void
|
60
|
+
{
|
61
|
+
|
62
|
+
if(txt1.text == ""){
|
63
|
+
txt2.text = "";
|
64
|
+
trace("Nothing to convert");
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
|
68
|
+
var button:PlainButton = e.target as PlainButton;
|
69
|
+
switch(button.label)
|
70
|
+
{
|
71
|
+
case "UpperCase":
|
72
|
+
trace("UpperCase transform");
|
73
|
+
var t0:UpperCaseTransform = new UpperCaseTransform();
|
74
|
+
txt2.text = t0.run(txt1.text);
|
75
|
+
break;
|
76
|
+
case "LowerCase":
|
77
|
+
trace("LowerCase transform");
|
78
|
+
var t1:LowerCaseTransform = new LowerCaseTransform();
|
79
|
+
txt2.text = t1.run(txt1.text);
|
80
|
+
break;
|
81
|
+
case "Reverse":
|
82
|
+
trace("Reverse transform");
|
83
|
+
var t2:ReverseTransform = new ReverseTransform();
|
84
|
+
txt2.text = t2.run(txt1.text);
|
85
|
+
break;
|
86
|
+
case "Split":
|
87
|
+
trace("Split transform");
|
88
|
+
var t3:SplitTransform = new SplitTransform();
|
89
|
+
txt2.text = t3.run(txt1.text);
|
90
|
+
break;
|
91
|
+
case "2337":
|
92
|
+
trace("2337 transform");
|
93
|
+
var t4:LeetTransform = new LeetTransform();
|
94
|
+
txt2.text = t4.run(txt1.text);
|
95
|
+
break;
|
96
|
+
default:
|
97
|
+
trace("Unkown button");
|
98
|
+
txt2.text = "";
|
99
|
+
break;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
@@ -0,0 +1,72 @@
|
|
1
|
+
package
|
2
|
+
{
|
3
|
+
import flash.display.Graphics;
|
4
|
+
import flash.display.SimpleButton;
|
5
|
+
import flash.display.Sprite;
|
6
|
+
import flash.filters.DropShadowFilter;
|
7
|
+
import flash.text.TextField;
|
8
|
+
import flash.text.TextFieldAutoSize;
|
9
|
+
import flash.text.TextFormat;
|
10
|
+
|
11
|
+
/**
|
12
|
+
* ...
|
13
|
+
* @author Victor Rosales
|
14
|
+
*/
|
15
|
+
public class PlainButton extends SimpleButton
|
16
|
+
{
|
17
|
+
private var _label:String;
|
18
|
+
|
19
|
+
public function PlainButton(label:String, padding:Number = 10)
|
20
|
+
{
|
21
|
+
_label = label;
|
22
|
+
|
23
|
+
var chromeUp:Sprite = drawButtonChrome(label, padding, 0xCCCCCC);
|
24
|
+
|
25
|
+
var chromeOver:Sprite = drawButtonChrome(label, padding, 0xAAC3E1);
|
26
|
+
|
27
|
+
var chromeDown:Sprite = drawButtonChrome(label, padding, 0xD6E8FF);
|
28
|
+
|
29
|
+
var chromeHitTest:Sprite = drawButtonChrome(label, padding);
|
30
|
+
|
31
|
+
upState = chromeUp;
|
32
|
+
overState = chromeOver;
|
33
|
+
downState = chromeDown;
|
34
|
+
hitTestState = chromeHitTest;
|
35
|
+
|
36
|
+
//var myFilters:Array = new Array();
|
37
|
+
//myFilters.push(new DropShadowFilter(0, 45, 0, 0.25, 10, 10));
|
38
|
+
//filters = myFilters;
|
39
|
+
}
|
40
|
+
|
41
|
+
|
42
|
+
private function drawButtonChrome(label:String = "Button", padding:Number = 10 , color:Number = 0xCCCCCC):Sprite
|
43
|
+
{
|
44
|
+
var text:TextField = new TextField();
|
45
|
+
text.text = label;
|
46
|
+
text.setTextFormat( new TextFormat("Verdana"));
|
47
|
+
text.autoSize = TextFieldAutoSize.LEFT;
|
48
|
+
|
49
|
+
text.x = padding / 2;
|
50
|
+
text.y = padding / 2;
|
51
|
+
|
52
|
+
var chrome:Sprite = new Sprite();
|
53
|
+
var g:Graphics = chrome.graphics;
|
54
|
+
g.lineStyle(1.5, 0x777777);
|
55
|
+
g.beginFill(color);
|
56
|
+
g.drawRoundRect(0, 0, text.width + padding, text.height + padding, 13);
|
57
|
+
//g.drawRect(0, 0, text.width + padding, text.height + padding);
|
58
|
+
g.endFill();
|
59
|
+
|
60
|
+
chrome.addChild(text);
|
61
|
+
|
62
|
+
return chrome;
|
63
|
+
}
|
64
|
+
|
65
|
+
public function get label():String
|
66
|
+
{
|
67
|
+
return _label;
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
|
72
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
package transforms
|
2
|
+
{
|
3
|
+
/**
|
4
|
+
* ...
|
5
|
+
* @author @@AUTHOR@@
|
6
|
+
*/
|
7
|
+
public class LeetTransform
|
8
|
+
{
|
9
|
+
|
10
|
+
public function LeetTransform()
|
11
|
+
{
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
private function replace(data:String, pattern:*, replacement:String):String
|
16
|
+
{
|
17
|
+
var s:String = data;
|
18
|
+
var t:String;
|
19
|
+
while(s != (t = s.replace(pattern, replacement)))
|
20
|
+
s = t;
|
21
|
+
return s;
|
22
|
+
}
|
23
|
+
|
24
|
+
public function run(data:String):String
|
25
|
+
{
|
26
|
+
var r:String = data;
|
27
|
+
|
28
|
+
r = replace(r, /e|E/, "3");
|
29
|
+
r = replace(r, /a|A/, "4");
|
30
|
+
r = replace(r, /o|O/, "0");
|
31
|
+
r = replace(r, /l|L/, "1");
|
32
|
+
r = replace(r, /t|T/, "7");
|
33
|
+
r = replace(r, "h4ck3r", "haxor");
|
34
|
+
|
35
|
+
return r;
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
package transforms
|
2
|
+
{
|
3
|
+
/**
|
4
|
+
* ...
|
5
|
+
* @author @@AUTHOR@@
|
6
|
+
*/
|
7
|
+
public class LowerCaseTransform
|
8
|
+
{
|
9
|
+
|
10
|
+
public function LowerCaseTransform()
|
11
|
+
{
|
12
|
+
|
13
|
+
}
|
14
|
+
|
15
|
+
public function run(data:String):String
|
16
|
+
{
|
17
|
+
return data.toLowerCase();
|
18
|
+
}
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|