|
|
Create Swf Flash Movie from C# - Create-Button
Flash swf File Size: 1.34 KB
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using eMarkASFLib;
public partial class aspx_flash_csharp_createbutton : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Buffer = true;
Response.CacheControl = "private";
// Create flash movie object
Movie movie = new Movie();
// Set the stage size and background-color of flash movie
movie.SetSize (600, 229);
movie.SetBackgroundColorEx ("#FFD700");
// Use a color object
Color color1 = new Color();
color1.ColorString = "#FFFFFF";
Color color2 = new Color();
color2.ColorString = "red";
// Create flash objects and create four button shape for four button status of up, over, hit, down
FlashObject obj = new FlashObject();
obj.CreatePolygon (20, 50);
obj.AddPolygonLineTo (20,200);
obj.AddPolygonLineTo (200, 50);
obj.AddPolygonLineTo (20, 50);
obj.LineWidth = 4;
obj.SetRadialFill (color1, color2);
FlashObject obj2 = new FlashObject();
obj2.CreatePolygon (20, 50);
obj2.AddPolygonLineTo (20,200);
obj2.AddPolygonLineTo (200, 50);
obj2.AddPolygonLineTo (20, 50);
obj2.LineWidth = 4;
obj2.SetRadialFill (color2, color1);
// Create action object to set the button action
Action action = new Action();
action.GetURL ("http:'www.emarksoft.com", "blank");
//ActionConditions enum
{
| OverDownToIdle |
= 1, |
| IdleToOverDown |
= 2, |
| OutDownToIdle |
= 3, |
| OutDownToOverDown |
= 4, |
| OverDownToOutDown |
= 5, |
| OverDownToOverUp |
= 6, |
| OverUpToOverDown |
= 7, |
| OverUpToIdle |
= 8, |
| IdleToOverUp |
= 9 |
};
// Create the button using the four shape
FlashObject btn = new FlashObject();
btn.CreateButton (obj, obj2, obj, obj2);
btn.QueueEvent(action, eMarkASFLib.eMarkASFButtonActionConditions.emRollOut);
movie.AddObject (btn, 0);
obj.CreateOval (250,70,550,210);
obj.LineWidth = 0;
obj.SetRadialFill (color1, color2 );
obj2.CreateOval (250,70,550,210);
obj2.LineWidth = 0;
obj2.SetRadialFill (color2, color1);
color2.ColorString = "blue";
// Create another button without action
FlashObject obj3 = new FlashObject();
obj3.CreateOval (250,70,550,210);
obj3.LineWidth = 0;
obj3.SetRadialFill (color1, color2);
FlashObject obj4 = new FlashObject();
obj4.CreateOval (250,70,550,210);
obj4.Linewidth = 0;
obj4.SetRadialFill (color2, color1);
btn.CreateButton (obj4, obj3, obj2, obj);
movie.AddObject (btn, 0);
// Output the swf binary data to browser directly
Response.ContentType = "application/x-shockwave-flash";
Response.BinaryWrite ((byte[])movie.Content);
// Free all objects
obj.Free();
obj2.Free();
obj3.Free();
obj4.Free();
movie.Free();
}
}
|

|
|
|
|