C# to ActionScript tutorial
In this tutorial you will learn what must be done to start developing actionscript applications in c# with the jsc compiler. Jsc enables you to write your code in c# and it will be compiled into actionscript for you.
Post your questions at
google groups.
Read my blog at
wordpress.
Visit
jsc homepage.
View
the result of this tutorial.
Written by Arvo Sulakatko 2008 April.
You can skip some steps if you have already installed the software needed.
Step 1: Visual Studio
Install
Visual Studio 2008 C# Express Edition. ~60mb

Step 2: Flex
Download
Free Adobe Flex SDK. ~75mb
Choose
c:\util\flex\ as the target location.
Flex requires
Java Runtime. Download and install it.
Step 3: jsc
Download
jsc. ~2mb
Choose
c:\util\jsc\ as the target location.
Step 4: Project Templates
Copy the project templates from
C:\util\jsc\templates\ to
My Documents\Visual Studio 2008\Templates\ProjectTemplates\.
In this tutorial we only need
OrcasFlashApplication template.
Step 5: New Project
Run
Microsoft Visual C# 2008 Express Edition and open the new project dialog and create a new project.

Step 6: Debug Interface Access SDK
UPDATE: jsc can now be compiled without DIA support. To compile with DIA support WITH_DIA conditional constant should be defined.
More about DIA
here.
As there seems to be no public download, you should delete all
.pdb files at
c:\util\jsc\bin\ and disable debug info output. Otherwise jsc will try to load DIA to get variable names and if you do not have DIA installed it will just try to guess.
Step 7: Some fixups
We need to change the
tools/mxmlc.bat file to target the installed flex SDK.
We need to change the
tools/jsc.bat file to target current project.

Enable
Show advanced build configurations option
.
Select the
Debug build and add a post build event.
Step 8: Build
Build the project.
My output looks like this:
------ Rebuild All started: Project: OrcasFlashApplication1, Configuration: Debug Any CPU ------C:\Windows\Microsoft.NET\Framework\v3.5\Csc.exe /noconfig /nowarn:1701,1702 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:..\..\..\..\..\..\..\util\jsc\bin\ScriptCoreLib.dll /reference:..\..\..\..\..\..\..\util\jsc\bin\ScriptCoreLib.Query.dll /reference:..\..\..\..\..\..\..\util\jsc\bin\ScriptCoreLibA.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug- /filealign:512 /optimize- /out:obj\Debug\OrcasFlashApplication1.dll /resource:web\assets\AlphaTest\Preview.png,OrcasFlashApplication1.web.assets.AlphaTest.Preview.png /resource:web\assets\AlphaTest\rain_1.mp3,OrcasFlashApplication1.web.assets.AlphaTest.rain_1.mp3 /target:library ActionScript\Assets.cs ActionScript\OrcasFlashApplication.cs ActionScript\Extensions.cs Properties\AssemblyInfo.cs IAssemblyReferenceToken.cs Compile complete -- 0 errors, 0 warningsOrcasFlashApplication1 -> C:\Users\predator\Documents\Visual Studio 2008\Projects\OrcasFlashApplication1\OrcasFlashApplication1\bin\Debug\OrcasFlashApplication1.dllpushd ..\..\toolscall build.batpopdC# to JavaScript by Arvo Sulakatko 2008zproxy.wordpress.com, jsc.sourceforge.netCopyright © 2008, All rights reservedCurrent Path: C:\Users\predator\Documents\Visual Studio 2008\Projects\OrcasFlashApplication1\OrcasFlashApplication1\bin\Debugassembly: file:///c:/util/jsc/bin/ScriptCoreLib.DLLassembly: file:///c:/util/jsc/bin/ScriptCoreLib.Query.DLLassembly: file:///C:/Users/predator/Documents/Visual Studio 2008/Projects/OrcasFlashApplication1/OrcasFlashApplication1/bin/Debug/OrcasFlashApplication1.dllwill compile 'c:\util\jsc\bin\ScriptCoreLib.dll'found 103 types to be compiledScriptCoreLib.ActionScript.Extensions.flash.events.__EventDispatcher -> Extensions.flash.events.__EventDispatcherScriptCoreLib.ActionScript.BCLImplementation.System.__Object -> BCLImplementation.System.__ObjectScriptCoreLib.ActionScript.BCLImplementation.System.__Exception -> BCLImplementation.System.__ExceptionScriptCoreLib.ActionScript.BCLImplementation.System.__NotSupportedException -> BCLImplementation.System.__NotSupportedExceptionScriptCoreLib.ActionScript.BCLImplementation.System.__Math -> BCLImplementation.System.__MathScriptCoreLib.ActionScript.Query.InternalSequenceImplementation -> Query.InternalSequenceImplementationpdb not found c:\util\jsc\bin\ScriptCoreLib.pdbScriptCoreLib.ActionScript.BCLImplementation.System.__String -> BCLImplementation.System.__StringScriptCoreLib.ActionScript.BCLImplementation.System.__NotImplementedException -> BCLImplementation.System.__NotImplementedExceptionScriptCoreLib.ActionScript.BCLImplementation.System.__ArgumentNullException -> BCLImplementation.System.__ArgumentNullExceptionScriptCoreLib.Shared.Query.SZArrayEnumerator`1 -> Query.SZArrayEnumerator`1ScriptCoreLib.ActionScript.BCLImplementation.System.Collections.__IEnumerable -> BCLImplementation.System.Collections.__IEnumerableScriptCoreLib.ActionScript.BCLImplementation.System.__Random -> BCLImplementation.System.__RandomScriptCoreLib.ActionScript.BCLImplementation.System.Collections.Generic.__ICollection`1 -> BCLImplementation.System.Collections.Generic.__ICollection`1ScriptCoreLib.ActionScript.Extensions.flash.text.__TextField -> Extensions.flash.text.__TextFieldScriptCoreLib.ActionScript.BCLImplementation.System.__Action -> BCLImplementation.System.__ActionScriptCoreLib.ActionScript.BCLImplementation.System.__Action`1 -> BCLImplementation.System.__Action`1ScriptCoreLib.ActionScript.BCLImplementation.System.__Action`2 -> BCLImplementation.System.__Action`2ScriptCoreLib.ActionScript.BCLImplementation.System.__Action`3 -> BCLImplementation.System.__Action`3ScriptCoreLib.ActionScript.Extensions.flash.ui.__ContextMenuItem -> Extensions.flash.ui.__ContextMenuItemScriptCoreLib.ActionScript.BCLImplementation.System.Collections.Generic.__IEnumerable`1 -> BCLImplementation.System.Collections.Generic.__IEnumerable`1ScriptCoreLib.ActionScript.BCLImplementation.System.Text.__StringBuilder -> BCLImplementation.System.Text.__StringBuilderScriptCoreLib.ActionScript.BCLImplementation.System.__Delegate -> BCLImplementation.System.__DelegateScriptCoreLib.ActionScript.BCLImplementation.System.__IntPtr -> BCLImplementation.System.__IntPtrScriptCoreLib.ActionScript.BCLImplementation.System.Collections.Generic.__List`1 -> BCLImplementation.System.Collections.Generic.__List`1ScriptCoreLib.ActionScript.BCLImplementation.System.Collections.Generic.__List`1+__Enumerator -> BCLImplementation.System.Collections.Generic.__List`1+__EnumeratorScriptCoreLib.ActionScript.Extensions.flash.display.__DisplayObject -> Extensions.flash.display.__DisplayObjectScriptCoreLib.ActionScript.BCLImplementation.System.__MulticastDelegate -> BCLImplementation.System.__MulticastDelegateScriptCoreLib.ActionScript.BCLImplementation.System.__Convert -> BCLImplementation.System.__ConvertScriptCoreLib.ActionScript.BCLImplementation.System.Collections.__IEnumerator -> BCLImplementation.System.Collections.__IEnumeratorScriptCoreLib.ActionScript.Extensions.flash.util.__Timer -> Extensions.flash.util.__TimerScriptCoreLib.ActionScript.Extensions.CommonExtensions -> Extensions.CommonExtensionsScriptCoreLib.ActionScript.Extensions.CommonExtensions+IFill_Dispose -> Extensions.CommonExtensions+IFill_DisposeScriptCoreLib.ActionScript.BCLImplementation.System.Collections.Generic.__IList`1 -> BCLImplementation.System.Collections.Generic.__IList`1ScriptCoreLib.ActionScript.BCLImplementation.System.Collections.Generic.__IEnumerator`1 -> BCLImplementation.System.Collections.Generic.__IEnumerator`1ScriptCoreLib.ActionScript.Extensions.flash.display.__InteractiveObject -> Extensions.flash.display.__InteractiveObjectScriptCoreLib.ActionScript.BCLImplementation.System.__IDisposable -> BCLImplementation.System.__IDisposableactionscript type compiler - 3973mswill compile 'c:\util\jsc\bin\ScriptCoreLib.Query.dll'found 137 types to be compiledScriptCoreLib.ActionScript.Query.DefinedError -> Query.DefinedErrorpdb not found c:\util\jsc\bin\ScriptCoreLib.Query.pdbScriptCoreLib.ActionScript.Query.__Enumerable -> Query.__EnumerableScriptCoreLib.ActionScript.Query.__Enumerable+_SelectIterator_d__b`2 -> Query.__Enumerable+_SelectIterator_d__b`2ScriptCoreLib.ActionScript.Query.__Enumerable+_SelectManyIterator_d__37`3 -> Query.__Enumerable+_SelectManyIterator_d__37`3ScriptCoreLib.ActionScript.Query.__Enumerable+_SelectManyIterator_d__16`2 -> Query.__Enumerable+_SelectManyIterator_d__16`2ScriptCoreLib.ActionScript.Query.__Enumerable+_RangeIterator_d__91 -> Query.__Enumerable+_RangeIterator_d__91ScriptCoreLib.ActionScript.Query.__Enumerable+_WhereIterator_d__0`1 -> Query.__Enumerable+_WhereIterator_d__0`1ScriptCoreLib.ActionScript.Lambda.LambdaExtensions -> Lambda.LambdaExtensionsScriptCoreLib.ActionScript.Lambda.YFunc`2 -> Lambda.YFunc`2ScriptCoreLib.ActionScript.Lambda.YFunc`3 -> Lambda.YFunc`3ScriptCoreLib.ActionScript.Lambda.YAction`1 -> Lambda.YAction`1ScriptCoreLib.ActionScript.Lambda.YAction`2 -> Lambda.YAction`2ScriptCoreLib.ActionScript.BCLImplementation.System.__Func`1 -> BCLImplementation.System.__Func`1ScriptCoreLib.ActionScript.BCLImplementation.System.__Func`2 -> BCLImplementation.System.__Func`2ScriptCoreLib.ActionScript.BCLImplementation.System.__Func`3 -> BCLImplementation.System.__Func`3ScriptCoreLib.ActionScript.BCLImplementation.System.__Func`4 -> BCLImplementation.System.__Func`4ScriptCoreLib.ActionScript.BCLImplementation.System.__Func`5 -> BCLImplementation.System.__Func`5ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass1 -> Lambda.LambdaExtensions+<>c__DisplayClass1ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass4`1 -> Lambda.LambdaExtensions+<>c__DisplayClass4`1ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass7`2 -> Lambda.LambdaExtensions+<>c__DisplayClass7`2ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClassa`3 -> Lambda.LambdaExtensions+<>c__DisplayClassa`3ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClassd`3 -> Lambda.LambdaExtensions+<>c__DisplayClassd`3ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass10`2 -> Lambda.LambdaExtensions+<>c__DisplayClass10`2ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass13`3 -> Lambda.LambdaExtensions+<>c__DisplayClass13`3ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass16`2 -> Lambda.LambdaExtensions+<>c__DisplayClass16`2ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass19`4 -> Lambda.LambdaExtensions+<>c__DisplayClass19`4ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass1c`3 -> Lambda.LambdaExtensions+<>c__DisplayClass1c`3ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass1f`2 -> Lambda.LambdaExtensions+<>c__DisplayClass1f`2ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass22 -> Lambda.LambdaExtensions+<>c__DisplayClass22ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass25`1 -> Lambda.LambdaExtensions+<>c__DisplayClass25`1ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass28`2 -> Lambda.LambdaExtensions+<>c__DisplayClass28`2ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass2b`3 -> Lambda.LambdaExtensions+<>c__DisplayClass2b`3ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass2e`1 -> Lambda.LambdaExtensions+<>c__DisplayClass2e`1ScriptCoreLib.ActionScript.Lambda.LambdaExtensions+<>c__DisplayClass31`2 -> Lambda.LambdaExtensions+<>c__DisplayClass31`2actionscript type compiler - 3511mswill compile 'C:\Users\predator\Documents\Visual Studio 2008\Projects\OrcasFlashApplication1\OrcasFlashApplication1\bin\Debug\OrcasFlashApplication1.dll'found 138 types to be compiledpdb not found C:\Users\predator\Documents\Visual Studio 2008\Projects\OrcasFlashApplication1\OrcasFlashApplication1\bin\Debug\OrcasFlashApplication1.pdbOrcasFlashApplication1.ActionScript.OrcasFlashApplication1actionscript type compiler - 176ms- OrcasFlashApplication1Loading configuration file C:\util\flex\frameworks\flex-config.xmlRecompile: C:\Users\predator\Documents\Visual Studio 2008\Projects\OrcasFlashApplication1\OrcasFlashApplication1\bin\Debug\web\OrcasFlashApplication1\ActionScript\OrcasFlashApplication1.asReason: The source file or one of the included files has been updated.Files changed: 1 Files affected: 0OrcasFlashApplication1.swf (936 bytes)========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========Step 9: Test with flash player
Open your
OrcasFlashApplication1.swf with
C:\util\flex\runtimes\player\win\FlashPlayer.exe.
Step 10: Write Some New Code
Create just a textfield and attach an event which will display
hello world. Then build your project.

Test it with flash player.

Click on the text.
Watch it online
here.