Ming/Ruby examples

[Get Flash]

Ports from "Ming/PHP examples"

Basic Drawing and Animation
Drawing Shapes - shape [swf] [rb]
Basic drawing commands revealed, uninteresting shape rendered. In red.
Writing Text - text [swf] [rb]
Everything you want to know -- everything you could know -- about adding text to SWF movies.
Drawing Glyphs - glyph [swf] [rb]
The previous example shows how to make text objects. This shows how to draw glyph outlines into shape objects. The difference is this allows you to set fill/line properties for the text, instead of just being able to change the text color.
Animation - anim [swf] [rb]
Stare in amazement as your very own words spin nauseatingly in front of you. What will you choose- your name? an onomatopoeia? random symbols? perhaps a trite obscenity?
SWFSprite - sprite [swf] [rb] -k
The happy red square spins gleefully!
clip [swf] [rb] があった(^^;)。Ming/Ruby 的には Sprite = MovieClip なんですね。 「class SWFSprite < SWFMovieClip; end」しています。 ← Ming/Ruby 0.0.9 から必要なくなりました。
SWFMorph - morph [swf] [rb]
The happy red square turns into a mean blue square!
Bitmaps
png images - png [swf] [rb] -k
Can now use PNG images in shapes..
JaMing についてくる util/png2dbl を make して png2dbl hoge.png すると hoge.dbl ができます。
pngs with alpha channel - pngalpha [swf] [rb] -k
..even those with alpha channels.
アルファチャンネル(透明度)のグラデーションがある PNG ファイルも同様に dbl にして取り込めます。
jpegs - jpegfill [swf] [rb] -k
..plus jpegs, too!
jpg ファイルは変換せずに取り込めます。
alpha masking - alphafill [swf] [rb] -k
And you can put an alpha mask on a jpeg fill.
JaMing についてくる util/gif2mask を make してマスクファイルを作るようですが、「SWFBitmap.new("hoge.jpg", "hoge.msk")」がまだうまく使えません。Ming/Ruby 0.0.9 以降で直っているはずです。白→黒のグレースケールのマスクファイルを使うと黒っぽいところが透けます。
Gradients
basic gradients - gradient [swf] [rb] -k
A red splotch in a grey field.
Fill Transforms
gradient transforms - gradientxform [swf] [rb] -k
A morphing gradient fill.
bitmap transforms - bitmapxform [swf] [rb] -k
A morphing bitmap fill- if only it worked..
Color Transforms
basic color transform - cxform [swf] [rb] -k
..the spooky halloween/landing-on-jupiter version.
cxform2 [swf] [rb] -k jpg を使わないで色だけ変えたもの
Action script
basic action - action [swf] [rb]
The happy red square swims gracefully across the screen!
action2 [swf] [rb] -k action.rb があるのに気づかないで PHP から素直に移植したもの。(^^;)
mouse tracking - mousetrack [swf] [rb] -k
Shows how to follow the mouse around the window. Warning: users with nervous disorders should avoid this one.
うまく動きません。ruby mousetrack.rb すると帰ってこなくなります。
Ming/Ruby 0.0.8 から PHP の Ming_useSWFVersion(4); に対応する use_SWFVersion(4) が使えるようになったそうです。
mouse tracking again - sparks [swf] [rb] -k (*)
Another mouse tracking example, but this one uses the Flash 5 _xmouse and _ymouse properties to track the mouse.
swf は生成されるけど真っ黒で何も起こらない。(^^;
key press actions - keypress [swf] [rb] -k
Shows how to add a keypress action to a button. Hint: use SWFBUTTON_KEYPRESS() as a flag to SWFButton::addAction.
SWFBUTTON_KEYPRESS を Ming#key_press にどう書きかえればいいのかまだよくわかんない。
% ruby keypress.rb
keypress.rb:72: [BUG] Segmentation fault
ruby 1.6.7 (2002-03-01) [i386-linux-gnu]
zsh: 12415 abort      ruby keypress.rb
素直に置き換えちゃえばいいみたいです。↑Ming/Ruby 0.0.9 で直りました。
Buttons
SWFTextField - newbutton [swf] [rb] -k
Fancy button actions and text fields.
TextField に set_name メソッドが抜けてるみたい → PHP/Ming でしか実装されてないメソッドかも?
% ruby newbutton.rb
newbutton.rb:54: undefined method `set_name' for #<Ming::SWFTextField:0x2acc6778> (NameError)
newbutton.rb:54: [BUG] Segmentation fault
ruby 1.6.7 (2002-03-01) [i386-linux-gnu]
zsh: 11523 abort      ruby newbutton.rb
これも Ming/Ruby 0.0.9 で直っています。
more SWFButton - drag [swf] [rb] -k
This one's a real drag. Ha! Get it? A DRAG! whew boy.
SWFButton - button [swf] [rb] -k
The happy red square changes color when you click on it!
Streaming mp3
Streaming mp3 - sound [swf] [rb]

[Back]
Kumamushi Genome Project BioRuby.org
KATAYAMA Toshiaki <k@bioruby.org>