Feeds:
Posts
Comments

Archive for March, 2007

As I was preparing for tutorial of using SharpStyle Neutron to develop an ActionScript project and Windows Forms within one solution, I ran into the following issue: while there are a number of references on the web on how to use Flash OCX within Visual Studio 2003, there are only a handful of results related to Visual Studio 2005 and most of them document the problems that people are having.

Following the steps from this article (Macromedia – Developer Center Embedding Macromedia Flash Player in a C# Application) produce the following errors:

  • There is a popup stating that VS “Failed to import the ActiveX control.  Please ensure it is properly registered
  • If you examine Error List, under Warnings, you will see the following

Could not resolve dependent COM reference “stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”.  

Failed to create the wrapper assembly for type library “AxShockwaveFlashObjects”. Exception of type ‘Microsoft.Build.Tasks.ComReferenceResolutionException’ was thrown.

The referenced component ‘AxShockwaveFlashObjects’ could not be found. Failed to create the wrapper assembly for type library “AxShockwaveFlashObjects”. Exception of type ‘Microsoft.Build.Tasks.ComReferenceResolutionException’ was thrown. 

I found the following Unable to add Flash 8 control in VS2005 – Tentative workaround blog post from 2005-12-07, but the instructions there didn’t work. After doing a few more searches I found the following forum page in French (translated page / original page)

Here is what needs to be done:

  • Open Visual Studio 2005 command prompt and execute the following:
    • aximp.exe -source “C:\WINDOWS\system32\Macromed\Flash\Flash9b.ocx”
  • This will generate the following files. Items in bold are the important ones:
    • AxShockwaveFlashObjects.dll
    • AxShockwaveFlashObjects.pdb
    • ShockwaveFlashObjects.dll
    • AxShockwaveFlashObjects.cs

  • In Visual Studio, add the references to the 2 dlls generated by aximp (I copied them from “C:\Program FIles\Microsoft Visual Studio 8\VC” to the root of the project): 

  • Add namespaces to the imports section

using AxShockwaveFlashObjects;
using ShockwaveFlashObjects;

  • And here is some sample code to display SWF
AxShockwaveFlash axShockwaveFlash = new AxShockwaveFlash();
axShockwaveFlash.Location = new System.Drawing.Point(50, 50);   

this.Controls.Add (axShockwaveFlash);
//this.Show(); // Avoids InvalidActiveXStateException.

axShockwaveFlash.Movie = "D:\\test.swf";
//* it is important to set Size after specifying Movie property
//* if Size is specified before, it is ignored
axShockwaveFlash.Size = new System.Drawing.Size(20, 20);
axShockwaveFlash.Play();
 
References:

~Mike

Read Full Post »

This tutorial will demonstrate how to setup a project in order to easily trace your code.

We will be using Powerflasher SOS.

Powerflasher SOS (SocketOutputServer) is an XML Socket server with a graphic user interface. Connected clients can send messages to SOS. These messages are shown in SOS. Further on commands from SOS to Client can be sent. These are freely configurable.

It requires JavaVM starting from 1.3: http://java.com/en/download/index.jsp

This tutorial will demonstrate the following steps:

  • Download and run Powerflasher SOS
  • Create new ActionScript Application
  • Write code that will allow our application to “trace” to Powerflasher SOS using XMLSocket
  • Specify additional compilation parameter: -trace “Main.myTrace”. Compiler will replace all “trace()” statements with a call to Main.myTrace which will send messages over XMLSocket to SOS
  • We will then add
    • new ActionScript Class
    • two SWF files that will serve as ON/OFF states
  • We will then show the following
    • Loading resources
    • MovieClip.onRollOver, MovieClip.onRollOut events

Source code is here.

Click the image below to launch:

 

Here is the code for your reference:

class Main
{
    private static var sock : XMLSocket;
    static function main()
    {
        Stage.align = "TL";
        Stage.scaleMode = "noScale";
        
        if (_root.enableTrace == "true")
        {
            enableTrace();
        }
        trace("main() called");
        var app : App = new App();
        app.Start();
    }
    private static function enableTrace() : Void
    {
        sock = new XMLSocket();
        sock.connect("localhost", 4444);
        trace("connected");
    }
    public static function myTrace(obj : Object, fullclass : String, file : String, line : Number) : Void
    {
        sock.send("msg: " + obj + " (class: " + fullclass + ", line: " + line + ")\n");
    }
}
 
 
class App
{
    public function App()
    {
        
    }
    public function Start() : Void
    {
        var button : MovieClip = _root.createEmptyMovieClip("button", _root.getNextHighestDepth());
        button._x = 20;
        button._y = 20;
        
        var imageOn : MovieClip = button.createEmptyMovieClip("imageOn", button.getNextHighestDepth());
        imageOn.loadMovie("smiley_happy.swf");
        
        var imageOff : MovieClip = button.createEmptyMovieClip("imageOff", button.getNextHighestDepth());
        imageOff.loadMovie("smiley_sad.swf");
        
        button.onRollOver = function()
        {
            trace("");
            this.imageOff._visible = false;
        }
        
        button.onRollOut = function()
        {
            trace("");
            this.imageOff._visible = true;
        }
    }
}

~Mike

Read Full Post »

This tutorial will demonstrate how to create “resources” SWF that might contain required UI elements and then load them into your ActionScript application.

This tutorial will demonstrate the following steps:

  • Create new Flash Document using Macromedia Flash Professional 8
  • Create new Movie Clip (Linkage: Export for ActionScript, Export in first frame)

  • Add an image and create a simple motion tween
  • Publish to produce SWF
  • Create new ActionScript Application
  • Specify “input SWF” pointing to the produced SWF
  • Show code required to load needed Movie Clip

Source code is here.

Click image below to launch:

Read Full Post »

Clearing Visual Studio recent projects list

Clearing Flash 8 Recent Items list

Read Full Post »

This tutorial will build upon our previous “Hello World ActionScript Application” tutorial.

A few concepts:

  • Please review our previous post for information about swfobject.js and _SwfHtmlTemplate.htm: Files included in default project (Neutron)
  • You might also find the following post useful: SharpStyle Neutron Project Properties
  • This tutorial starts with an existing ActionScript project
  • We will add to the solution an ASP.NET Web Application
  • We will then configure “output path” of the ActionScript project to output compiled SWF into a subfolder of the Web Application
  • We will copy necessary HTML code from _SwfHtmlTemplate.htm into Default.aspx. This will allow us to display SWF

Source files are here.

Click the image below to launch:

 

~Mike

Read Full Post »

AjaxWorld 2007

We attended AjaxWorld 2007 in NY. You can find our posts here:

~Mike

Read Full Post »

Consider viewing a video tutorial that creates a simple “Hello World” ActionScript application using SharpStyle Neutron: Launch Tutorial

This post will describe files that are included in the the default project. I will go through them in the order that it makes it easier to follow, not the order you see on the image

SWFObject is a small Javascript file used for embedding Adobe Flash content. The script can detect the Flash plug-in in all major web browsers (on Mac and PC) and is designed to make embedding Flash movies as easy as possible

  • _SwfHtmlTemplate.htm: customizable HTML file that will embed created SWF. Contains a number of {Tokens} that take their value from Project Properties. You can either modify this file or specify another one within
  • Project Properties : Run screen. Code below shows some of the tokens being used

var so = new SWFObject(“{AsOutputPath}{AssemblyName}.swf”, “swftester”, “{Width}”, “{Height}”, “{TargetVersion}”, “{BackgroundColor}”);

  • Main.as — entry point for your new project. Code provided below:
class Main 
{ 
    // The main entry point for the application. 
    static function main() 
    { 
 
    } 
}

~Mike

Read Full Post »

Older Posts »