Click here to Skip to main content
Email Password   helpLost your password?

Introduction

For those out there who have added Macromedia Flash movies to your dynamic web pages, you no doubt found it frustrating to make the movie itself dynamic. That is, dynamic variables and properties; or even the movie itself dynamic like a rotator. And even more frustrating what if you wanted default html in place just in case the Flash plug-in is not installed or you are going the route of enforcing that a certain version is installed through JavaScript, and in fact JavaScript has been disabled. Well, although this custom ASP.NET control does not sing and dance, it does make these tasks extremely easy to manage.

The FlashMovieControl wraps up all properties that can be pushed into a Flash movie, (i.e. scale, width, height, window mode... the list goes on). And does it all with great designer support, which proved to be a valuable learning experience for me. The current version of this control is currently up-to-date with the latest properties and output rendering of Macromedia 2004 Flash MX. You will find that the rendered content that is sent to the browser is exact to what is published directly from the Macromedia MX studio.

Features

What are the FlashOutputType's for? (Osmosis.Web.UI.FlashOutputType)

Get me started using the FlashMovieControl

Make sure to reference the .dll in your project. In the Solution Explorer, locate your project and right click on the References node. Select Add Reference. Browse for the .dll file downloaded from CodeProject and click OK. To use with the designer: when your webform is in design view, open up the Toolbox and right click. Select Add/Remove Items. Browse for the .dll file downloaded from CodeProject and click OK. Now the FlashMovieControl is added to your Toolbox. Just drag it onto your page and open up your Properties window. One thing to keep in mind is to always set the MovieName property. This is the URL of the actual .swf file. If you forget to add the actual movie, your browser will hang because it is trying to locate the file that is non-existent. In a future release, I will set the control to throw an exception if no movie has been set. Below is an example of using the FlashMovieControl with ClientScriptVersionDetection as the FlashOutputType.

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace FlashTest
{

    public class FlashMovieControlTest : System.Web.UI.Page
    {
        protected Osmosis.Web.UI.Controls.FlashMovie FlashMovie1;
    
        private void Page_Load(object sender, System.EventArgs e)
        { 
            this.FlashMovie1 = new Osmosis.Web.UI.Controls.FlashMovie();
            
            ///Set the output type and Movie

            this.FlashMovie1.FlashOutputType = 
              Osmosis.Web.UI.FlashOutputType.ClientScriptVersionDection;
            ///Always make sure you have a valid movie 

            ///or your browser will hang.

            this.FlashMovie1.MovieName = "MyMovie.swf";
            
            /// Set the plugin version to check for

            this.FlashMovie1.MajorPluginVersion = 7;
            this.FlashMovie1.MajorPluginVersionRevision = 0;
            this.FlashMovie1.MinorPluginVersion = 0;
            this.FlashMovie1.MinorPluginVersionRevision = 0;
            
            ///Set some other properties

            this.FlashMovie1.MovieHeight = "400px";
            this.FlashMovie1.MovieWidth = "200px";
            this.FlashMovie1.AutoLoop = false;
            this.FlashMovie1.AutoPlay = true;
            this.FlashMovie1.FlashHorizontalAlignment = 
                 Osmosis.Web.UI.FlashHorizontalAlignment.Center;
            this.FlashMovie1.FlashVerticalAlignment = 
                 Osmosis.Web.UI.FlashVerticalAlignment.Top;
            this.FlashMovie1.HtmlAlignment = 
                 Osmosis.Web.UI.FlashHtmlAlignment.Right;
            this.FlashMovie1.UseDeviceFonts = false;
            this.FlashMovie1.WindowMode = 
                 Osmosis.Web.UI.FlashMovieWindowMode.Transparent;
            this.FlashMovie1.ShowMenu = false;
            this.FlashMovie1.MovieQuality = 
                 Osmosis.Web.UI.FlashMovieQuality.AutoHigh;
            this.FlashMovie1.MovieScale = 
                 Osmosis.Web.UI.FlashMovieScale.NoScale;
            
            /// Add some variables

            this.FlashMovie1.MovieVariables.Add("MyVar1","MyValue1");
            this.FlashMovie1.MovieVariables.Add("MyVar2","MyValue2");
            this.FlashMovie1.MovieVariables.Add("MyVar3","MyValue3");
            
            ///Set the NoScript and NoFlash content.  

            ///In most situations where

            ///html will be displayed the content is the same for both

            this.FlashMovie1.NoFlashContainer.Controls.Add(
              this.GetDefaultHtmlContent());
            this.FlashMovie1.NoScriptContainer.Controls.Add(
              this.GetDefaultHtmlContent());
        }
        
        

        private HtmlTable GetDefaultHtmlContent(){
            
            HtmlTable tbl = new HtmlTable();
            HtmlTableRow tr = new HtmlTableRow();
            HtmlTableCell td = new HtmlTableCell();
            Label lbl = new Label();
            lbl.Text = "This is my default content";
            
            td.Controls.Add(lbl);
            tr.Cells.Add(td);
            tbl.Rows.Add(tr);
            return tbl;
        }

        #region Web Form Designer generated code
        override protected void OnInit(EventArgs e)
        {
            //

            // CODEGEN: This call is required by the ASP.NET 

            // Web Form Designer.

            //

            InitializeComponent();
            base.OnInit(e);
        }
        
        /// <summary>

        /// Required method for Designer support - do not modify

        /// the contents of this method with the code editor.

        /// </summary>

        private void InitializeComponent()
        {    
            this.Load += new System.EventHandler(this.Page_Load);

        }
        #endregion
    }
}
-------------------------------------------------------------------
Renders As......
-------------------------------------------------------------------
<SCRIPT LANGUAGE="JavaScript1.1">
<!--
var MM_contentVersion = 7;
var plugin = (navigator.mimeTypes && navigator.mimeTypes[
  "application/x-shockwave-flash"]) ?
navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin : 0;
if ( plugin ) {
var words = navigator.plugins["Shockwave Flash"].description.split(" ");
for (var i = 0; i < words.length; ++i)
{
if (isNaN(parseInt(words[i])))
continue;
var MM_PluginVersion = words[i];
}
var MM_FlashCanPlay = MM_PluginVersion >= MM_contentVersion;
}
else if (navigator.userAgent && navigator.userAgent.indexOf("MSIE")>=0
&& (navigator.appVersion.indexOf("Win") != -1)) {
document.write('<SCR' + 'IPT LANGUAGE="VBScript\"> \n');
document.write('on error resume next \n');
document.write('MM_FlashCanPlay = ( 
  IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash." & 
  MM_contentVersion)))\n');
document.write('</SCR' + 'IPT\> \n');
}
if ( MM_FlashCanPlay ) {
document.write('<OBJECT classid=
  "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"');
document.write('  codebase=
  "http://fpdownload.macromedia.com/pub/shockwave/cabs/
  flash/swflash.cab#version=7,0,0,0" ');
document.write(' ID="FlashMovie1" WIDTH="200px" 
  HEIGHT="400px" ALIGN="right">');
document.write(' <PARAM NAME=movie 
  VALUE="MyMovie.swf?MyVar1=MyValue1&MyVar2=MyValue2&MyVar3=MyValue3"> 
  <PARAM NAME=loop VALUE=false /> <PARAM NAME=menu VALUE=false /> 
  <PARAM NAME=scale VALUE=noscale /> <PARAM NAME=wmode VALUE=transparent />
  <PARAM NAME=salign VALUE=T /> <PARAM NAME=quality VALUE=AutoHigh/> 
  <PARAM NAME=bgcolor VALUE=#ffffff/> <PARAM NAME="allowScriptAccess" 
  value="SameDomain" />  ');
document.write(' <EMBED 
  src="MyMovie.swf?MyVar1=MyValue1&MyVar2=MyValue2&MyVar3=MyValue3" 
  loop="false" menu="false" scale="noscale" wmode="transparent" 
  salign="T" quality="autohigh" bgcolor="#ffffff" 
  allowScriptAccess="SameDomain"   ');
document.write(' swLiveConnect=FALSE WIDTH="200px" 
  HEIGHT="400px" NAME="MyMovie.swf" ALIGN="right"');
document.write(' TYPE="application/x-shockwave-flash" 
  PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">');
document.write(' </EMBED>');
document.write(' </OBJECT>');
} else{
document.write('<table>');
document.write('    <tr>');
document.write('        <td><span>This is my default content</span></td>');
document.write('    </tr>');
document.write('</table>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<table ID="Table1">
    <tr>
        <td><span>This is my default content</span></td>
    </tr>
</table>
</NOSCRIPT>
HTML View example
------------------

<OSMOSIS:FLASHMOVIE id=FlashMovie1 runat="server" 
  MovieName="MyMovie.swf" AutoLoop="False" AutoPlay="False" 
MovieScale="NoScale" MovieQuality="AutoLow" FlashHorizontalAlignment="Right" 
FlashVerticalAlignment="Top" MovieHeight="222" MovieWidth="33" 
WindowMode="Transparent"></Osmosis:FlashMovie>

Thanks for all your input! Keep it coming. Feel free to contact with any questions or suggestions.

History

You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralDoes it solves the problem of swf file caching.
Hemant.Kamalakar
20:25 4 Mar '09  
SWFs, like other documents and media retrieved by a Web browser, are often saved, or cached, locally on the user's hard drive. The next time that media is requested the Web browser may load the file from the cache instead of downloading it over the network. This might be desirable for a Flash movie whose content doesn't change often but undesirable for SWFs that are updated frequently with new content or information.

Does this control solves the problem of swf file caching???
GeneralLoad an swf dinamically
mjpr
7:09 24 Jan '07  
Hi,

Love your control.

But I have a question.

Imagine I have a listbox populated with swf files existing in a directory.
When I select a file from the listbox, I want that specific movie to be loaded.

On the listbox SelectedIndexChanged event I try to set the "MovieName" property:

Dim FlashMovie1 As Osmosis.Web.UI.Controls.FlashMovie = New
Osmosis.Web.UI.Controls.FlashMovie
FlashMovie1.MovieName = Me.myListbox.SelectedItem.Text
FlashMovie1.Visible = True

' clean up any other loaded swf
Me.phJogo.Controls.Remove(FlashMovie1)
' add the FlashMovie Control to the PlaceHolder
Me.phJogo.Controls.Add(FlashMovie1)


When I select an SWF from the listbox the first time everthing goes fine, but if I select another movie, it dowsn't change.
I think it has something to do with the code beeing already sent to the html page, but how do I overcome that to make it dynamic?

Thankx,
Mario

QuestionNew version
rashack
4:14 30 Nov '06  
Thanks for this control. I hope it will help me in the end.

Is there any chance you would publish the new version? If yes - when?

Thanks for any info.
General.NET 2
Sam_Tanner
5:16 19 Oct '06  
Hurry with the NET 2 version, Ron!
Thanks for sharing...


GeneralGood Control so far
babalao
11:13 6 Sep '06  
Thanks man, this control its owsome, easy to install and the example its great. I easyly intall it. just put the dll in the bin folder add the component and that it. Well in design mode gaves me a Error Rendering Control(there is a way to fix it), but when i compile it compiles good.Cool

Thanks again


Babalao
GeneralFlash file is not displayed in window
etanefo
19:38 18 Aug '06  
Here is the script:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" width="480" height="325">
<EMBED src="~/Episodes/presentation_1.swf?contentVersion=7&contentMajorRevision=0&contentMinorRevision=0&allowFlashAutoInstall=True&flashContentURL=&altContentURL=" scale="noscale" devicefont="true" salign="RT" quality="autohigh" bgcolor="#c0c0c0" allowScriptAccess="SameDomain" WIDTH="480" HEIGHT="325" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED>
</OBJECT>

Would you please tell me why the flash file is not loaded in teh window?
I am working on a very urgent project and your prompt response will be very much appreciated.
My environment is ASP DOT NET 2.0 with IE

Regards,

Eric T.
GeneralFlashMovie1 does not work when I attempt to drag the object from the toolbox into my page (in design mode)
etanefo
14:38 16 Aug '06  
How to resolve the following issue:

Error message:

Error rendering Control - FlashMovie1
An unhandled exception has occured
Object reference not set to an instance of an object

The same message appears in the Property box next to the following attributes:
- DetectionPluginsPage
- FlashCodeBase
- FlashPluginsPage

It is not possible to select another option for these attributes.

Please HELP!



Eric T.
GeneralRe: FlashMovie1 does not work when I attempt to drag the object from the toolbox into my page (in design mode)
bswooden
12:15 7 Dec '06  
I am having the exact same problem.

I am using VS 2005.

Is there been a solution to this problem?
GeneralRe: FlashMovie1 does not work when I attempt to drag the object from the toolbox into my page (in design mode)
somayeh_h
2:40 15 Apr '08  
:( I have this problem too
please answer it
GeneralIE Security Workaround
7SM Developers
8:34 26 May '06  
Have you or can you implement the workaround to the IE security issue (http://www.amarasoftware.com/macromedia-ie-solution.htm[^]) explained in the article?

It looks pretty straightforward, but I don't particularly want to change the code base if you plan on implementing it.



Thanks,
-->Monnix
GeneralRe: IE Security Workaround
RonVecchi
16:32 30 May '06  
just started working on it, among other things like some fixez for DOTNET 2.0 and some misc stuff. Give me a couple days on it...

Ron,
QuestionRe: IE Security Workaround
leonziur
10:24 26 Sep '06  
Any word on this update? I am hoping it will be implemented as well as I love using this control Smile
GeneralPlugin doesn't autoinstall
YaKs69
1:19 26 Apr '06  
Hi!

I used the control and when I have already installed the flash plugin in the browser everything works perfect but when not, it doesn't download the needed plugin.

Is there any way to achieve this the automatic behaviour?

Thanks in advance.

Jose
GeneralRe: Plugin doesn't autoinstall
RonVecchi
16:32 30 May '06  
Looking into it, I am working on a release for the IE work around and some dotnet 2.0 stuff. I'll look into this as well...

Ron,
GeneralBASE tag?
mgamache
12:32 4 Mar '06  
I don't see a way of setting the BASE url param from the control. Am I missing something?

-mark
GeneralRe: BASE tag?
RonVecchi
16:35 30 May '06  
currently looking into this.......

Ron,
GeneralFlash object missing the id attribute
Le-Fay
3:48 13 Feb '06  
I'm using the Osmosis.Web.UI.Controls.FlashMovie inside a user control and trying to access variables in the swf file using javascript, but some how the flash object don't have an id.
I've used 'view source' on the final web page and found no id attribute on the flash object.

did any one came across this problem before?
GeneralRe: Flash object missing the id attribute
RonVecchi
16:36 30 May '06  
looking into it...

Ron,
GeneralFlash movie is not working
Arun Gandhi
13:08 25 Jan '06  
Hi all

I am trying to run the example. Its not working. The following properties have the values "Object reference not set to an instance of an object."

DetectionPluginsPage
FlashCodeBase
FlashPluginsPage

I have a movie on my local workstation and as well as at a remote server. When I run the example browser hangs.

I am using ASP.Net 1.1.

Please help.

Thanks

GeneralRe: Flash movie is not working
sayou
23:17 22 Feb '06  
hello,

i have exactly the same problem, what can I do?

Please help

GeneralRe: Flash movie is not working
RonVecchi
16:35 30 May '06  
Typically when the browser hangs it is because the movie is not there, are you sure you are pointing to the correct file name. If this is it, I am currently working on a release for the IE work around, some DOTNET 2.0 related issues and some misc stuff. I am also going to handle the situation when the file being referenced is not available...mabey throw an error or something...not sure yet.

Ron,
GeneralMovie Variables
venkat_sub
11:21 25 Jan '06  
Hi,

I wonder if anybody has experienced this problem.

The movie variables are a namevaluecollection property. While trying to add values using web forms designer, the string collection editor appears with 'Add', 'Remove' button disabled.

I'm using ASP.NET 2.0.

Thanks
Arvind
GeneralRe: Movie Variables
RonVecchi
16:37 30 May '06  
looking into it...new release soon...

Ron,
GeneralWhy it won't loop?
wasouthpnt
10:52 23 Jan '06  
Great control, but can we get a loop feature. I tried the loop property=true but no looping. Also, what about a list of .swf files that the control would play in order or at random with looping like a "AdRotator" control. The idea here is to provide looping through *.swf files WITHOUT needing to do page re-loads.

Thanks
GeneralFlash movie doesn't work properly
YaKs77
5:30 12 Jan '06  
Hi everybody and congratulatiosn for the incredible control.

but I cannot find out what is going wrong with it in my app. My flash movie does connections to web services and when I run my aspx, the flash movie gives an error conection to web services BUT If I copy the generated HTML code and paste it into a blank document and I open the html file with the browser, everything works fine.

somebody could tell what is going on? something related with the .net framework?
some code that I miss to include...

Thank you very much in advance, every comment will be very welcome

Jose


This is my code, very simple...

private void Page_Load(object sender, System.EventArgs e)
{
oFlash.FlashOutputType = Osmosis.Web.UI.FlashOutputType.ClientScriptVersionDection;
oFlash.MovieName = "tiendasonline.swf";
oFlash.MovieQuality = Osmosis.Web.UI.FlashMovieQuality.High;
oFlash.MovieBGColor = System.Drawing.Color.FromArgb(0,0,0);
oFlash.ScriptAccessControl = Osmosis.Web.UI.FlashScriptAccessControl.SameDomain;
oFlash.MovieWidth = "975";
oFlash.MovieHeight = "625";

DataSet ds;

wsUtiles.sws_perfil.Perfil oPerfil = wsUtiles.wsCreacion.wsNuevoPerfil();
if (oPerfil == null)
{
Response.Write(wsUtiles.wsCreacion.enErrorCode);
return;
}
string usuario = WindowsIdentity.GetCurrent().Name.ToUpper();
ds = oPerfil.dsCadenasSecciones("123456789","tiendasonline",usuario);

if (ds.Tables["Errores"].Rows.Count == 0 )
{
ArrayList aCadenas = new ArrayList();
foreach(DataRow oFila in ds.Tables["CadenasSecciones"].Rows)
{
if (aCadenas.IndexOf(oFila["CodCadena"].ToString()) == -1)
aCadenas.Add(oFila["CodCadena"].ToString());
}
for ( int i =0 ; i< aCadenas.Count;i++)
oFlash.MovieVariables.Add("C"+aCadenas[i],"1");
}

}

Jose


Last Updated 25 Apr 2005 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2010