so in this project i'm working on, the client wants a flash carousel of images. easy right? easy if the images don't have to change. my problem here is that the images needs to be replaced everytime the user clicks on a tab.
so for example, if i click on a "celebrity" tab, it'll show me images of the recent celebrities added. same goes if i click on "photos", "groups", and etc.
so here's how i did it:
i used flShow Carousel for the flash carousel, jQuery and RoR.
first, i embedded the flash carousel in my index.html.erb.
<div style="width:605px;height:200px;">then, i added a method in my controller to generate the xml.
<object width="605" height="200">
<param name="movie" value="/flash/Carousel.swf">
<param name="flashvars" value="xmlfile=<%= url_for :action => "carousel_data", :type => 'Person', :only_path => true %>"/>
<embed src="/flash/Carousel.swf?xmlfile=<%= url_for :action => "carousel_data", :type => 'Person', :only_path => true %>" width="605" height="200">
</embed>
</object>
</div>
def carousel_datathen, i added my jQuery script binded to the onclick event of each tab.
@data = params[:type].constantize.find_recent
render :file => "data.xml", :layout => false
return @data
end
embed_flash = '<div style="width:605px;height:200px;"><object width="605" height="200"><param name="movie" value="/flash/Carousel.swf"><param name="flashvars" value="xmlfile=<%= url_for :action => "carousel_data", :type => 'Blog', :only_path => true %>"/><embed src="/flash/Carousel.swf?xmlfile=<%= url_for :action => "carousel_data", :type => 'Blog', :only_path => true %>" width="605" height="200"></embed></object></div>';in my data.xml file, i added the following:
$('#coverflow').html(embed_flash);
return false;
<slide_show>for more info on the options for configuring the flShow Carousel through xml, view the flShow docuwiki
<% @data.each do |d| %>
<photo><%= d.image.url(:small) %></photo>
<% end %>
</slide_show>