5,449,204 members and growing! (20,992 online)
Email Password   helpLost your password?
Enterprise Systems » SharePoint Server » Web Parts     Intermediate

SharePoint 2007 Flash Animation Web Part

By Mahdi Abdulhamid

SharePoint 2007 Flash Animation Web Part
C# 2.0, C#, Windows, .NET, .NET 2.0, ASP.NET, VS2005, Visual Studio, Dev

Posted: 11 Jun 2007
Updated: 11 Jun 2007
Views: 30,806
Bookmarked: 15 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
8 votes for this Article.
Popularity: 4.09 Rating: 4.53 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
1 vote, 12.5%
3
0 votes, 0.0%
4
7 votes, 87.5%
5

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 = "";
                
        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;
            }
        }
        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;
            }
        }
        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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Mahdi Abdulhamid



Occupation: Web Developer
Location: Saudi Arabia Saudi Arabia

Other popular SharePoint Server articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 15 of 15 (Total in Forum: 15) (Refresh)FirstPrevNext
Subject  Author Date 
Generalextend the webpartmemberm_Consultant3:42 28 Feb '08  
GeneralIs there a version that might work with WSS v3.0memberInverted_Diver14:22 7 Nov '07  
GeneralRe: Is there a version that might work with WSS v3.0memberMahdi Abdulhamid5:37 9 Dec '07  
Questionerror in this.ExportModememberellenzinha2:51 15 Oct '07  
GeneralMore reasons....memberMagnus Salgo0:26 22 Aug '07  
GeneralPort 80membertonyjo20:06 22 Jul '07  
GeneralRe: Port 80memberMahdi Abdulhamid0:07 23 Jul '07  
Questionmiss the category flashInfomemberGertrud223:43 21 Jun '07  
AnswerRe: miss the category flashInfomemberMahdi Abdulhamid1:38 22 Jun '07  
GeneralRe: miss the category flashInfomemberGertrud21:27 26 Jun '07  
GeneralRe: miss the category flashInfomemberMahdi Abdulhamid2:28 26 Jun '07  
GeneralRe: miss the category flashInfomemberjerald jp5:41 16 Jul '07  
GeneralRe: miss the category flashInfomemberMahdi Abdulhamid6:04 16 Jul '07  
GeneralThanksmembermerlin98110:17 11 Jun '07  
GeneralRe: ThanksmemberMahdi Abdulhamid11:33 11 Jun '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 11 Jun 2007
Editor: Deeksha Shenoy
Copyright 2007 by Mahdi Abdulhamid
Everything else Copyright © CodeProject, 1999-2008
Web12 | Advertise on the Code Project