Serve SWF thru RubyAMF

0 views
Skip to first unread message

Gustav (Stockholm)

unread,
Jan 6, 2008, 6:12:29 PM1/6/08
to rubyamf
Hi!
Can I use RubyAMF to dynamically load a SWF into a Flash-file using
loadMovie, or something along those lines? I was thinking of
integrating it with REST by using render :amf in the respond_to-block
in my Rails-controller; how would I go about to do that?

Best regards,
Gustav

Cliff Rowley

unread,
Jan 6, 2008, 6:47:53 PM1/6/08
to rub...@googlegroups.com

RubyAMF serves AMF, and AMF isn't SWF - therefore you can't serve a
SWF through it. You can however serve the movie through Rails. If
you want to serve an existing SWF, then take a peek at my tutorial
here: http://blog.eleventyten.com/2007/6/8/embedding-swf-content-with-ror

If you want to dynamically generate the SWF, then you'll need to look
at either MTASC/SWFMill, or the Flex SDK, or something similar.

HTH

Cliff

Gustav (Stockholm)

unread,
Jan 7, 2008, 5:05:42 AM1/7/08
to rubyamf
> RubyAMF serves AMF, and AMF isn't SWF - therefore you can't serve a
> SWF through it. You can however serve the movie through Rails. If
> you want to serve an existing SWF, then take a peek at my tutorial
> here:http://blog.eleventyten.com/2007/6/8/embedding-swf-content-with-ror

Ok, thanks! What I want to accomplish is to make an embedded flash-
file make a REST get-request to a Rails-server, which serves a SWF-
dynamically to be integrated in the Flash-file, based on a pattern in
the IP-adress of the request.

I suppose the way to do this is by using "render :file =>":

def show

ip = request.remote_ip

pattern = x

if pattern.match(ip)
@file = '/ads/x.swf'
else
@file = '/ads/y.swf'
end

respond_to do |format|
format.html { render :file => @file }
end

end

This however, raises the error "No such file or directory - /ads/
x.swf", although when I paste it in the URL as "localhost:3000/ads/
x.swf" it works completely fine. Something with the routes maybe? It
would probably be good idea to use "format.swf" or something in the
respond_to block to get the MIME types all sorted out, but maybe
that's another forum ;)

Anyways, thanks a million for the help!

Cliff Rowley

unread,
Jan 7, 2008, 5:10:11 AM1/7/08
to rub...@googlegroups.com
Does "render :file" not take a file system path? :-)

Cliff Rowley

unread,
Jan 7, 2008, 5:11:14 AM1/7/08
to rub...@googlegroups.com
On 7 Jan 2008, at 04:05, Gustav (Stockholm) wrote:

> if pattern.match(ip)
> @file = '/ads/x.swf'
> else
> @file = '/ads/y.swf'
> end

Try @file = "#{RAILS_ROOT}/public/ads/x.swf" :-)

Reply all
Reply to author
Forward
0 new messages