4. Insert Shockwave Flash Object
Right-click the Toolbox and Choose "Choose Items..." to add COM Components.
Tricky Point: A Macromedia Flash Factory Object in COM Component is also linked to C: \ Windows \ System32 \ Macromed \ Flash \ Flash9c. ocx, but do not select this Component here. Otherwise, "Failed to import the ActiveX control" may appear. You can use regsvr32.exe Flash9c. ocx registers Flash9c in the command line. ocx control. The following registration success prompt is displayed:
--------------------------------------------------
Http://blogs.msdn.com/ B /jijia/archive/2007/06/07/wpf-flash-activex.aspx
How to embed Flash (ActiveX) in WPF)
Jijia Huang
7 Jun 2007 AM
Background
A recent Partner wants to embed the previous Flash into a brand new WPF Application and.. NET 3.0 rich user experience combined with Flash animation to better serve its users.
Embedding Flash is equivalent to embedding an ActiveX control. Some Tricky points should be noted during the embedding process. The steps for embedding Flash control in WPF Application are briefly described below, and remind you of some issues that need attention.
Development Environment
Visual Studio 2008 Beta1 (Code name: Orcas), Windows Vista, Flash Player 9,
Method
1. Create a WPF Application.
First, create a WPF Application named FlashinWPF
2. Set the Window attribute.
Modify the Window attribute in XAML, add the Loaded event, and set the x: Name of the default Grid to "FlashGrid". The Code is as follows:
<Window x: Class = "FlashinWPF. Window1"
Xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation"
Xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml"
Title = "Flash in WPF" Loaded = "WindowLoaded" Height = "500" Width = "600">
<Grid x: Name = "FlashGrid">
</Grid>
</Window>
3. Create a Windows Forms Control Library
As a display layer project, WPF Application cannot insert COM Component itself. Therefore, you need to use Windows Form to introduce ActiveX control.
4. Insert Shockwave Flash Object
Right-click the Toolbox and Choose "Choose Items..." to add COM Components.
Tricky Point:In COM Component, a Macromedia Flash Factory Object is also linked to C: \ Windows \ System32 \ Macromed \ Flash \ Flash9c. ocx, but do not select this Component here. Otherwise, "Failed to import the ActiveX control" may appear. You can use regsvr32.exe Flash9c. ocx registers Flash9c in the command line. ocx control. The following registration success prompt is displayed:
5. Create a Flash Object
After a Shockwave Flash Object is added, an Object named AxShockwaveFlashObjects is automatically added to the Flash Control project.
The axShockwaveFlash1 object is added by default in UserControl1.Designer. cs.
Private AxShockwaveFlashObjects. AxShockwaveFlash axShockwaveFlash1;
6. Compile Flash Control
7. Add Reference in FlashinWPF
Added AxInterop. ShockwaveFlashObjects. dll compiled in Flash Control.
Add DLL used to integrate ActiveX in Windows Form
Add Windows Form DLL
8. Modify the Codebehind of the Window.
The code and comments of Window1.xaml. cs are as follows:
Private void WindowLoaded (object sender, RoutedEventArgs e)
{
// Create a host Object
System. Windows. Forms. Integration. WindowsFormsHost host = new System. Windows. Forms. Integration. WindowsFormsHost ();
// Instantiate axShockwaveFlash1
AxShockwaveFlashObjects. AxShockwaveFlash axShockwaveFlash1 = new AxShockwaveFlashObjects. AxShockwaveFlash ();
// Load. axShockwaveFlash1
Host. Child = axShockwaveFlash1;
// Embed the host object into FlashGrid
This. FlashGrid. Children. Add (host );
// Set the relative path of the. swf File
String swfPath = System. Environment. CurrentDirectory;
SwfPath + = @ "\ sample.swf ";
AxShockwaveFlash1.Movie = swfPath;
}
9. Add a. swf File
Select Always Copy to Output Directory to use the WPF Applicaiton to call the Flash
10. Success
Click here to download this project file.
Tips
You can use the powerful Object Browser in Visual Studio to view various FlashObjects methods and abstract classes, as shown in
Technorati tags: WPF, Flash, ActiveX, AxHost, AxShockwaveFlashObjects FlashinWPF.zip