Category: Development

  • Do you have a class with read only properties?
  • Need to bind to those properties?
  • Getting: warning: unable to bind to property 'propertyName' on class 'com.example.package::ClassName'?

Add the Bindable metatag to your function and specify an event to be associated with it's update.

package com.example.package {
    import flash.events.Event;
    import flash.events.EventDispatcher;
   
    import mx.collections.ArrayCollection;

    public class ClassNameextends EventDispatcher {
        private var _myExposedVar:ArrayCollection;

        public function ClassName() { }

        public function set resultsObject(value:Object):void {
            /* Do Stuff with resultsObject and update _myExposedVar */
            this.dispatchEvent(new Event("ResultsUpdated") );
        }

        [Bindable(event="ResultsUpdated")]
        public function get myExposedVar ():ArrayCollection {
            return this._myExposedVar;
        }

    }
}

Problem solved.

I was trying to access an ColdSpring generated remote facad from Flex this morning when I got this error. It worked just fine by calling CFINVOKE and by calling the CFC directly in the browser. From my flash/flex app it however did not work. I hit my head for several minutes before finding the utmost simple solution.

I have multiple CF instances and it turns out that I did not fully setup the current instance to my liking. So if you see this error, check to make sure that your use-mappings settings is set to true in your services-config.xml file. Flipping this switch resolved my issue.

<use-mappings>true</use-mappings>

This walk through will help you setup Win32 Apache 2.2.x with an SSL test environment using a self signed certificate that I will also show you how to create. I will use my full paths to help with the comprehension.

The post is a bit long, so please [read more] to view the entire walk through

A while ago I posted about some shortcuts I often use in Eclipse. Well this morning I found a new shortcut that I can't believe I never knew about; and while borderline, I deemed it worthy of it's own post!

ALT + UP-ARROW
ALT + DOWN-ARROW

I tend to be an ordering freak and this little gem of simplicity is way better than cutting and pasting. This short-cut key will move any line your cursor is on or any lines you have selected in the direction you press.

Ever wanted to set background colors or border colors based on an image's "theme"? Thats what I needed to do, and I was suprised by how easy it was.

I've created a "SmartImage" that i'm using in my RoundedImage component. When you set the borderStyle to "dynamic" it will use this generated average.
<flash source="/FlexApps/CookBook-DynamicImageBorder/DynamicImageBorder.swf" width="508" height="279" quality="high" scriptAccess="none" align="center" />


Full Source Code for SmartImage. due to an error with my code viewer plugin (that I wrote) it looks like a couple double GT signs got converted. Anything that is a » is really two greater than symbols!
package com.EGPS.toolbox.graphics {
    import flash.display.BitmapData;
    import flash.events.Event;
   
    import mx.controls.Image;
    import mx.events.FlexEvent;

    [Event(name="averageColorUpdated", type="flash.events.Event")]
    public class SmartImage extends Image {
        public static const AVERAGE_COLOR_UPDATED:String = "averageColorUpdated";

        [Bindable]
        public var averageColor:uint;

        public function SmartImage() {
            this.addEventListener(FlexEvent.UPDATE_COMPLETE, updateAverageColor);
            super();
        }

        public function get image():Image {
            return super;
        }

        private function updateAverageColor(event:*):void {
            trace("updateAverageColor: " + event.type + " : " + this.width + "x" + this.height);
            if (this.width == 0 || this.height == 0)
                return;

            var bmpData:BitmapData = new BitmapData(this.width, this.height);
            bmpData.draw(this);

            var r:Number = 0;
            var g:Number = 0;
            var b:Number = 0;
 
            var count:Number = 0;
            var pixel:Number;
 
            for (var x:int = 0; x < bmpData.width; x++) {
                for (var y:int = 0; y « bmpData.height; y++) {
                    pixel = bmpData.getPixel(x, y);
 
                    r += pixel >» 16 & 0xFF;
                    g += pixel »» 8 & 0xFF;
                    b += pixel & 0xFF;
 
                    count++
                }
            }
 
            r /= count;
            g /= count;
            b /= count;

            this.averageColor = r «« 16 | g «« 8 | b;

            this.dispatchEvent(new Event(AVERAGE_COLOR_UPDATED));
        }
    }
}

After writing this post, I found a great example app with maybe not as light weight, but very nice image color extractor! http://blog.soulwire.co.uk/flash/actionscript-3/colourutils-bitmapdata-extract-colour-palette/