I don’t discover as many bugs nowadays as I’ve used to in the old days when I was beta testing for Macromedia. But it happened today, and I’ve just installed the newest Flash Player 10.0.22.87 to be sure.

It happens to DisplayObjects A inside DisplayObjectContainers B inside DisplayObjectContainer C, when

  • A was not initially visible (not inside initial scroll rect of C)
  • A is in 3D mode (I just change rotationY for that)
  • B is in «cached as Bitmap» (cacheAsBitmap would do, I go with DropShadowFilter in the example)
  • C’s scrollrect property is set, so A is shows up (well, it doesn’t – that’s the bug after all ;)

Here the example:

bug-3d-shadow.swf
(more…)

Most of the Flash application deal with server side data like images, xml files etc. We tend to forget about that because the default Run or Debug commands in Flex will open a local html file (and also because we developers often have quite a nice internet connection when testing remotely). Thus all data is loaded nearly instantely.

In Flash we have a menu command called «Simulate Download» to see how things run at different bandwidth situations. But how to achieve this in Flex?

I’ve been using Sloppy for a long time. It’s little java app that can be started via a simple web click. It’s really easy to use and does very well what it does. For debugging your app (your flash website) throttled in Flex Builder simply follow these steps:

 

  1. Open the Sloppy website
  2. Click the little Sloppy icon:

  3. A «sloppy.jnlp» file is downloaded. Open it if doesn’t open automatically.
  4. The actual application will be downloaded and started. If it asks you to trust: trust! :-)
  5. Enter the address of your html file in the bin-debug or bin-release folder. It should be a webserver address. I usually create a symbolic link of my project directory and put it into my local webserver directory.
  6. Click «Go» – this will start the Sloppy proxy and open the page in your default browser. 
  7. Copy the address from the browser window (usually http://127.0.0.1:7569/your/path)
  8. You may close the window. Go to Flex Builder and open the project properties (right click on project folder, last item). In an Actionscript Project, switch to ActionScript Build Path.
     
  9. Enter the copied address into «Output folder URL», clear the html name (e.g. App.html).
  10. Click «OK» and you’re done. You can now Run and Debug as if your website was hosted on some server and you had a 256K ADSL connection (instead of your T1).

Note: I tried to automate the whole thing (with Ant of course) and succeeded to a certain limit. What I did was download Sloopy’s source code (java), modify it so it can handle more terminal attributes and build the  .jar file. This can be run on command line, which will start the sloopy server. So I created an ant file that does all that for me, but this ant file would only be cool, if it could also trigger the run or debug commands and modify the output folder url. I haven’t found a way (at least not a satisfying one) to do this, so I might just follow the manual street for once ;)

Another note: If you are windows user, you might wanna try this Firefox plugin: Firefox Throttle

I figured a much much easier (compared to this) way to trigger Test Movie in Flash IDE from within Flex. What you’ll still need is Ant (here’s how to install), but that’s all you gonna need apart from Flex Builder and Flash. That’s the simplest ant build file to achieve this:

< ?xml version="1.0" encoding="UTF-8"?>
<project name="Publish" default="Publish" basedir="./">
	<!-- project specifics -->
	<target name="Publish">
		<concat destfile="build.jsfl">
			fl.getDocumentDOM().testMovie();
		</concat>
		<exec executable="open" failonerror="true" logerror="true">
			<arg line="build.jsfl" />
		</exec>
		<delete file="build.jsfl" />
	</target>
</project>

This tests the frontmost document in Flash IDE. (basically what does this plugin). Tested on Mac OS X 10.5.5 with Flex Builder Pro 3.0.2 and Flash CS4.

No need for FlashCommand. No need to alter the file for other projects. Just a super easy file for people with not too many requirements.

You can still go more advanced with something like that:
(more…)

Update: I’ve found an easier way without FlashCommand

Once you got used to developing for Flash in Flex Builder, you hate to do any programming in Flash IDE. Still you sometimes might have to: Flex Builder won’t allow to publish into a FLA file. (There are of course many other reasons, like supporting older AS1/AS2 projects, we don’t go into that here.) Thanks to Eclipse’s ability to be customized, there are ways to make things at least a little easier. I give here a little overview of how I’ve set up my environment, based on several helpful resources I’ve found in the web.

  1. Install FlashCommand
  2. Install Ant

And for each project:

  1. Create/modify Ant file
  2. Create Actionscript project
  3. Set up project and FLA file

(more…)

I did a lot of string parsing in the recent time: CSS Selectors, XML Display Objects, Stylesheets, … I also need XML selection from String expressions – I formerly (AS2) used the great XPath4AS2 from XFactorStudio which did it’s job well (though a bit slow, it’s AS2 after all).

There’s also one for Actionscript 3 (xpath-as3). But.. well… I wanted to go for some real speed! I like XPath a lot, but we now have native E4X selection in Actionscript 3, quite a different concept of node selection, and the conversion of XPath to E4X obviously results in quite a compromise in performance.

So all I need is a decent E4X parser. And hey, I found one! E4XParser from Digital Primates. It does its job really well, especially considering the very compact code it consists of. Thanks to some preparsing and caching, it’s also quite fast.

Still I thought I can do better :-) So I planted myself for a day (and a night) in front of my displays and hacked the hell out of it. The result is a little library which does pretty much the same thing as E4XParser, though pretty much more and a little faster too (15% to 50%). It’s about half as fast as the native E4X selection (once parsed). You can do nearly anything you can do with E4X. Use it like this:

 

import com.betabong.xml.e4x.E4X;
var result : XMLList = E4X.evaluate( xmllist , "author.( name.@last == 'Jobs' )" );
 
// E4X.evaluate( source : XMLList , expression : String ) : XMLList

 
If your source is XML, just do XMLList( xml ), if your result should be xml, do xml = result[0]

Test it here

Restrictions: You can’t use AND/OR in comparisions. So, this won’t go: author.( name.@first == ‘Steve’ && name.@last == ‘Jobs’ ) – though this is only a real limitations for OR. do this for AND: author.( name.@first == ‘Steve’ ).( name.@last == ‘Jobs’ ).

What you can do: Yes, you can do quite advanced stuff like author.( name.@first == name.@last ) or car.@rating.average() (one of the few proprietary functions I added). Or even

*..car.( @brand.toLowerCase() == 'volvo' ).( parent().( localName() == 'group' ).@rating > @rating )

– a weird example, I admit, but fancy, ain’t it? :-)

This is the first time ever I’m releasing part of my library as Open Source (MIT licence). As soon as I’ll find some time (and if I see any interest), I’m gonna put this into Google Code, so everybody can easily checkout and participate. Until then download it from here:

Download (zip 13kb)

Weak references are cool. No. they are substantial. I don’t know how we lived without them before. Anyway, they made our (we = flash developers) life better. I use them very often, when adding event listeners or caching with dictionaries (and I’m sure I’d use them even more often if there was any more possibilty provided).

Still you can struggle over unexpected behaviour. (more…)

It doesn’t happen that often that I see stuff that amazes me from a professional and private perspective in so many ways. Well, it happened today when I saw:

http://code.google.com/creative/radiohead/viewer.html (Flash)

http://code.google.com/creative/radiohead/ (see video in better quality, making of and more…)