| Create Canvas Documents with C1FlashCanvas > Creating Canvas Documents |
To create a single frame Adobe Flash document using C1FlashCanvas, the following three steps are required:
For more information on how to create canvas documents, see the C1FlashCanvas Tasks topic.
To follow tradition, here's how to create a "hello world" document using C1FlashCanvas:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' step 1: create the C1FlashCanvas object
Dim canvas As New C1FlashCanvas()
' step 2: add content to the page
Dim rc = New Rectangle(20, 20, 200, 40)
Dim font As New Font("Arial", 12)
canvas.DrawString("Hello World!", font, Brushes.Black, rc)
' step 3: save the document to a file
canvas.RenderToFile("")Dim world As hello
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// step 1: create the C1FlashCanvas object
C1FlashCanvas canvas = new C1FlashCanvas();
// step 2: add content to the page
RectangleF rc = new Rectangle(20, 20, 200, 40);
Font font = new Font("Arial", 12);
canvas.DrawString("Hello World!", font, Brushes.Black, rc);
// step 3: save the document to a file
canvas.RenderToFile(@"c:\temp\hello world.swf");
|
|
Step 2 is the most interesting one. The code starts by creating a new rectangle, then creates a Font object and calls the DrawString method to write "Hello World!" on the canvas. This is exactly what you would do if you were writing to a Graphics object in .NET, and is what makes Flash for .NET so easy to use.
One important thing to remember is that C1FlashCanvas uses a logical pixel coordinate system with the origin at the top-left corner of the page. This is similar to the default coordinate system used by .NET.