Click here to Skip to main content
Licence Ms-PL
First Posted 11 Jun 2007
Views 89,060
Downloads 491
Bookmarked 36 times

SharePoint 2007 Flash Animation Web Part

By | 11 Jun 2007 | Article
SharePoint 2007 Flash Animation Web Part

Screenshot - flashWebPart.jpg

Introduction

I've seen that many people are using HTML content web part for displaying Flash animation. I don't recommend this approach for many reasons, one of them being you won't tell your client to edit HTML code for changing Flash properties; so it is better to have a dedicated web part for rendering Flash animation.

Software Requirements

  • Microsoft SharePoint 2007 installed (With Site Collection created on port:80)
  • SharePoint Services 3.0 Extensions for Visual Studio 2005 installed

Using the code

To apply the code, you will need to create a new SharePoint Webpart Project then overrides the web part class file:

using System;
using System.ComponentModel;
using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.WebControls;
using System.Xml.Serialization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;
using Microsoft.SharePoint.Utilities;
using System.Web.UI.HtmlControls;
namespace FlashWebPart
{
    [Guid("f04fa49d-1342-4c7d-904a-c43ebc942f39")]
    [XmlRoot(Namespace = "FlashWebPart")]
    public class FlashWebPart : Microsoft.SharePoint.WebPartPages.WebPart
    {
        public FlashWebPart()
        {
            this.ExportMode = WebPartExportMode.All;
        }
        protected int flashWidth = 400;
        protected int flashHeight = 300;
        protected string flashUrl = "";
                
        [Browsable(true), 
        Category("Flash Info"),
        DefaultValue(400),
        WebPartStorage(Storage.Shared),
        FriendlyName("Width"), 
        Description("Width of the web part")]
        public int FlashWidth
        {
            get
            {
                return this.flashWidth;
            }
            set
            {
                this.flashWidth = value;
            }
        }
        [Browsable(true),
       Category("Flash Info"),
        DefaultValue(300),
        WebPartStorage(Storage.Shared),
        FriendlyName("Height"), 
        Description("Height of the web part")]
        public int FlashHeight
        {
            get
            {
                return this.flashHeight;
            }
            set
            {
                this.flashHeight = value;
            }
        }
        [Browsable(true),
        Category("Flash Info"),
        DefaultValue(""),
        WebPartStorage(Storage.Shared),
        FriendlyName("URL"), 
        Description("URL of the web part")]
        public string FlashURL
        {
            get
            {
                return this.flashUrl;
            }
            set
            {
                this.flashUrl = value;
            }
        }
        protected override void Render(HtmlTextWriter writer)
        {
            string outHTML = 
            "<OBJECT classid=
            \"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" " +
                        "codebase=
            \"http://download.macromedia.com/pub/shockwave/cabs/
            flash/swflash.cab#version=7,0,0,0\" " +
                        "WIDTH=" + flashWidth + " HEIGHT=" + flashHeight + "> 
            " + "<PARAM NAME=movie VALUE=\"" + flashUrl + "\"> " +
                        "<PARAM NAME=WMODE VALUE=\"Transparent\">" +
                        "<PARAM NAME=quality VALUE=high> " +
                        "<EMBED src=\"" + flashUrl + 
                        "\" quality=high wmode=\"transparent\" WIDTH=\"" + 
            flashWidth + 
                        "\" HEIGHT=\"" + flashHeight + 
                        "\" TYPE=\"application/x-shockwave-flash\" PLUGINSPAGE=
            \"http://www.macromedia.com/shockwave/download/
            index.cgi?P1_Prod_Version=ShockwaveFlash\"></EMBED> " 
            + "</OBJECT>";
            writer.Write(outHTML);
        }
    }
}

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)

About the Author

Mahdi Abdulhamid

Web Developer

Saudi Arabia Saudi Arabia

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalhello Pinmemberclinton131416:03 8 Mar '11  
Generalwant to display poster image before video play Pinmemberpoonamgharge23:06 11 Oct '10  
GeneralMy vote of 5 Pinmemberpoonamgharge23:02 11 Oct '10  
QuestionOne More Thing..... PinmemberChristopher Losh10:04 20 Apr '09  
AnswerRe: One More Thing..... PinmemberMahdi Abdulhamid7:31 21 Apr '09  
QuestionRe: One More Thing..... PinmemberChristopher Losh8:16 21 Apr '09  
QuestionRe: One More Thing..... PinmemberChristopher Losh9:57 23 Apr '09  
QuestionIs it supposed to do this? PinmemberChristopher Losh6:18 20 Apr '09  
GeneralWSS 3.0 - Wrong use of the Web Part class Pinmembernowisee3:17 1 Dec '08  
GeneralFlash Query Strings Pinmemberjim iverson4:44 20 Nov '08  
Generalextend the webpart Pinmemberm_Consultant2:42 28 Feb '08  
GeneralIs there a version that might work with WSS v3.0 PinmemberInverted_Diver13:22 7 Nov '07  
GeneralRe: Is there a version that might work with WSS v3.0 PinmemberMahdi Abdulhamid4:37 9 Dec '07  
Questionerror in this.ExportMode Pinmemberellenzinha1:51 15 Oct '07  
GeneralMore reasons.... PinmemberMagnus Salgo23:26 21 Aug '07  
Quote "I don't recommend this approach for many reasons"
 
Confused | :confused: Could you please give more arguments than editing HTML....
 
Magnus Sälgö
Sälgö Consulting AB, Sweden
 

GeneralPort 80 Pinmembertonyjo19:06 22 Jul '07  
GeneralRe: Port 80 PinmemberMahdi Abdulhamid23:07 22 Jul '07  
Questionmiss the category flashInfo PinmemberGertrud222:43 21 Jun '07  
AnswerRe: miss the category flashInfo PinmemberMahdi Abdulhamid0:38 22 Jun '07  
GeneralRe: miss the category flashInfo PinmemberGertrud20:27 26 Jun '07  
GeneralRe: miss the category flashInfo PinmemberMahdi Abdulhamid1:28 26 Jun '07  
GeneralRe: miss the category flashInfo Pinmemberjerald jp4:41 16 Jul '07  
GeneralRe: miss the category flashInfo PinmemberMahdi Abdulhamid5:04 16 Jul '07  
GeneralThanks Pinmembermerlin9819:17 11 Jun '07  
GeneralRe: Thanks PinmemberMahdi Abdulhamid10:33 11 Jun '07  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120529.1 | Last Updated 11 Jun 2007
Article Copyright 2007 by Mahdi Abdulhamid
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid