Compiling XIFF with the Flash IDE - Solution

Hey all,

I’ve been through an incredibly painful process of getting XIFF to compile in the Flash IDE and thought that I’d share what I found in the hope of sparing others the same experience. As most of you probably already know - XIFF3 has moved XIFF from being a general Actionscript Library to being a Flex library. Unfortunately, I was unaware of this change before I opened my big mouth on a project that I’m currently working on and promising Jabber (Open Fire) support in the app which for reasons too lengthy to go into here had to be built in the Flash IDE and not Flex.

Being the proud and stubborn guy that I am, I had to come up with a solution. I chatted with some of the Dave here and he suggested that I grab the specific flex files form the sdk (mx.blah.blah). I just grabbed the whole ‘mx’ folder from the flex 3 sdk and placed it in my project folder. When I attempted this I began getting this error:

No class registered for interface ‘mx.resources::IResourceManager’.

which, I must admit, made me a little sad… After doing some research, I found a way around this as well… Evidently this error has been a problem for flex developers updating projects form Flex 2 to Flex 3 as well as me… The solution is to:

  1. Add these two classes in your Main.as or whatever your Constructor class is:

import flash.system.ApplicationDomain;
import mx.core.Singleton;

  1. Add this as the first line of your application in the Main class constructor function:

var resourceManagerImpl:Object = flash.system.ApplicationDomain.currentDomain.getDefinition(“mx.resources::Resou rceManagerImpl”); Singleton.registerClass(“mx.resources::IResourceManager”, Class(resourceManagerImpl));

After making these changes I tried compiling and was once again a happy developer with a working chat :slight_smile:

Instructions sans attempts at humor:

  1. Copy the mx folder from the flex3sdk - C:\flex3sdk\frameworks\projects\framework\src

1a - If you don’t have it already get it here: http://www.adobe.com/products/flex/flexdownloads/

1b - I have mine here: C:\flex3sdk

  1. Paste it into the same folder as your .fla

  2. Add the following lines to your Main.as (Constructor Class) file:

import flash.system.ApplicationDomain;
import mx.core.Singleton;

  1. Add the following line to your Main.as constructor function:

var resourceManagerImpl:Object = flash.system.ApplicationDomain.currentDomain.getDefinition(“mx.resources::Resou rceManagerImpl”); Singleton.registerClass(“mx.resources::IResourceManager”, Class(resourceManagerImpl));

I also found it to be very helpful to run asdoc (comes with the sdk - command line tool) on the xiff library to get some minimal documentation…

You should be off and running… Good luck!

Phil

not really, I keep on getting a Message saying: ResourceManagerImpl Variable not definied.

the mx-package is in its place, the Singleton Class can be load for example.

Any idea what went wrong?

thx

sebastian

Hmmmm… That is intersting - I was seeing that before I made sure to add:

var resourceManagerImpl:Object = flash.system.ApplicationDomain.currentDomain.getDefinition(“mx.resources::Resou rceManagerImpl”); Singleton.registerClass(“mx.resources::IResourceManager”, Class(resourceManagerImpl));

as the very first line of the constructor function of my Main.as class… I was seeing that when I tried to add this to other classes - say, when I had Chat.as as a sub-class being instantiated in my Main.as class and I tried to add it to that constructor. You also need to be sure to be importing the two other classes:

import flash.system.ApplicationDomain;
import mx.core.Singleton;

into your Main.as as well. To clarify - this has to be the first thing that you do in your application - before any other code runs and not try to do it in another class. I know that this kills (or at least complicates) re-use but it is the only method that I have found that works. I am also assuming that you are working in the CS3 IDE - I should have included that but I no longer have access to anything earlier than that to test this…

If you are still having problems after ensuring that the above are true then post back and I will try to look into it this evening - very busy day right now and will not be able to concentrate on this till then.

Good luck.

Phil

thx for your time,

yes I tried to add it into the constructor of my very first Class file, as well as adding in the main.fla right instead of importing/instantiate the first Class.

The import is also available, if did not import the:

import flash.system.ApplicationDomain;
import mx.core.Singleton;

before you will get errors like:

1120: Access of undefined property Singleton.

the Main Class file just looks like that:

package com.tpw.app.modules.sparkweb.logindialog
{     
     import flash.system.ApplicationDomain;
     import mx.core.Singleton;         public class LoginDialogMain
     {
          public var className:String;
          public var model:Object = null;
          public var view:Object = null;
          public var controller:Object;
          
          public var oMain:Object = null;      public function LoginDialogMain(oMain:* = null)
     {
       var resourceManagerImpl:Object = flash.system.ApplicationDomain.currentDomain.getDefinition("mx.resources::ResourceManagerImpl");
       Singleton.registerClass("mx.resources::IResourceManager", Class(resourceManagerImpl));
       //some more script but certainly executed _after_ the loading
     }
}

while in the main.fla I got only:

import com.tpw.app.modules.sparkweb.logindialog.LoginDialogMain;

var loginDialogMain:LoginDialogMain = new LoginDialogMain(this);

thats it, I’m puzzled

thanks

sebastian

Seb,

I can’t be certain because I don’t have the time to test it right now but I would bet that the problem comes from what you mention last:

import com.tpw.app.modules.sparkweb.logindialog.LoginDialogMain;
var loginDialogMain:LoginDialogMain = new LoginDialogMain(this);

taking place in the .fla.... I don't know but I'd suggest getting that moved into your Main and out of the .fla or comment it
out.....   That is the difference that I see between what I'm doing and what you are.....

So, LoginDialogMain is your your constructor class? Also, you are using CS3?

Best,
Phil

yes the code is already in LoginDialogMain and thats the Main (and only) created/instantiated class in the Main.fla. I tested both, in fla and the Main-Class File. Same results.

Yes I am using CS3 / AS3.

thanks,

sebastian

Seb,

Sorry to hear that - that is odd because it is running completely cleanly in mine - I’m working on a different area of the application right now but I just ran a compile and again, it ran fine, with absolutely no issue.

Another two thoughts and then I really need to get back to it till this evening:

  1. Which version of the XIFF library are you working with - I’m utilizing the beta zip release from the website.

  2. You are sure to have grabbed the mx library from flex 3 and not flex 2 (I’m sure you did - just checking).

Please update if you come to a solution but if I don’t hear back I will try to look into it this evening.

Best,

Phil

yes I use

3.0.0 Beta 1 – April 2nd, 2008

of XIFF

and the lated Flex3SDK copied mx-Classes.

I will now try to export to AIR, as that tshould already Flex components embeded.

but it seems like I got no luck today: http://www.igniterealtime.org/community/message/177685

thanks of course for any advice

tty