如何使用Flash对象去显示图片

今天在论坛上看到有网友有这样的需求,就是“在asp.net页面中如何点图片就在asp.net页面中堪入的SWF文件中显示这张图片”。记得Insus.NET以前也曾经实现过。既然有人也需求,那把它分享出来。下面提供的代码与方法,已经最大化简化。
首先创建一个swf类别:

View Code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for Swf
/// </summary>
namespace Insus.NET
{
    
public class Swf 
    {
        
private string _File;       

        
public string File
        {
            
set { _File = value; }
        }

        
public Swf()
        {
            
//
            
// TODO: Add constructor logic here
            
//
        }

        
public Swf(string File)
        {
            
this._File = File;
        }

        
public string Show()
        {
            
return @"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'>"
            
+ @" <param name='movie' value=" + _File + ">"
            
+ @" <param name='quality' value='high'>"
            
+ @"<embed src=" + _File + " quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash'></embed>"
            
+ @" </object>";
        }
    }
}


.aspx:

<asp:Literal ID="Literal1" runat="server"></asp:Literal>

.aspx.cs:

View Code
 protected void Page_Load(object sender, EventArgs e)
    {
        
string file = "Koala.jpg";      
        Swf objSwf 
= new Swf(file);
        
this.Literal1.Text = objSwf.Show();
    }

页面运行结果:


完整代码:http://download.cnblogs.com/insus/ASPDOTNET/SwfShowImage.rar


 

原文地址:https://www.cnblogs.com/insus/p/2048479.html