My Links
Post Categories
Archives
- May, 2008 (1)
- March, 2008 (3)
- February, 2008 (2)
- January, 2008 (1)
- November, 2007 (2)
- October, 2007 (3)
- August, 2007 (1)
- July, 2007 (10)
- June, 2007 (3)
- May, 2007 (7)
- April, 2007 (1)
- February, 2007 (1)
- January, 2007 (6)
- December, 2006 (2)
- November, 2006 (1)
- August, 2006 (1)
- July, 2006 (1)
- February, 2006 (1)
- January, 2006 (6)
- November, 2005 (1)
- October, 2005 (1)
- September, 2005 (1)
- August, 2005 (2)
- July, 2005 (2)
- May, 2005 (1)
- March, 2005 (7)
- February, 2005 (4)
- January, 2005 (2)
- December, 2004 (1)
- November, 2004 (1)
- October, 2004 (3)
- September, 2004 (2)
- August, 2004 (6)
- July, 2004 (2)
- June, 2004 (2)
- May, 2004 (4)
- April, 2004 (2)
- March, 2004 (3)
- November, 2003 (8)
- October, 2003 (13)
|
Note: this post still seems to get tons of hits, and I do get a lot of requests for the source as well. This project was merged into the xamlon project, and is now rotting on some backup disks somewhere : ). There is a new C# parser if that is what brought you here you can read about it here . Not planning to go to swf with it, but feel free... Also, there is NeoSwiff if you are looking for C# to swf, from all I have heard it is an awesome product. Back to the old post...
So I finally finished a long month of work (er, the real work that is) and have been able to get back to the C# compiler this week. I've made a first 'test' pass at generating swf bytecode from csharp input, and it works pretty good -- hey, even the bugs are working! It takes this code and makes this swf. The current generated bytecode is as Actionscript Viewer friendly as possible (world's best tool btw!). The code is not efficient at all, there's not even constant folding yet. The next version will be very different though - you can really optimize with all the info a C# file gives up... Try it here if you like.
It just uses stub code now for the flash access part (just a few drawing API commands, and a fake console), but that should end up being a pretty clean library. Maybe 'unsafe' code is overkill for that (that was plan A), a Swf.Native namespace that called each one with a (params object) arg list might be enough. The idea being almost no one would use that, everyone would use the level above. Eg: new Movieclip() or new Button() which would look much like a pared down windows forms class (modeled on the compact framework I think). On the visual side, the graphics/timelines are all parsing/generating (from/to swf, svg and emf), though I do have some work on fonts iirc, and other things I'm sure. Huge amount of glue work too (that is combining, not sniffing). The graphics are all stored in an 'meta' graphics format I call 'sma' (simple media abstraction) and the code is all stored in the CSharp Dom from the compiler. It will be possible to generate swf, svg, and .net files from the same code, eventually...
While you technically don't need the Microsoft csc compiler to use this, my compiler supplies virtually no error info. Of course maybe you don't make mistakes when you program. What I do (the bat file is set up for this) is compile in csc first, then if there aren't errors, convert the same C# code to an swf, and if that went ok, launch the swf to view. It only handles single files at this point, that is just a mechanics thing as I finish that part, but just to know...
Overloading (const & method) is working, though I'm not yet differentiating between long/int/uint, nor float/double (there are only ints and reals). Static members, are working (maybe only on methods and fields). Enums work, though I haven't written Attribute classes, which keeps the [Flags] attribute from compiling. Arrays and jagged arrays, are in, but could still be buggy. Then the usual expressions/stmts etc. A lot of things I thought were going to be problematic ended up being not too hard. It is amazing how much easier it is when you have access to all the metadata in advance (eg - max number of params that will be used in all the possible overloads, etc).
On the 'not in yet' side is inheritance... I think I can just use the prototype inheritance, though I'm debating writing custom super code or not. Shouldn't be hard anyway. Also missing (and most requiring some custom code), events, delegates, using, goto/labels, indexers, operator overloads, structs (hmm), try/catch, as/is (some type reflection stuff is in though), ref/out, and attributes. More I'm sure, that is just on the current todo list.
Bugs are VERY easy to find at the moment ; ). Maybe in a few weeks I'll get some kind of bug list going, but until then there would be no point in mentioning ones you find unless they seem major. If you find this super crappy please wait a bit, it will get much more solid within the month (this is basically the first three days of swf bytecode gen).
Oh, and you can download it here, it works on the cs file, and you can run it by clicking the bat file.. Requires .Net of course, ideally the csc compiler as well. Did I mention it is full of bugs?
posted on Monday, July 12, 2004 6:39 AM
SWF... Preview"
trackback:ping="http://blog.debreuil.com/services/trackbacks/314.aspx" />
-->
Feedback
-
# re: C# --> SWF... Preview
Posted @ 7/12/2004 7:53 AM
This is really awesome...Robin I mean it..
Now I can write in CSharp and generate SWFs, GOD this is great.
cheers,
Abdul
-
# re: C# --> SWF... Preview
Posted @ 7/13/2004 2:20 AM
Hey, Good Job. I have been using Macromedia Flash SDK for long but this is the first C# library I have found for developing SWF. Not to mention similarities, both have bugs ;)
Are you planning to add ActionScript support too??
Thanks
Naseem Amjad
-
# re: C# --> SWF... Preview
Posted @ 7/13/2004 2:35 AM
Hey Abdul,
Congrats on the big win[1], that is a really cool app. Great example of how useful and useable a web app can be. Hope there was some cash in the clash ; ).
[1] http://www.zdnetindia.com/flashclash/
-
# re: C# --> SWF... Preview
Posted @ 7/13/2004 2:41 AM
Hi Naseem,
There are a ton of bugs at the moment, or more exactly parts that just haven't been addressed. It is going good though, I'm just finishing the inheritance parts tonight, next up events. Hopefully by the end of the week it will be more useable (though by no means finished ;).
I never really used the SDK, but I heard different things about it. I guess it was usable at least then? I'm just glad the docs are so much improved from those days!
-
# re: C# --> SWF... Preview
Posted @ 7/13/2004 2:46 AM
Oh, and no plans for AS support, but maybe Java eventually...
-
# re: C# --> SWF... Preview
Posted @ 7/13/2004 11:09 AM
i love you.... this is really cool, appreciate all the hard work youve put in... out of curiosity.. are doing anything for swf -> c#?
or parsing a as code in a swf?
nik
nik@nuthing.com
-
# re: C# --> SWF... Preview
Posted @ 7/14/2004 5:48 AM
This is amazing!
I think you've got something very interesting going there, Robin.
I'm really looking forward to the beta version!
cheers,
till
-
# re: C# --> SWF... Preview
Posted @ 7/14/2004 10:30 AM
This is amazing!
Good Work!!!
-
# re: C# --> SWF... Preview
Posted @ 7/15/2004 2:37 PM
Robin, you did it! ... you da man :)
-
# re: C# --> SWF... Preview
Posted @ 7/15/2004 4:10 PM
Hey Florian,
Well unicode and reals just got 200% better thanks to your most helpful advice, so at the moment there is only one 'da man' in this house (and he is you : ).
-
# re: C# --> SWF... Preview
Posted @ 7/15/2004 4:12 PM
Hey Nik,
I've been thinking a lot about if/how/why with swf or actionscript back into this, still not sure... At first I thought no, but working with it a bit I can see that might be pretty useful too : ). Maybe opinions?
-
# re: C# --> SWF... Preview
Posted @ 7/16/2004 3:36 AM
nah... just a little research in the framework docs ;) It´s so cool to see this is really working. If you can compile C#, you can compile ObjectPascal, Basic, Java... everything to swf.
Imho, AS2 was only a proof of concept that you can compile any language to swf bytecode :)
-
# re: C# --> SWF... Preview
Posted @ 7/16/2004 5:34 AM
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.FormatException: Input string was not in a correct format.
at System.Number.ParseDouble(String s, NumberStyles style, NumberFormatInfo info)
at System.Double.Parse(String s, NumberStyles style, IFormatProvider provider)
at DDW.CSharp.Parse.RealLiteral.GetGraph(RealLiteral graph)
at DDW.CSharp.Parse.RealLiteral.GetGraph()
at DDW.CSharp.Parse.PrimaryExpression.ParsePrimaryExpr(Expression tok)
at DDW.CSharp.Parse.Expression.Parse(Expression tok)
at DDW.CSharp.Parse.Declarator.GetGraph(DeclaratorCollection graph)
at DDW.CSharp.Parse.VariableDeclStmt.GetGraph(VariableDeclStmt graph)
at DDW.CSharp.Parse.VariableDeclStmt.GetGraph()
at DDW.CSharp.Parse.Statement.ParseStatement(Statement tok)
at DDW.CSharp.Parse.Statements.GetGraph(StatementCollection graph)
at DDW.CSharp.Parse.MethodNode.GetGraph(MethodDecl graph)
at DDW.CSharp.Parse.MethodNode.GetGraph()
at DDW.CSharp.Parse.Members.GetGraph(MemberDeclCollection graph)
at DDW.CSharp.Parse.TypeNode.GetGraph(TypeDecl graph)
at DDW.CSharp.Parse.ClassNode.GetGraph(ClassDecl graph)
at DDW.CSharp.Parse.ClassNode.GetGraph()
at DDW.CSharp.Parse.Types.GetGraph(TypeDeclCollection graph)
at DDW.CSharp.Parse.NamespaceNode.GetGraph(NamespaceDecl graph)
at DDW.CSharp.Parse.NamespaceNode.GetGraph()
at DDW.CSharp.Parse.CompileUnit.GetGraph(CompileUnit graph)
at DDW.CSharp.Parse.CompileUnit.GetGraph()
at DDW.CSharpUI.CSharpViewer.AddFile(String filename)
at DDW.CSharpUI.CSharpViewer.menuItem5_Click(Object sender, EventArgs e)
at System.Windows.Forms.MenuItem.OnClick(EventArgs e)
at System.Windows.Forms.MenuItemData.Execute()
at System.Windows.Forms.Command.Invoke()
at System.Windows.Forms.Control.WmCommand(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
************** Loaded Assemblies **************
mscorlib
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/microsoft.net/framework/v1.1.4322/mscorlib.dll
----------------------------------------
CSharpUI
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/GRAPH/Bureau/csswf_prev/csswf.exe
----------------------------------------
CSharp
Assembly Version: 0.0.0.0
Win32 Version: 0.0.0.0
CodeBase: file:///C:/Documents%20and%20Settings/GRAPH/Bureau/csswf_prev/CSharp.DLL
----------------------------------------
antlr.runtime
Assembly Version: 2.7.2.10
Win32 Version: 2.7.2.10
CodeBase: file:///C:/Documents%20and%20Settings/GRAPH/Bureau/csswf_prev/antlr.runtime.DLL
----------------------------------------
SmaConverter
Assembly Version: 1.0.1654.6599
Win32 Version: 1.0.1654.6599
CodeBase: file:///C:/Documents%20and%20Settings/GRAPH/Bureau/csswf_prev/SmaConverter.DLL
----------------------------------------
System.Windows.Forms
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.windows.forms/1.0.5000.0__b77a5c561934e089/system.windows.forms.dll
----------------------------------------
System
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system/1.0.5000.0__b77a5c561934e089/system.dll
----------------------------------------
Sma
Assembly Version: 1.0.1654.6599
Win32 Version: 1.0.1654.6599
CodeBase: file:///C:/Documents%20and%20Settings/GRAPH/Bureau/csswf_prev/Sma.DLL
----------------------------------------
System.Drawing
Assembly Version: 1.0.5000.0
Win32 Version: 1.1.4322.573
CodeBase: file:///c:/windows/assembly/gac/system.drawing/1.0.5000.0__b03f5f7f11d50a3a/system.drawing.dll
----------------------------------------
************** JIT Debugging **************
To enable just in time (JIT) debugging, the config file for this
application or machine (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.
For example:
<configuration>
<system.windows.forms jitDebugging="true" />
</configuration>
When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the machine
rather than being handled by this dialog.
-
# re: C# --> SWF... Preview
Posted @ 7/26/2004 3:37 PM
This is *very good*!! Having used the SDK released from Macromedia, and fighting the C++ compiler, I gave up. Writing in C# will make it that much easier. I am very much a novice to Flash, but have quite a bit of experience with c#.
I looked at the preview you have on the site. It looks like the Swf library commands are pretty limited at the moment, but are well on the way. I could see how much of a pain it would be to try to map System.Drawing or any UI to the Swf command set, so going with a native namespace.
Are you planning on incorporating the "using" directive to link in other components from other compiled .swf (or other format) files (maybe by using the ImportAssets and ExportAssets from the Flash Control Tags)? I could definately see doing that if you did not want to imbed as much in the compiler. I guess the tough part would be getting the compiler to understand how to "read" the files in addition to writing them.
BTW, did I mention how great this is!? Keep up the good work!
-
# re: C# --> SWF... Preview
Posted @ 7/26/2004 8:18 PM
Yeah, the Swf library has just been a stub for testing for now. I'm just finishing a new way of accessing native calls using Attributes. Basically a native method goes in the Swf.Native namespace, and has an SwgGen attrib that takes the real name as an arg, like so:
[SwfGen("attachMovie")]
public void AttachMovie(
string idName,
string newName,
int depth){}
[SwfGen("attachMovie")]
public void AttachMovie(
string idName,
string newName,
int depth,
object initObject){}
I will rewrite access classes to that to fit into the .Net style, and then a higher level API accessing that. That should look a lot more like normal .net framework classes. Eg. A Form class that only uses Movieclip as a paint surface, etc.
As for 'using', I have that in now as well, but it is only for compiling multiple projects into a single swf. I'm thinking '/reference' on the compiler switch would be conceptually how you get access to other swfs. That part isn't in yet, but the rest is now running with multiple files/compile units, so it shouldn't be too big of job. Referencing swfs that were created in flash etc will be harder, as it will require generating some sort of stub files in order to be able to compile...
I was ready to go last monday with the next release, but the duct tape wasn't holding the type attribution part together very well, so I spent the last week trying to make that part more sensible. It is now working again, and allowing rewrites for optimization. I have to test the new swf lib system and write some more challenging test files. Hopefully I can have a better release out in the next few days, though the gen'd swfs will still be a bit, um, long winded : ).
I can't repo that bug two posts above but a few people have sent it in - it is something with intl text. I've changed that around a bit, I think it should be fixed, but it would be great if someone with intl windows could give it a test..? I have a copy of Japanese XP here, I really have to put that on a machine to keep me honest -- intl text is pretty well taken care of with .Net, but that lulls you into a false sense of security too...
|
|
Blog Stats
- Posts - 121
- Stories - 1
- Comments - 1441
- Trackbacks - 47
.Net Blogs
01101 Blogs
Flash Blogs
Graphics
People
|
|