| By Bill Wolff | Article Rating: |
|
| September 3, 2005 09:00 AM EDT | Reads: |
25,187 |
An SWF Application provides standard controls such as buttons, labels, and textboxes. An SWF Project is for coded Flash API applications. The Solution Explorer lists the files generated by the template (see Figure 2).
App.xaml is used for general layout and graphic objects. Assemblyinfo.vb has the standard .NET compilation directives. File1.vb is a class file that imports several referenced assemblies (see Figure 3).
These assemblies contain the Xamlon bytecode libraries that match Flash primitives. There must be references to these assemblies in the project (see Figure 4).
The XamlControls library contains controls that are familiar to a Windows Forms or ASP.Net developer. Details can be viewed in the object browser, as shown in Figure 5.
The SwfNative library contains objects that map directly to Flash primitives. One of the most used objects is a MovieClip (see figure 6).
The containing window is referred to as the Canvas. There are multiple layers that render on top of each other. Setting the Z-order produces a layered interface. The Desktop object is used in procedural code to create controls and add them to a layer:
Running this sample creates the window shown in Figure 7
Private Shared Sub CreateSampleWindow()
' create window
Dim window As Window = New Window(200, 80)
window.Text = "Reader Survey"
window.X = 80
window.Y = 10
' add a button
b1 = New Xamlon.Swf.Controls. Button(75, 30)
b1.X = 10
b1.Y = 10
b1.Text = "What do you read?"
' add to window
window.AddChild(b1)
' add window to desktop
desktop.AddChild(window)
' show window
window.Show
End Sub
The size of the window is driven by the XAML declarative markup. The Canvas object has a size:
Button events are coded in typical .NET fashion, including an event handler with one parameter.
<?xml version="1.0"?>
<!-- The width and height of your swf file is set from these -->
<Canvas Width="360" Height="240">
<Canvas.Resources>
</Canvas.Resources>
</Canvas>
This requires some initial set-up. The MovieClip object is used to create a TextField called Con-sole. Writing Console displays the text string at the desired location.
Shared Sub b1_Click(ByVal sender As System.Object) Handles b1.Click
Console.WriteLine(".NET Developers Journal")
End Sub
Pressing the button displays the console text shown in Figure 8.
Public Shared Function CreateConsole()
consoleField = MovieClip.Root. CreateTextField(10, 100, 290, 390, -1)
consoleField.TextColor = &H333333
consoleField.Variable = "Console"
End Function
The project folder contains the solution file, project file, XAML markup, vb class file, and user options(see Figure 9).
The bin folder gets a little busy. There are some resource files, a series of intermediate IL and SWF files, and the compiled exe and swf. The batch file is used for post processing of the compiled .NET MSIL. It has a call to the CWSF compiler.
The HTML file is a testbed for viewing the SWF in a browser. Copy this file, the SWF, and any associated image or movie clips to a Web site. Review the HTML code and copy to your Web application as needed. Here is a sample of the object tag definition:
<object width="100%" height="100%"
classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase-"http://fpdownload.macromedia.com/pub/shockwave/cabs/
flash/swflash.cab#version
<param name-"allowScriptAccess"
value-"sameDomain" />
<param name="movie" value="SwfApplication3.swf" />
<embed width="100%" height="100%"
src="SwfApplication3.swf" allow-ScriptAccess="sameDomain"
type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
Published September 3, 2005 Reads 25,187
Copyright © 2005 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Bill Wolff
Bill Wolff is an independent consultant, trainer, and architect specializing in Microsoft development technologies. His company, Agility Systems, is based in the Philadelphia area. He ran the consulting firm Wolff Data Systems for 15 years and directed armies of consultants in the dot com world. Bill is founder and President of the philly.net user group, board member for INETA (Vice President, Speaker Bureau), and he is active in several other user communities. Bill was a contributing author to several books and articles and he currently writes for .NET Developer's Journal. His certifications include trainer, systems engineer, developer, and Microsoft MVP for VB.NET.
- Kindle 2 vs Nook
- Confessions of a Ulitzer Addict
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Windows 7 – Microsoft’s First Step to the Cloud
- Cloud Expo and the End of Tech Recession
- Jill Tummler Singer, Deputy CIO of CIA, Keynotes at GovIT Expo
- Reality Check at the Cloud Computing Expo
- Visual Studio 2010 Is Cloud Friendly
- Fired SCO CEO Fires Back
- Kindle 2 vs Nook
- The Difference Between Web Hosting and Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Confessions of a Ulitzer Addict
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- Cloud Computing Best Practices
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Ulitzer.com Named Exclusive "New Media" Sponsor of Cloud Computing Conference & Expo
- Infrastructure-as-a-Service Will Mature in 2010: Microsoft's David Chou
- Eval JavaScript in a Global Context
- Windows 7 – Microsoft’s First Step to the Cloud
- Google Maps and ASP.NET
- Crystal Reports XI & How It Has Changed
- Converting VB6 to VB.NET, Part I
- Creating Controls for.NET Compact Framework in Visual Studio 2005
- Where Are RIA Technologies Headed in 2008?
- How to Write High-Performance C# Code
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Implementing Tab Navigation with ASP.NET 2.0
- i-Technology Photo Exclusive: Bill Gates & Steve Jobs In "Nerds"
- .NET Archives: Getting Reacquainted with the Father of C#
- i-Technology Viewpoint: "SOA Sucks"
- Programmatically Posting Data to ASP .NET Web Applications


























