I just finished writing a Flex3 library that will allow you to read a great number of image formats using flex and actionscript 3. The component uses a codec like rendering system, so each time you provide it with a source, the codecs attempt one by one to read the file signature and decide which one is fit to decode the image.
So doing this, it won't matter the file extension or the way you provide the image asset (archived, link, base64 encoded, plain text, byteArray or embedded at compile time)
It's a work in progress but curently I've made codecs for the following formats:
- PointLineCAD 3D objects (*.p3d)
- Photoshop images (*.psd, *.pdd)
- ZSoft images (*.pcx)
- Truevision TGA (*.tga, *. icb, *.vda, *.vst, *.win)
- Windows icon files (*.ico)
- GIF images (*.gif – static and animated gifs)
- JPEG images (*.jpg. *.jpeg, *.gfif)
- PNG (Portable network graphic) images (*.png)
- Windows Bitmap images ( *.bmp, *.rle, *.dib)
- Adobe Shockwave Flash (*.swf)
As I said before, the way you provide the source doesn't really matter. You can zip up all your images in an archive and as source you can just point to the file inside the zip.
<adm :ExtendedImage id="img" source="archive.zip://image.png" />
This way, you greatly reduce the number of requests to the server. But this is not all. Source can be also provided as a base64 encoded string, or as plain text (only p3d can take advantage of this since the p3d file is plain text as well).
For those of you who tried but didn't succed, I found some straigthforward instructions for this.
Install cygwin to "c:\cygwin" - make sure to check boxes to install Perl, "Archive" (ZIP), and Devel/gcc:g++ (184.108.40.206 presumably) (is Perl necessary?)
Copy the alchemy directory to: c:\cygwin\home\Lee
Copy the flex sdk bin dir from c:\program files\etc to "c:\flex" (to avoid paths with spaces in it!)
Run the alchemy config script once:
run cygwin cd alchemy ./config
Edit the textfile "C:\cygwin\home\Lee\alchemy\alchemy-setup" and uncomment and edit line 22 to: add "export ADL=c:\flex\adl.exe"
Edit .bashrc (in C:\cygwin\home\Lee)
echo "LEE PROFILE" export FLEX_HOME=~/flex export ALCHEMY_HOME=~/alchemy # "This should be added before your PATH is modified" !! source /home/Lee/alchemy/alchemy-setup PATH=$ALCHEMY_HOME/achacks:/home/Lee/flex:$PATH export PATH alc-on
Do this (just once, I think):
cd $ALCHEMY_HOME/bin ln -s llvm-stub llvm-stub.exe
Compiling a SW:
CD to the directory with the source
Always do "alc-on" before compiling, cuz it doesn't work without it even though i added it to the startup (dunno)
gcc stringecho.c -O3 -Wall -swc -o stringecho.swc -- should give you a swc.
Import the swc into your flex builder 4 project and make sure compiler targets SDK v4
alc-home - takes you to the Alchemy install folder.
alc-on - puts Alchemy gcc toolchain replacements at the front of your path.
alc-off - restores original path.
alc-util - shows you various Alchemy-related environment vars
USEFUL TO KNOW
which gcc - tells you which gcc it will use (should be the one in the achacks dir)
ln - links shit
rm - deletes links as well as files
Ugh: Make sure to do "alc-on" and "alchemy-setup" even though you put it in the startup script 🙁 (?)
I've just started working on a set of Flex components which I call Flex Components Pack. I've only managed to make 11 components till now but I'm still working and have a lot of ideas on my to-do list. If any one of you is willing to help I would be very glad to get an extra brain in here. Just drop me a comment or something and I'll share the road-map and SVN path with you.
(13/06/2009) - Added 5 more components. A simple but nice led light switch and 4 visualisation effects (EQTunnel, EQLine, EQWave, EQBars - winamp style). Just drag and drop the EQ on your app and it will animate any running sound inside your flash.