Embedding swf (Flash) file as a resource in c# 2008 win app.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • guizawa
    New Member
    • Mar 2010
    • 5

    #1

    Embedding swf (Flash) file as a resource in c# 2008 win app.

    Hi all, I am experimenting Walter Wang's code to try to load .swf file from embedded resource to webbrowser in window form but get error:

    "An object reference is required for the non-static field, method, or property'System .Web.UI.Page.Cl ientScript.get' "


    This is what I did:

    checked with GetManifestReso urceNames(), 'swfER.Resource s.Maze.swf' was listed

    in assemblyinfo.cs , I entered:

    [assembly: WebResource("sw fER.Resources.M aze.swf", "applicatio n/x-shockwave-flash")]

    in WebBrowserForm

    Code:
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    
    namespace swfER
    {
        public partial class WBForm : Form
        {
            public WBForm()
            {
    	    HtmlTextWriter writer = null;
    
                InitializeComponent();
    		
    	    Render(writer);
    
    	}
    
    	private void Render(HtmlTextWriter writer)
            {
                
                String template =
                @"<html><head></head><body><object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' 
                codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' 
                width='400' height='320'> 
                <param name='movie' value='{0}'>        
                <embed src='temp.swf' width='400' height='320'  
                pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' 
                type='application/x-shockwave-flash'></embed></object></body></html>"; 
                writer.Write(string.Format(template,
                Page.ClientScript.GetWebResourceUrl(this.GetType() ,
                "swfER.Resources.Maze.swf")));
            }
             
        }
    }
    I noticed that Page had no ClientScript property in my IDE.


    Please, inform me what to do to make this work, if you can. Really appreciate it. Thank's in advance.
    Last edited by tlhintoq; Mar 30 '10, 03:35 PM. Reason: [CODE] ...Your code goes between code tags [/CODE]
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    TIP: When you are writing your question, there is a button on the tool bar that wraps the [code] tags around your copy/pasted code. It helps a bunch. Its the button with a '#' on it. More on tags. They're cool. Check'em out.

    Comment

    Working...