Blog

  • How to tell the difference between Web 1.0 and Web 2.0

    Even though there is no such thing as Web 2.0, this is still the best comparison I’ve seen. That so made my day… I fell out of my chair laughing. I love the interweb.

    How to tell the difference between Web 1.0 and Web 2.0

    Via The Roman Empire.

  • Automating SWC Creation in Flex 1.5

    Flex was made for true software developers. I apparently am not the target market of said demographic, or have yet to see the benefit of casting off the usage of clicking graphical buttons.

    Suffice it to say, there isn’t a symbol to right click on with an “Export SWC…” in the context menu like in Flash. Since Yahoo! Maps was created this way, however, it must still be good, right?

    A program called “compc.exe” creats SWC’s in Flex. You point it at an MXML or AS file, tell it where your classes root folder is, and tell it what to name the the SWC file. There are a lot more parameters you can use the docs, but those main 3 are all you need to create SWC’s.

    SWC’s are basically .zip files that contain your packaged component, and potentially other assets. They are what jar files are to Java. They can contain non-graphical, compiled assets for portable class libraries, or even images that your component needs to draw itself.

    They are really nice in Flex because you deploy with your app, greatly simplifying the amount of files in your project. Additionally, you can deploy them on the server so all applications on your Flex server compile with the same SWC.

    Since I was constantly testing a component recently, I had to keep remaking the SWC. Here’s a simple script you can paste into Notepad, and save as a .bat file on Windows. Then, all you have to do is double-click the file, and it’ll recompile the SWC for you.

    cd c:\program files\macromedia\flex\bin
    compc -o "C:\mypath\my.swc" "c:\mypath\mymain.as" -root "c:\mypath\"

    Ensure there is a carriage return after the “bin” so the compc part appears on it’s own line.

    You can obviously automate this in other build tools like ANT.

  • Dynamic Icons in a ComboBox

    Wrote this example for a gent on the Flashcoders list. Didn’t want an orphan page on my site, so linking to it from here. Shows how to use a cellrenderer in a ComboBox to show an icon. I should of only changed in the icon in the setValue function if it changed, like so:

    if(lastIcon != item.icon)
    {
       lastIcon = item.icon;
       image_ldr.load(item.icon);
    }

    That would of prevented the flicker you see when you roll over the items. The more I code in Flash, the more I love Flex. Flash is still faster though, no doubt.

    Icon in a ComboBox using a cellrenderer

  • Flex Chronicles #13: One Way to Skin a Button

    I haven’t figured out how to get this dyanamic yet, meaning, loading an image externally that isn’t compiled in. I know it can be done, but alpha bits are tough. Best excuse I have, sorry.

    There some new styles that correspond to skins. I’m still reading and learning, and have seen a CSS example Dirk posted somewhere, but the setStyle way is nice since I’m familiar with the syntax, and if it’s a style, it can be set in CSS, and bound to, etc.

    Here’s an example that uses a PNG, a GIF, and a JPG.

    The key is the style names, as shown here. skin_pb is the name of the Button, img is the pointer to one of the embeded images, and the the rest are the skin style names.

    skin_pb.setStyle("upSkin", img);
    skin_pb.setStyle("selectedUpSkin", img);
    skin_pb.setStyle("selectedOverSkin", img);
    skin_pb.setStyle("selectedDownSkin", img);
    skin_pb.setStyle("selectedDisabledSkin", img);
    skin_pb.setStyle("overSkin", img);
    skin_pb.setStyle("downSkin", img);
    skin_pb.setStyle("disabledSkin", img);
    

    Flex 2 Button Skin – Source ZIP