bomberstudios-fluby 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.mdown +134 -0
- data/Rakefile +63 -0
- data/lib/fluby.rb +131 -0
- data/lib/templates/ASClass.as +9 -0
- data/lib/templates/README +51 -0
- data/lib/templates/Rakefile +114 -0
- data/lib/templates/generate +17 -0
- data/lib/templates/generators/class +7 -0
- data/lib/templates/generators/delegate +22 -0
- data/lib/templates/generators/xml_loader +24 -0
- data/lib/templates/index.rhtml +16 -0
- data/lib/templates/project.rxml +22 -0
- data/lib/templates/swfobject.js +8 -0
- metadata +16 -3
data/README.mdown
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
# fluby
|
2
|
+
|
3
|
+
A simple command to create an empty ActionScript project for MTASC + SWFMILL + Rake
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
gem install fluby
|
8
|
+
|
9
|
+
Fluby requires the 'mtasc' and 'swfmill' executables somewhere on your path.
|
10
|
+
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
### New project
|
15
|
+
|
16
|
+
To create a new project:
|
17
|
+
|
18
|
+
fluby ProjectName
|
19
|
+
|
20
|
+
|
21
|
+
### Compilation
|
22
|
+
|
23
|
+
To compile your brand new project:
|
24
|
+
|
25
|
+
cd ProjectName
|
26
|
+
rake
|
27
|
+
|
28
|
+
That should generate a 'ProjectName.swf' file on the 'deploy' folder. The SWF file is debug-enabled (i.e: you can see the trace() output if you have a debug Flash Player). If you want to release your project without debug information, run
|
29
|
+
|
30
|
+
rake release
|
31
|
+
|
32
|
+
|
33
|
+
### More Rake tasks
|
34
|
+
|
35
|
+
There are other rake tasks available:
|
36
|
+
|
37
|
+
rake package # Creates a ZIP file containing your SWF file on the 'pkg' folder
|
38
|
+
rake test # Opens a HTML file with your SWF for testing on your default browser (available on Mac only)
|
39
|
+
|
40
|
+
|
41
|
+
### script/generate
|
42
|
+
|
43
|
+
Starting from version 0.6, fluby installs a 'generate' script in the 'scripts' folder that you can use to speed up the creation of new classes.
|
44
|
+
|
45
|
+
Right now there are 3 template types:
|
46
|
+
|
47
|
+
#### **class**
|
48
|
+
|
49
|
+
Use it to create a generic class by running:
|
50
|
+
|
51
|
+
script/generate class your.class.path.ClassName attribute:Type attribute:Type (...)
|
52
|
+
|
53
|
+
For example: if you want to create a "Car" class with attributes "make" and "model" of type String and an attribute "year" of type Number, you'd run:
|
54
|
+
|
55
|
+
script/generate class com.yourdomain.Car make:String model:String year:Number
|
56
|
+
|
57
|
+
This will create a file in com/yourdomain/Car.as with this content:
|
58
|
+
|
59
|
+
class com.yourdomain.Car {
|
60
|
+
var make:String;
|
61
|
+
var model:String;
|
62
|
+
var year:Number;
|
63
|
+
function Car(){
|
64
|
+
// Init class
|
65
|
+
}
|
66
|
+
}
|
67
|
+
|
68
|
+
|
69
|
+
#### **xml_loader**
|
70
|
+
|
71
|
+
Use to create a simple XML loader class by running:
|
72
|
+
|
73
|
+
script/generate xml_loader your.class.path.ClassName
|
74
|
+
|
75
|
+
Example: if you run
|
76
|
+
|
77
|
+
script/generate xml_loader com.bomberstudios.xml.Loader
|
78
|
+
|
79
|
+
you'll get a com/bomberstudios/xml/Loader.as file containing:
|
80
|
+
|
81
|
+
class com.bomberstudios.xml.Loader {
|
82
|
+
var _path:String;
|
83
|
+
var raw_data:XML;
|
84
|
+
function Loader(path:String,callback:Function){
|
85
|
+
_path = path;
|
86
|
+
raw_data = new XML();
|
87
|
+
raw_data.ignoreWhite = true;
|
88
|
+
raw_data.onLoad = callback;
|
89
|
+
}
|
90
|
+
function give_me(node_name){
|
91
|
+
if (raw_data.firstChild.nodeName == node_name) {
|
92
|
+
return raw_data.firstChild;
|
93
|
+
}
|
94
|
+
for(var i=raw_data.firstChild.childNodes.length; i>=0; i--){
|
95
|
+
if(raw_data.firstChild.childNodes[i].nodeName == node_name){
|
96
|
+
return raw_data.firstChild.childNodes[i];
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
public function load(){
|
101
|
+
raw_data.load(_path);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
|
106
|
+
#### **delegate**
|
107
|
+
|
108
|
+
To generate a MTASC-compatible Delegate class, run
|
109
|
+
|
110
|
+
script/generate delegate your.class.path.Delegate
|
111
|
+
|
112
|
+
This will produce a your/class/path/Delegate.as file containing:
|
113
|
+
|
114
|
+
/**
|
115
|
+
*
|
116
|
+
* Delegate Class, MTASC compatible
|
117
|
+
*
|
118
|
+
**/
|
119
|
+
class your.class.path.Delegate {
|
120
|
+
public static function create(scope:Object,method:Function):Function{
|
121
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
122
|
+
var proxyFunc:Function = function():Void{
|
123
|
+
method.apply(scope,arguments.concat(params));
|
124
|
+
}
|
125
|
+
return proxyFunc;
|
126
|
+
}
|
127
|
+
public static function createR(scope:Object,method:Function):Function{
|
128
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
129
|
+
var proxyFunc:Function = function():Void{
|
130
|
+
method.apply(scope,params.concat(arguments));
|
131
|
+
}
|
132
|
+
return proxyFunc;
|
133
|
+
}
|
134
|
+
}
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
##### Requirements
|
2
|
+
|
3
|
+
require 'rake'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/testtask'
|
7
|
+
|
8
|
+
require File.dirname(__FILE__) + '/lib/fluby.rb'
|
9
|
+
|
10
|
+
##### Cleaning
|
11
|
+
CLEAN.include [ 'tmp', 'test/fixtures/*/output/*', 'test/fixtures/*/tmp' ]
|
12
|
+
CLOBBER.include [ 'pkg', '*.gem', 'coverage.data' ]
|
13
|
+
|
14
|
+
desc 'Build gem package'
|
15
|
+
task :gem do
|
16
|
+
system('gem build fluby.gemspec')
|
17
|
+
end
|
18
|
+
|
19
|
+
desc 'Install gem'
|
20
|
+
task :install => :gem do
|
21
|
+
if RUBY_PLATFORM =~ /mswin32/
|
22
|
+
system('cmd.exe /c rake package')
|
23
|
+
system("cmd.exe /c gem install pkg/#{Fluby::NAME}-#{Fluby::VERSION}")
|
24
|
+
else
|
25
|
+
system("sudo gem install pkg/#{Fluby::NAME}-#{Fluby::VERSION}")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'Uninstall gem'
|
30
|
+
task :uninstall do
|
31
|
+
sh %{sudo gem uninstall #{Fluby::NAME}}
|
32
|
+
end
|
33
|
+
|
34
|
+
### Testing
|
35
|
+
Rake::TestTask.new(:test) do |test|
|
36
|
+
test.test_files = Dir['test/test_*.rb']
|
37
|
+
end
|
38
|
+
|
39
|
+
desc 'Test if the gem will build on Github'
|
40
|
+
task :github do
|
41
|
+
require 'yaml'
|
42
|
+
require 'rubygems/specification'
|
43
|
+
data = File.read('fluby.gemspec')
|
44
|
+
spec = nil
|
45
|
+
if data !~ %r{!ruby/object:Gem::Specification}
|
46
|
+
Thread.new { spec = eval("$SAFE = 3\n#{data}") }.join
|
47
|
+
else
|
48
|
+
spec = YAML.load(data)
|
49
|
+
end
|
50
|
+
spec.validate
|
51
|
+
puts spec
|
52
|
+
puts "OK"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc 'Test code coverage using rcov'
|
56
|
+
task :rcov do
|
57
|
+
rm_f "coverage"
|
58
|
+
rm_f "coverage.data"
|
59
|
+
rcov = "rcov --exclude gem --aggregate coverage.data --text-summary -Ilib"
|
60
|
+
sh "#{rcov} --no-html test/*", :verbose => false
|
61
|
+
end
|
62
|
+
|
63
|
+
task :default => [ :github, :test ]
|
data/lib/fluby.rb
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
require "erb"
|
2
|
+
require "fileutils"
|
3
|
+
|
4
|
+
module Fluby
|
5
|
+
NAME = 'fluby'
|
6
|
+
VERSION = '0.6.6'
|
7
|
+
|
8
|
+
COLORS = {
|
9
|
+
:black => "\033[0;30m",
|
10
|
+
:red => "\033[0;31m",
|
11
|
+
:green => "\033[0;32m",
|
12
|
+
:yellow => "\033[0;33m",
|
13
|
+
:blue => "\033[0;34m",
|
14
|
+
:purple => "\033[0;35m",
|
15
|
+
:cyan => "\033[0;36m",
|
16
|
+
:white => "\033[0;37m",
|
17
|
+
:whitebold => "\033[1;37m"
|
18
|
+
}
|
19
|
+
PATH = File.expand_path(__FILE__)
|
20
|
+
|
21
|
+
def self.create_project(name)
|
22
|
+
require "fileutils"
|
23
|
+
require "erb"
|
24
|
+
|
25
|
+
# TODO: Support project creation in subfolders (i.e: fluby test/project)
|
26
|
+
@project_name = name
|
27
|
+
@project_folder = FileUtils.pwd + "/" + @project_name
|
28
|
+
|
29
|
+
puts "\n#{COLORS[:green]}Creating project #{@project_name}"
|
30
|
+
|
31
|
+
# Make folders
|
32
|
+
if File.exist? @project_folder
|
33
|
+
puts "#{COLORS[:red]}Folder #{@project_name} already exists,"
|
34
|
+
puts "#{COLORS[:red]}please choose a different name for your project"
|
35
|
+
raise RuntimeError
|
36
|
+
end
|
37
|
+
FileUtils.mkdir [@project_folder,"#{@project_folder}/deploy","#{@project_folder}/assets","#{@project_folder}/script"]
|
38
|
+
|
39
|
+
# Make files
|
40
|
+
["Rakefile","README"].each do |file|
|
41
|
+
render_template file
|
42
|
+
end
|
43
|
+
|
44
|
+
# Static Templates
|
45
|
+
copy_template "index.rhtml"
|
46
|
+
copy_template "project.rxml", "#{@project_name}.rxml"
|
47
|
+
copy_template "swfobject.js", "assets/swfobject.js"
|
48
|
+
|
49
|
+
# Main Class
|
50
|
+
render_template "ASClass.as", "#{@project_name}.as"
|
51
|
+
|
52
|
+
# script/generate
|
53
|
+
render_template "generate", "script/generate"
|
54
|
+
%x(chmod 755 "#{@project_folder}/script/generate")
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.copy_template source, destination=nil
|
59
|
+
if destination.nil?
|
60
|
+
destination = source
|
61
|
+
end
|
62
|
+
FileUtils.cp "#{File.dirname(__FILE__)}/templates/#{source}", "#{@project_folder}/#{destination}"
|
63
|
+
log "create", "#{@project_name}/#{destination}"
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.render_template source, destination=nil
|
67
|
+
if destination.nil?
|
68
|
+
destination = source
|
69
|
+
end
|
70
|
+
open("#{@project_folder}/#{destination}","w") do |f|
|
71
|
+
f << ERB.new(IO.read("#{File.dirname(__FILE__)}/templates/#{source}")).result(binding)
|
72
|
+
end
|
73
|
+
log "create", "#{@project_name}/#{destination}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.log type, string
|
77
|
+
case type
|
78
|
+
when "alert"
|
79
|
+
puts "\t#{COLORS[:red]}Alert:\t#{string}#{COLORS[:white]}"
|
80
|
+
when "create"
|
81
|
+
puts "\t#{COLORS[:white]}Created:\t#{COLORS[:cyan]}#{string}#{COLORS[:white]}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def self.in_textmate?
|
86
|
+
begin
|
87
|
+
if TextMate
|
88
|
+
return true
|
89
|
+
end
|
90
|
+
rescue
|
91
|
+
return false
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.is_mac?
|
96
|
+
return RUBY_PLATFORM =~ /darwin/
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.has_growl?
|
100
|
+
return is_mac? && !`which "growlnotify"`.empty?
|
101
|
+
end
|
102
|
+
|
103
|
+
# these functions are used by script/generate
|
104
|
+
def self.generate(type, name, options={})
|
105
|
+
target_path = File.dirname(name.split(".").join("/").to_s)
|
106
|
+
target_file = name.split(".").join("/") + ".as".to_s
|
107
|
+
if File.exist?(target_file)
|
108
|
+
log "alert", "File #{target_file} already exists!"
|
109
|
+
raise RuntimeError
|
110
|
+
end
|
111
|
+
FileUtils.mkdir_p target_path unless File.exist? target_path
|
112
|
+
@classpath = target_path.split("/").join(".")
|
113
|
+
@classname = name.split(".").last
|
114
|
+
options = options.map { |i| i = i.split(":") } unless options == {}
|
115
|
+
@opts = options
|
116
|
+
File.open(target_file,"w") do |file|
|
117
|
+
file << ERB.new(File.read("#{template_path}/generators/#{type}")).result(binding)
|
118
|
+
end
|
119
|
+
log "create", "#{target_path}/#{@classname}.as"
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.path
|
123
|
+
File.dirname(PATH)
|
124
|
+
end
|
125
|
+
def self.template_path
|
126
|
+
path + "/templates"
|
127
|
+
end
|
128
|
+
def self.available_templates
|
129
|
+
return Dir["#{template_path}/generators/**"].map { |i| i = File.basename(i) }
|
130
|
+
end
|
131
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
|
2
|
+
<%= @project_name %>
|
3
|
+
<%= "="*@project_name.length %>
|
4
|
+
|
5
|
+
This is the README for the <%= @project_name %> project.
|
6
|
+
|
7
|
+
Compilation
|
8
|
+
-----------
|
9
|
+
<%= @project_name %> has been created using fluby, so compilation is pretty straightforward:
|
10
|
+
|
11
|
+
$ cd <%= @project_name %>
|
12
|
+
$ rake
|
13
|
+
|
14
|
+
There are some additional rake tasks available:
|
15
|
+
<% if RUBY_PLATFORM =~ /mswin32/ %>
|
16
|
+
<%= %x(cmd.exe /c rake -f "#{@project_folder}/Rakefile" -T -s) %>
|
17
|
+
<% else %>
|
18
|
+
<%= %x(rake -f "#{@project_folder}/Rakefile" -T -s) %>
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
Assets
|
22
|
+
------
|
23
|
+
When compiling, fluby imports all assets in the 'assets' directory.
|
24
|
+
|
25
|
+
PNG files are imported as MovieClips, with their name (minus extension) as an ID. Thus, if you have a 'background.png' file, you can use it on your code with:
|
26
|
+
|
27
|
+
var my_clip = attachMovie("background","my_clip_name",1);
|
28
|
+
|
29
|
+
TTF fonts are also imported. If you need to use multiple weights of the same family (i.e: regular, bold, italics...) you should name your fonts like this:
|
30
|
+
|
31
|
+
family_name-font_weight.ttf
|
32
|
+
|
33
|
+
So, if you were to use Arial, you'd use:
|
34
|
+
|
35
|
+
arial-regular.ttf
|
36
|
+
arial-bold.ttf
|
37
|
+
arial-italic.ttf
|
38
|
+
arial-bold_italic.ttf
|
39
|
+
|
40
|
+
Then, in your code, you'd use the fonts like this:
|
41
|
+
|
42
|
+
createTextField("txtest",1,0,0,200,30);
|
43
|
+
txtest.embedFonts = true;
|
44
|
+
var tf = new TextFormat();
|
45
|
+
tf.font = "arial";
|
46
|
+
tf.italic = true;
|
47
|
+
txtest.setNewTextFormat(tf);
|
48
|
+
txtest.text = "This is italics";
|
49
|
+
|
50
|
+
---
|
51
|
+
Created: <%= Time.now.strftime("%Y%m%d") %>
|
@@ -0,0 +1,114 @@
|
|
1
|
+
require "erb"
|
2
|
+
require 'rake/packagetask'
|
3
|
+
|
4
|
+
WIDTH = 725
|
5
|
+
HEIGHT = 480
|
6
|
+
FPS = 31
|
7
|
+
PLAYER = 8
|
8
|
+
BGCOLOR = "#ffffff"
|
9
|
+
APP = "<%= @project_name %>"
|
10
|
+
|
11
|
+
def render_template(file)
|
12
|
+
filename = File.basename(file).split(".")[0]
|
13
|
+
case File.basename(file).split(".")[1]
|
14
|
+
when "rhtml"
|
15
|
+
extension = "html"
|
16
|
+
when "rxml"
|
17
|
+
extension = "xml"
|
18
|
+
end
|
19
|
+
to_file = filename + "." + extension
|
20
|
+
puts "Rendering #{file}"
|
21
|
+
open(to_file,"w") do |f|
|
22
|
+
f << ERB.new(IO.read(file)).result
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
task :assets do
|
27
|
+
Dir.glob(['assets/*.js','assets/*.xml']).each do |file|
|
28
|
+
cp file, "deploy/#{File.basename(file)}", :verbose => true
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
task :compile => [:assets] do
|
33
|
+
if @nodebug
|
34
|
+
puts "Trace disabled"
|
35
|
+
trace = " -trace no"
|
36
|
+
else
|
37
|
+
trace = ""
|
38
|
+
end
|
39
|
+
@start = Time.now
|
40
|
+
["*.rhtml","*.rxml"].each do |list|
|
41
|
+
Dir[list].each do |tpl|
|
42
|
+
render_template(tpl)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
puts %x(swfmill simple #{APP}.xml #{APP}.swf)
|
46
|
+
rm "#{APP}.xml", {:verbose => false}
|
47
|
+
puts %x(mtasc -swf #{APP}.swf -main -mx -version #{PLAYER} #{trace} #{APP}.as)
|
48
|
+
@end = Time.now
|
49
|
+
|
50
|
+
["*.html","*.swf"].each do |list|
|
51
|
+
Dir[list].each do |file|
|
52
|
+
mv file, "deploy/#{file}", {:verbose => false}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
Rake::PackageTask.new(APP, :noversion) do |p|
|
58
|
+
p.need_zip = true
|
59
|
+
p.name = Time.now.strftime("%Y%m%d") + "-" + APP
|
60
|
+
p.package_files.include("README",Dir["deploy/*"])
|
61
|
+
end
|
62
|
+
|
63
|
+
<% if Fluby.has_growl? %>
|
64
|
+
task :notify do
|
65
|
+
msg = "Finished compiling in #{@end - @start}s."
|
66
|
+
if @nodebug
|
67
|
+
msg += "\ntrace() disabled"
|
68
|
+
end
|
69
|
+
%x(growlnotify --name Rake -m '#{msg}' 'Rake')
|
70
|
+
end
|
71
|
+
<% end %>
|
72
|
+
|
73
|
+
task :nodebug do
|
74
|
+
@nodebug = true
|
75
|
+
end
|
76
|
+
|
77
|
+
task :monitor do
|
78
|
+
command = "rake"
|
79
|
+
files = {}
|
80
|
+
|
81
|
+
Dir["*.as","*.rxml","*.rhtml","Rakefile"].each { |file|
|
82
|
+
files[file] = File.mtime(file)
|
83
|
+
}
|
84
|
+
|
85
|
+
loop do
|
86
|
+
sleep 1
|
87
|
+
changed_file, last_changed = files.find { |file, last_changed|
|
88
|
+
File.mtime(file) > last_changed
|
89
|
+
}
|
90
|
+
if changed_file
|
91
|
+
files[changed_file] = File.mtime(changed_file)
|
92
|
+
puts "=> #{changed_file} changed, running #{command}"
|
93
|
+
system(command)
|
94
|
+
puts "=> done"
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
<% if Fluby.is_mac? %>
|
100
|
+
desc "Test the SWF file in your default browser"
|
101
|
+
task :test => [:compile] do
|
102
|
+
%x(open deploy/index.html)
|
103
|
+
end
|
104
|
+
<% end %>
|
105
|
+
|
106
|
+
<% if Fluby.has_growl? %>
|
107
|
+
desc "Build a release version of <%= @project_name %> (with trace() disabled)"
|
108
|
+
task :release => [:nodebug,:compile,:pack,:notify]
|
109
|
+
task :default => [:compile,:notify,:test]
|
110
|
+
<% else %>
|
111
|
+
desc "Build a release version of <%= @project_name %> (with trace() disabled)"
|
112
|
+
task :release => [:nodebug,:compile,:pack]
|
113
|
+
task :default => [:compile,:test]
|
114
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "rubygems"
|
3
|
+
require "fluby"
|
4
|
+
|
5
|
+
commandline = ARGV
|
6
|
+
if commandline.size < 2
|
7
|
+
puts "Usage: script/generate type classpath [options]"
|
8
|
+
puts "where type is one of"
|
9
|
+
Fluby.available_templates.each do |t|
|
10
|
+
puts "\t#{t}"
|
11
|
+
end
|
12
|
+
else
|
13
|
+
type = commandline.shift
|
14
|
+
name = commandline.shift
|
15
|
+
options = commandline
|
16
|
+
Fluby.generate(type,name,options)
|
17
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* Delegate Class, MTASC compatible
|
4
|
+
*
|
5
|
+
**/
|
6
|
+
|
7
|
+
class <%= @classpath %>.<%= @classname %> {
|
8
|
+
public static function create(scope:Object,method:Function):Function{
|
9
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
10
|
+
var proxyFunc:Function = function():Void{
|
11
|
+
method.apply(scope,arguments.concat(params));
|
12
|
+
}
|
13
|
+
return proxyFunc;
|
14
|
+
}
|
15
|
+
public static function createR(scope:Object,method:Function):Function{
|
16
|
+
var params:Array = arguments.splice(2,arguments.length-2);
|
17
|
+
var proxyFunc:Function = function():Void{
|
18
|
+
method.apply(scope,params.concat(arguments));
|
19
|
+
}
|
20
|
+
return proxyFunc;
|
21
|
+
}
|
22
|
+
}
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class <%= @classpath %>.<%= @classname %> {
|
2
|
+
var _path:String;
|
3
|
+
var raw_data:XML;
|
4
|
+
|
5
|
+
function <%= @classname %>(path:String,callback:Function){
|
6
|
+
_path = path;
|
7
|
+
raw_data = new XML();
|
8
|
+
raw_data.ignoreWhite = true;
|
9
|
+
raw_data.onLoad = callback;
|
10
|
+
}
|
11
|
+
function give_me(node_name){
|
12
|
+
if (raw_data.firstChild.nodeName == node_name) {
|
13
|
+
return raw_data.firstChild;
|
14
|
+
}
|
15
|
+
for(var i=raw_data.firstChild.childNodes.length; i>=0; i--){
|
16
|
+
if(raw_data.firstChild.childNodes[i].nodeName == node_name){
|
17
|
+
return raw_data.firstChild.childNodes[i];
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
public function load(){
|
22
|
+
raw_data.load(_path);
|
23
|
+
}
|
24
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
2
|
+
<head>
|
3
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
4
|
+
<title><%= APP %></title>
|
5
|
+
<script type="text/javascript" src="swfobject.js"></script>
|
6
|
+
</head>
|
7
|
+
<body>
|
8
|
+
<div id="flashcontent">
|
9
|
+
This text is replaced by the Flash movie.
|
10
|
+
</div>
|
11
|
+
<script type="text/javascript">
|
12
|
+
var so = new SWFObject("<%= APP %>.swf", "mymovie", "<%= WIDTH %>", "<%= HEIGHT %>", "<%= PLAYER %>", "<%= BGCOLOR %>");
|
13
|
+
so.write("flashcontent");
|
14
|
+
</script>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
<movie width="<%= WIDTH %>" height="<%= HEIGHT %>" framerate="<%= FPS %>" version="<%= PLAYER %>">
|
3
|
+
<background color="<%= BGCOLOR %>"/>
|
4
|
+
<frame>
|
5
|
+
<library>
|
6
|
+
<% Dir["assets/*.png"].each do |file| %>
|
7
|
+
<clip id="<%= File.basename(file,'.png') %>" import="<%= file %>"/>
|
8
|
+
<% end %>
|
9
|
+
<% Dir["assets/*.ttf"].each do |file| %>
|
10
|
+
<font id="<%= File.basename(file,'.ttf') %>" import="<%= file %>" name="<%= File.basename(file,'.ttf').split('-')[0] %>" glyphs="abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ01234567890,.-_¡!áéíóúÁÉÍÓÚüÜ\/• :;()¿?<>" />
|
11
|
+
<% end %>
|
12
|
+
<!--
|
13
|
+
<clip id="VideoDisplay">
|
14
|
+
<frame>
|
15
|
+
<video id="vid" width="240" height="180" smoothing="3" />
|
16
|
+
<place id="vid" name="vid" />
|
17
|
+
</frame>
|
18
|
+
</clip>
|
19
|
+
-->
|
20
|
+
</library>
|
21
|
+
</frame>
|
22
|
+
</movie>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
/**
|
2
|
+
* SWFObject v1.5.1: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
|
3
|
+
*
|
4
|
+
* SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
|
5
|
+
* http://www.opensource.org/licenses/mit-license.php
|
6
|
+
*
|
7
|
+
*/
|
8
|
+
if(typeof deconcept=="undefined"){var deconcept={};}if(typeof deconcept.util=="undefined"){deconcept.util={};}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil={};}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params={};this.variables={};this.attributes=[];if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10]||"";},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15]||"";},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=[];var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+(this.getAttribute("style")||"")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+(this.getAttribute("style")||"")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bomberstudios-fluby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Ale Mu\xC3\xB1oz"
|
@@ -21,8 +21,21 @@ extensions: []
|
|
21
21
|
|
22
22
|
extra_rdoc_files: []
|
23
23
|
|
24
|
-
files:
|
25
|
-
|
24
|
+
files:
|
25
|
+
- README.mdown
|
26
|
+
- Rakefile
|
27
|
+
- bin/fluby
|
28
|
+
- lib/fluby.rb
|
29
|
+
- lib/templates/ASClass.as
|
30
|
+
- lib/templates/index.rhtml
|
31
|
+
- lib/templates/project.rxml
|
32
|
+
- lib/templates/Rakefile
|
33
|
+
- lib/templates/README
|
34
|
+
- lib/templates/swfobject.js
|
35
|
+
- lib/templates/generate
|
36
|
+
- lib/templates/generators/class
|
37
|
+
- lib/templates/generators/delegate
|
38
|
+
- lib/templates/generators/xml_loader
|
26
39
|
has_rdoc: false
|
27
40
|
homepage: http://github.com/bomberstudios/fluby/
|
28
41
|
post_install_message:
|