Archive for January, 2007

Reading Pixel Colors tutorial uploaded

I just uploaded a new tutorial to gotoandlearn.com that shows how to use the BitmapData class to create an interactive color picker. The BitmapData.getPixel() is used to read the color value from a color picker image. We then take that color and apply it to a little glassy interface box.

Enjoy!
Lee

Should Flash and Flex be combined?

This is something that I have thinking about lately as I work back and forth between Flash, Flex, and WPF. One thing is becoming clear to me lately. I love having the XML markup layer that is present in both Flex and WPF. It makes it much easier to keep a clean separation between the model and the view in data-driven applications. Data binding is another powerful tool that I instantly begin to miss when working in Flash.

Another feature of WPF that I really wish Flash would adopt is the generation of code when drawing graphics in the Flash IDE. It’s great to be able draw graphics in Blend and then immediately be able to see the code that was generated. This allows you to fine-tune properties of the graphic in code. The fact that you will be able to generate XML animation data from the Flash timeline is a great step in this direction.

So let’s say that Flex Builder had the ability to draw graphics and had a timeline for generating XML animations. Would there still be a need for the Flash IDE? One reason that I can think of would be that Flash allows you to create much more optimized code and smaller SWF files. Publishing an empty Flex project is already over 150k in size.

I think Expression Blend is a great example of a tool that could exist in the Flash world. You can create graphics visually and at the same time be able edit the code being generated. You can animate using a timeline which also is generating editable code. Built-in support for data binding and component styling are also nice features to have.

I’m sure that I’m missing a lot of reasons why this wouldn’t be a good idea, but it’s something to think about anyway.

Lee

theFlexBlog.com is now live!

I’m already breaking my New Year’s resolution to not take on too many things at once. But I can’t help it, I’m really loving playing around with Flex. I’m a true believer that blogging about a technology is one of the fastest ways to get good at it. Not only that but it also allows you track your progress and have a single place for experiments and code snippets. My first experiment was to make a Flex version of gotoandlearn.com. Check out the new blog at http://www.theflexblog.com/.

Lee :-)

Does anyone know how to fix this IE 7 Flash bug?

I’m using SWFObject to embed all of my Flash movies now so that it bypasses IE’s stupid “Click to activate” bug. That works great. But why when I click on a link somewhere else on the page does the Flash movie collapse and disappear? A good example of that is when I use JavaScript to open a new window. The new window opens fine but any Flash movies on the original page disappear and collapse.

Does anyone know of fix to this?

Thanks!
Lee

Flash MP3 Player – Part 3

The third and final installment of the Flash MP3 Player tutorials has been uploaded to gotoandlearn.com. This time we incorporate some object-oriented programming concepts to finish off the player. Hope you enjoy it!

Lee

Check out the FuseIDE extension!

Thanks to a trackback link from this blog, I found a great free extension for Flash 8. It is called the FuseIDE and when installed it adds a new panel into Flash that allows you to easily create animations with the excellent Fuse Kit. This is particularly helpful for people new to the kit or people without strong programming skills. There are a couple of different ways to create the Fuse sequences. You can actually create the animations using plain English which is a pretty freaking cool! For people who are more familiar with the kit you can create the sequences using a handy form. Once you are finished with the sequence you can copy the code to the clipboard for easy pasting into your ActionScript code.

Go and check out the extension at http://play.visualcondition.com/fuse/. There is also another extension called FuseXML which I haven’t had a chance to checkout yet.

Happy Fusing!
Lee

ActionScript 3 QuickTip #6: Loading XML

The XML libraries have been completely overhauled in ActionScript 3. It uses a system called ECMAScript for XML (E4X) and is much easier to work with than the current set of tools available in AS 2. The way in which we load external XML files, and any other assets for that matter, into our Flash movies has also changed dramtically. In AS 2 we create an XML object and then call the XML.load() method in order to load in an external file. In AS 3 loading of external XML files is handled by the new URLLoader class. To start with you need to create a new instance of this class like as shown below:

  1. var loader:URLLoader = new URLLoader();

Now that you’ve created the URLLoader, you need to set a listener to receive its complete event which gets fired after the file has finished loading. Here I’m giving a function of loadXML as the receiver for the event.

  1. loader.addEventListener(Event.COMPLETE, loadXML);

Lastly you will need to actually tell the URLLoader to actually start loading in your external XML data. For this we use the URLLoader.load() and pass in a new URLRequest object with string path to the XML file.

  1. loader.load(new URLRequest(“content.xml”));

Now the XML is loading you just need to implement the loadXML function that we used before. We use the event object sent to the function to retrieve the actual data from the loaded file. This can be retrieved using the Event.target.data property. Its this property that we use in the constructor of our XML object. See the full function below:

  1. function loadXML(e:Event):void
  2. {
  3.         xml = new XML(e.target.data);
  4.         trace(xml);
  5. }

Now what you can actually do with the XML data will have to wait for another tip. But this should give you a good idea of how to load in external XML data into your ActionScript 3 projects.

Lee

Next Page »