« September 2005 | Main | January 2006 »

October 17, 2005

ActionScript Projects in Zorn

I've seen some people at the MAX conference get 2400 baud modem speeds while downloading the alpha version of Zorn from the new Macromedia Labs site. Remember that if you're here at the conference, many of us working on Flex have the software on a USB key. We're happy to let you copy the bits and start playing around.

At lunch today, talking with some people who haven't played with Flex, I realized that many people think that Flex is just for big applications. While we do want to do large enterprise apps well, we're certainly trying to help developers create smaller apps as well. And really, really small apps can be created if that's what you need, less than 1k, by just using ActionScript 3.

It's not that I want to promote building just in AS3 over Flex. The framework provides all the components that make life easier, plus I work on the Flex compiler. But for people who just want to play with AS3, need really tiny movies, or want to isolate a problem, I think it's very helpful to be able to write just ActionScript in a project.

I'm sure there's documentation on ActionScript projects, but here's a simple example to illustrate how to do this in Zorn. Create a "New Actionscript Project" and name it "ImageTest". Put a PNG called "myimage.png" in the directory of the project, which defaults to "C:\Documents and Settings\username\My Documents\Flex\ImageTest". Replace the code for ImageTest with this:

package 
{
        import flash.display.MovieClip;
        import flash.display.DisplayObject;

        public class ImageTest extends MovieClip
        {
            [Embed(source="myimage.png")]
            public var embedClass:Class;

            public function ImageTest()
            {
                var embedObj:DisplayObject = new embedClass();
                embedObj.x = 100;
                embedObj.y = 100;
                addChild(embedObj);
            }
        }
}

Then go to "Run > Run", set up a new configuration, and you'll see the image in a movie in the browser. With a png of 805 bytes, this creates a movie of 1,809 bytes for me. Looking at the AS3 and Embed documentation, you'll be able to see all sorts of interesting things you can do with the combination of Embed, DisplayObject, Bitmap, etc.

Posted by Brian at 6:29 PM

October 14, 2005

A Little Info on the Proxy in 1.5

Some more airport blogging. I was going to write an article on the proxy, the part of Flex that is used by HTTPService and RemoteObject to access resources. I never found time to write much about this, though, and I don't see much time clearing up in the weeks ahead. Here's the notes I've jotted down for why you'd want to use the proxy:

1. To have a centralized whitelist or when crossdomain.xml can't be used.
2. When you need to have the text from errors. This doesn't show up without the proxy because the player isn't always given the text from the browser when there's an error status code.
3. When you want custom dialog boxes for security, since the proxy is the only way to do custom authentication/authorization.
4. And there's probably more reasons in 2.0. I don't know much about what's happening in the enterprise offering, but I do know the team has some amazing people on it who have been working like mad.

Posted by Brian at 6:38 PM

J2EE Application Server Support in Flex

Before the deluge of Max, Zorn, Flex and AS3 postings, let me slip a few thoughts out on J2EE application server support. The below won't even be applicable to the 2.0 alpha, since there isn't a server in alpha quite yet. You'll have to wait until the enterprise offering is in alpha to start thinking about the below. So for now this is simply some lovin for all the 1.5 customers.

I often see questions on support for different J2EE application servers. I spent time on both ColdFusion and Flex trying to get various app servers to work correctly, so I've been interested in this subject.

The first thing to do is to see if your app server is supported. You can see the list of supported servers here. If your app server is in the support app server list, then nothing else should be needed! We have QA'd these app servers and we'll answer support questions on these servers. The only time you may need something else is if you are running on ATG Dynamo, which is available via hotfix.

If your app server isn't supported, make sure to search blogs and flexcoders for known issues, as the few issues that are known have been discussed in multiple places. For instance, JBoss is not officially supported but is often asked about. The only issue I've heard about is answered in this message and in other places.

To expand on the JBoss support issue, something that has come up many times, make sure to turn off the unified class loading behavior for the Flex web applications. You can do this by setting loader-repository in jboss-app, as shown here.

I've generally seen things work for unsupported app servers. Flex is written without any native code, and it doesn't interact with the J2EE APIs too much.

The areas that should be looked out for on unsupported app servers:

a. loading of classes- class loading within Java can be tricky, and even trickier to diagnose. If you see a strange ClassCastException or problems on startup, it could be a class loading issue. We've tried to separate Flex from the rest of the app server via our own class loader, which is why most of the jars are in a "jars" directory rather than in "WEB-INF/lib". There's not much that can be done about this issue by yourself, if you do think something is wrong. You can try copying jars from your app server to the "jars" directory or vise versa, but that's really not recommended, as you're likely to break something else. If you're using the samples server, you can also try replacing or removing the axis.jar from WEB-INF/lib, since this jar has caused problems at certain points.

b. webtier compilation- one of the places we interact with the servlet API is through compilation on server. If you don't see SWFs being compiled correctly but can compile them correctly with mxmlc, then this is the problem. I haven't heard of any problems like this that we haven't fixed, but if you suspect a problem, I would compile with mxmlc and place the SWF on the server. You'll miss out on some things if you do this (JSP tag library, ease of development, etc) but it may allow you to work with an unsupported app server.

c. data services- this refers to using RemoteObject or using WebService and HTTPService with the proxy. It's another place where we interact with the app server through the servlet API. It's hard to diagnose this problem if it's occurring with RemoteObject, but for WebService and HTTPService you can set noProxy to true on the tag to determine whether this is the problem. If you are using HTTPService and having problems receiving data, try setting "flex.addFormParameters" to true as a JVM setting. Other than that, you'll have to set noProxy to true or email on flexcoders for help.

d. data service security- if you're using RemoteObject custom authentication, make sure that your app server is supported. See "resources/security/CustomLoginCommand" within your Flex installation for information on setting up custom authentication on an unsupported app server.

The above are the major areas of concern for using Flex with a given unsupported app server. Again, in general I've seen things work fine for unsupported app servers. It is also often hard to tell if a problem is really an issue just on a given app server, but the above can help narrow down the areas where problems could arise.

Posted by Brian at 6:31 PM

October 7, 2005

Did You Hear the News?

Hey, did you hear the news? I'm kidding, as I've seen more posts and more excitement than I imagined on the upcoming alpha of Flex 2. When you have your head down coding for so long, you sometimes lose sight of how all the daily changes being made will be seen.

As long as I'm posting things a little late... I've already welcomed some of them, but a scotch toast to those from iteration::two. I'll be waiting (I'm sure in vain) for Macromedia to send me out to the great city of Edinburgh.

Going to MAX? I'll be there too- feel free to say hello if you see this guy.

Posted by Brian at 9:28 AM