| Flash for .NET Task-Based Help > C1FlashMovie Tasks > Creating Movie Documents that Rotate |
This topic demonstrates how to generate a movie using the C1FlashMovie class.
After completing the following tasks, run your application, save the canvas to a SWF file, and launch it in Internet Explorer. Here is a frame-by-frame representation of the animation that will appear in Internet Explorer:
| Rectangles 1 (orange/black), 2 (red/black), and 3 (white/orange) | Rotate Rectangle 3 |
![]() |
![]() |
| Text appears | Text falls off to the lower-right |
![]() |
![]() |
To determine the location of each rectangle, add the following code to the Form_Load event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' top-left rectangle Dim rect1 As New FRectangle(0 * Constants.TWIPS, 0 * Constants.TWIPS, 300 * Constants.TWIPS, 300 * Constants.TWIPS) ' middle rectangle Dim rect2 As New FRectangle(50 * Constants.TWIPS, 50 * Constants.TWIPS, 200 * Constants.TWIPS, 200 * Constants.TWIPS) ' bottom-right rectangle Dim rect3 As New FRectangle(100 * Constants.TWIPS, 100 * Constants.TWIPS, 100 * Constants.TWIPS, 100 * Constants.TWIPS) |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// top-left rectangle FRectangle rect1 = new FRectangle( 0 * Constants.TWIPS, 0 * Constants.TWIPS, 300 * Constants.TWIPS, 300 * Constants.TWIPS ); // middle rectangle FRectangle rect2 = new FRectangle( 50 * Constants.TWIPS, 50 * Constants.TWIPS, 200 * Constants.TWIPS, 200 * Constants.TWIPS ); // bottom-right rectangle FRectangle rect3 = new FRectangle( 100 * Constants.TWIPS, 100 * Constants.TWIPS, 100 * Constants.TWIPS, 100 * Constants.TWIPS ); |
|
To fill each rectangle and determine the depth of each rectangle, call the FillGradientColor method and Depth property. Add the following code to the Form_Load event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' set rect1 to radial-fill orange-black rect1.FillGradientColor(Color.Orange, Color.Black, True) ' set rect3 to radial-fill red-black rect2.FillGradientColor(Color.Red, Color.Black, True) ' set rect3 to radial-fill orange-white rect3.FillGradientColor(Color.Orange, Color.White, False) ' set rect1 in depth 1 (at bottom) rect1.Depth = 1 ' set rect2 in depth 2 (in the middle) rect2.Depth = 2 ' set rect3 in depth 3 (on top of all) rect3.Depth = 3 |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// set rect1 to radial-fill orange-black rect1.FillGradientColor( Color.Orange, Color.Black, true ); // set rect3 to radial-fill red-black rect2.FillGradientColor( Color.Red, Color.Black, true ); // set rect3 to radial-fill orange-white rect3.FillGradientColor( Color.Orange, Color.White, false ); // set rect1 in depth 1 (at bottom) rect1.Depth = 1; // set rect2 in depth 2 (in the middle) rect2.Depth = 2; // set rect3 in depth 3 (on top of all) rect3.Depth = 3; |
|
To place rectangles 1 and 2 on frame one, and make rectangle 3 rotate by itself, use the AddObject and RemoveObject methods. Add the following code to the Form_Load event:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
' "add" rect1 and rect2 to frame1(this.C1FlashMovie1 dictionary), then "place" them on frame1 Me.C1FlashMovie1.Frames(0).AddObject(rect1) Me.C1FlashMovie1.Frames(0).AddObject(rect2) Me.C1FlashMovie1.Frames(0).AddObject(rect3) ' rect3 is rotating by itself. Me.C1FlashMovie1.Frames(1).RemoveObject(rect3) rect3.Rotate(22.5F) Me.C1FlashMovie1.Frames(1).AddObject(rect3) Me.C1FlashMovie1.Frames(2).RemoveObject(rect3) rect3.Rotate(45F) Me.C1FlashMovie1.Frames(2).AddObject(rect3) Me.C1FlashMovie1.Frames(3).RemoveObject(rect3) rect3.Rotate(67.5F) Me.C1FlashMovie1.Frames(3).AddObject(rect3) Me.C1FlashMovie1.Frames(4).RemoveObject(rect3) rect3.Rotate(90F) Me.C1FlashMovie1.Frames(4).AddObject(rect3) |
|
To write code in C#
| C# |
Copy Code
|
|---|---|
// "add" rect1 and rect2 to frame1(this.c1FlashMovie1 dictionary), then "place" them on frame1 this.c1FlashMovie1.Frames(0).AddObject( rect1 ); this.c1FlashMovie1.Frames(0).AddObject( rect2 ); this.c1FlashMovie1.Frames(0).AddObject( rect3 ); // rect3 is rotating by itself this.c1FlashMovie1.Frames(1).RemoveObject( rect3 ); rect3.Rotate(22.5F); this.c1FlashMovie1.Frames(1).AddObject( rect3 ); this.c1FlashMovie1.Frames(2).RemoveObject( rect3 ); rect3.Rotate(45F); this.c1FlashMovie1.Frames(2).AddObject( rect3 ); this.c1FlashMovie1.Frames(3).RemoveObject( rect3 ); rect3.Rotate(67.5F); this.c1FlashMovie1.Frames(3).AddObject( rect3 ); this.c1FlashMovie1.Frames(4).RemoveObject( rect3 ); rect3.Rotate(90F); this.c1FlashMovie1.Frames(4).AddObject( rect3 ); |
|
To add moving text, call the FEditText constructor. Add the following code in the Form_Load event handler:
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Dim [text] As New FEditText(New Rectangle(100 * Constants.TWIPS, 100 * Constants.TWIPS, 300 * Constants.TWIPS, 80 * Constants.TWIPS), "Hello World!", "Arial", False, False)
[text].ReadOnly = True
[text].NoSelect = True
[text].Height = 20 * Constants.TWIPS
[text].AutoSize = True
[text].ForeColor = Color.SkyBlue
Dim i As Integer
For i = 5 To 29
[text].ForeColor = Color.White
[text].Depth = CType(i, System.UInt16)
[text].Translate(i * 10 * Constants.TWIPS, i * 10 * Constants.TWIPS)
Me.C1FlashMovie1.Frames(i).AddObject([text])
' Remove the frame later in the timeline. Note you need to remove it now,
' since every time the AddObject is called, the object Id changes. But
' you can remove in the future, which is what is happening here.
If i < 30 Then
Me.C1FlashMovie1.Frames((i + 1)).RemoveObject([text])
End If
Next i
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
FEditText text = new FEditText(new Rectangle(100 * Constants.TWIPS, 100 * Constants.TWIPS,
300 * Constants.TWIPS, 80 * Constants.TWIPS), "ComponentOne Hello World!", "Arial", false, false);
text.ReadOnly = true;
text.NoSelect = true;
text.Height = 20 * Constants.TWIPS;
text.AutoSize = true;
text.ForeColor = Color.SkyBlue;
for(int i = 5; i < 30; i++)
{
text.ForeColor = Color.White;
text.Depth = (ushort)i;
text.Translate(i * 10 * Constants.TWIPS, i * 10 * Constants.TWIPS);
this.c1FlashMovie1.Frames( i ).AddObject( text );
// Remove the frame later in the timeline. Note you need to remove it now,
// since every time the AddObject is called, the object Id changes. But
// you can remove in the future, which is what is happening here.
if ( i < 30 )
this.c1FlashMovie1.Frames( i+1 ).RemoveObject( text );
}
|
|
To write code in Visual Basic
| Visual Basic |
Copy Code
|
|---|---|
Me.C1FlashMovie1.RenderToFile("c:\WindowsApplication1.swf")
LaunchViewer("C:\WindowsApplication1.swf")
|
|
To write code in C#
| C# |
Copy Code
|
|---|---|
this.c1FlashMovie1.RenderToFile(@"c:\WindowsApplication1.swf"); LaunchViewer(@"C:\WindowsApplication1.swf"); |
|