C# to SWF Flash Compiler

来源:互联网 发布:网站排名优化建设 编辑:程序博客网 时间:2024/04/29 03:54

Today I came across GOA WinForms for Adobe Flash, which allows you to write C# code in Visual Studio 2005 and compile it into a Flash SWF file. I was quite impressed, having been a C# web developer for some time now I thought this is great way to create Flash applications without having to become an expert at Flash or Flex. I have always found it difficult to get my head round the Adode interface for creating flash applications. I downloaded and installed the free version of GOA WinForms for Adobe Flash.

GOA WinForms for Adobe Flash is promoted as:

"GOA WinForms is an implementation of the standard System.Windows.Form .NET library for both Adobe Flash and Microsoft Silverlight. It allows .NET developers to write standard WinForms applications that will run on these two RIA platforms."

There are over 40 samples that can be found in the folder C:/Program Files/NETiKA/GOA WinForms for Flash/samples. I had a good look through the samples; there are plenty of samples to start you off. I tried creating a simple application of my own. Initially it’s easy to forget you are writing code that will be compiled into flash rather than a fully fledged desktop application. I quickly noticed that not all of the System.Windows.Form namespace is implemented, just the bits that relate to what can be done in flash. You still have all of the restrictions of flash. GOA WinForms for Adobe Flash cannot be used with the Visual Studio debugger, this is due to Visual Studio not having access to what is happening inside of the flash SWF.

Sample Hello World: 

The sample loads the text from a flash parameter. It was quite straight forward to create. The compiled SWF file is quite large at 89KB I would expect only a few KB for this sort of thing in flash.

Sample C# Code:

using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms;  namespace GOAApplicationStarter {     public class MyForm : System.Windows.Forms.Form     {         Label label1;         private System.ComponentModel.Container components = null         public MyForm()         {             InitializeComponent();         }          private string GetParam(string name, string defaultValue)         {             AppDomain domain = AppDomain.CurrentDomain;             string paramValue = (string)domain.Parameters[name];              if (paramValue == null            {                 return defaultValue;             }             return paramValue;            }          protected override void Dispose(bool disposing)         {             if (disposing)             {                 if (components != null                {                     components.Dispose();                 }             }             base.Dispose(disposing);         }          private void InitializeComponent()         {             SuspendLayout();              this.label1 = new System.Windows.Forms.Label();             this.label1.Location = new System.Drawing.Point(10, 0);             this.label1.Width = 280;             this.label1.Height = 100;             this.label1.Font =  new System.Drawing.Font(this.label1.Font.FontFamily, 25 );             this.label1.TextAlign =  System.Drawing.ContentAlignment.MiddleLeft;             this.label1.Text = GetParam("label""...");             this.Controls.Add(label1);             this.BackColor = Color.Lime;              ResumeLayout(false);         }          public static void Main()         {             Application.Run(new MyForm());         }     } }  

I do think GOA WinForms for Adobe Flash is defiantly a tool for a specific purpose. It takes some tasks, like animation, that flash is good at and makes then difficult. A lot of tasks can more easily be achieved using Adobe Flash or HTML and AJAX or perhaps even Silverlight. I think in general flash is best saved for interactive components in a web site such as the nice charts in Google Analytics rather than full websites. 
Sunday August 17 2008 07:37 p.m.
本文转自:
http://www.junasoftware.com/blog/c-to-swf-flash-compiler.aspx