Module ActionView::Helpers::FlexObjectHelper::InstanceMethods
In: lib/flexobject_view_helper.rb

Methods

Public Instance methods

Returns a path to a Flash object. The src can be supplied as:

  • a full path, such as "/swfs/flex_scaffold/phones.swf"
  • a file name such "phones.swf"
  • a file name without an extension, such as "phones"

[Source]

    # File lib/flexobject_view_helper.rb, line 22
22:         def flexobject_path source
23:           compute_public_path source, File.join('swfs', FlexScaffold::Config.plugin_name), 'swf'
24:         end

Returns a set of tags that display a Flash object within an HTML page.

Options:

  • :div_id - the HTML id of the div element that is used to contain the Flash object; default "flashcontent"
  • :flash_id - the id of the Flash object itself.
  • :background_color - the background color of the Flash object; default white
  • :flash_version - the version of the Flash player that is required; default "7.0.0"
  • :size - the size of the Flash object, in the form "100x100". Defaults to "100%x100%"
  • :variables - a Hash of initialization variables that are passed to the object; default {:lzproxied => false}
  • :parameters - a Hash of parameters that configure the display of the object; default {:scale => ‘noscale’}
  • :fallback_html - HTML text that is displayed when the Flash player is not available.

The following options are for developers. They default to true in development mode, and false otherwise.

  • :check_for_javascript_include - if true, the return value will cause the browser to display a diagnostic message if the FlashObject JavaScript was not included.
  • :verify_file_exists - if true, the return value will cause the browser to display a diagnostic message if the Flash object does not exist.

(This method is called flexobject_tags instead of flashobject_tag because it returns a sequence of HTML tags: a div, followed by a script.)

It is also renamed to flex rather than the original flash so that there are not naming clashes if you use openLaszlo at the same time.

[Source]

    # File lib/flexobject_view_helper.rb, line 50
50:         def flexobject_tags source, options={}
51:           path = flexobject_path source
52:           #TODO check why RAILS_ROOT is not absolute
53:           #verify_file_exists = options.fetch(:verify_file_exists, ENV['RAILS_ENV'] == 'development')
54:           #if verify_file_exists and not File.exists?(File.join(RAILS_ROOT, 'public', path))
55:           #  return "<div><strong>Warning:</strong> The file <code>#{File.join('public', path)}</code> does not exist.  Did you forget to execute <tt>rake flex:compile</tt>?</div>"
56:           #end
57:           div_id = options[:div_id] || 'flashcontent'
58:           flash_id = options[:flash_id] || File.basename(source, '.swf')
59:           width, height = (options[:size]||'100%x100%').scan(/^(\d*%?)x(\d*%?)$/).first
60:           background_color = options[:background_color] || '#ffffff'
61:           flash_version = options[:flash_version] || "7.0.0"
62:           variables = options.fetch(:variables, {:lzproxied => false})
63:           parameters = options.fetch(:parameters, {:scale => 'noscale'})
64:           fallback_html = options[:fallback_html] || %q{<p>Requires the Flash plugin.  If the plugin is already installed, click <a href="?detectflash=false">here</a>.</p>}
65:           if options.fetch(:check_for_javascript_include, ENV['RAILS_ENV'] == 'development')
66:             check_for_javascript ="if (typeof FlashObject == 'undefined') document.getElementById('#{div_id}').innerHTML = '<strong>Warning:</strong> FlashObject is undefined.  Did you forget to execute <tt>rake update_javascripts</tt>, or to include <tt>&lt;%= javascript_include_tag :defaults %></tt> in your view file?';"
67:           end
68:           return "<div id=\"\#{div_id}\" style=\"height:\#{height}; width:\#{width}\">\n\#{fallback_html}\n</div>\n<script type=\"text/javascript\">//<![CDATA[\n\#{check_for_javascript}\nvar fo = new FlashObject(\"\#{path}\", \"\#{flash_id}\", \"\#{width}\", \"\#{height}\", \"\#{flash_version}\", \"\#{background_color}\");\n\#{parameters.map{|k,v|%Q[fo.addVariable(\"\#{k}\", \"\#{v}\");]}.join(\"\\n\")}\n\#{variables.map{|k,v|%Q[fo.addVariable(\"\#{k}\", \"\#{v}\");]}.join(\"\\n\")}\nfo.write(\"\#{div_id}\");\n//]]>\n</script>\n"
69:         end

Returns a set of tags that display a Flash object within an HTML page. Defaults to v9.0.0

Options:

  • :major - default to version 9
  • :minor - default to 0
  • :revision - default to 0

Example output:

 <script language="JavaScript" type="text/javascript">
 <!--
  // -----------------------------------------------------------------------------
  // Globals
 // Major version of Flash required
  var requiredMajorVersion = 9;
 // Minor version of Flash required
 var requiredMinorVersion = 0;
 // Minor version of Flash required
 var requiredRevision = 0;
 // -----------------------------------------------------------------------------
 // -->
 </script>

[Source]

     # File lib/flexobject_view_helper.rb, line 108
108:         def flexobject_version options={}
109:         
110:         major = options[:major] || 9
111:         minor = options[:minor] || 0
112:         revision = options[:revision] || 0
113:         
114:         return "<script language=\"JavaScript\" type=\"text/javascript\">//<![CDATA[\nvar requiredMajorVersion = \#{major};\nvar requiredMinorVersion = \#{minor};\nvar requiredRevision = \#{revision};\n//]]>\n</script>\n"
115:         end

[Validate]