Monday 17 October 2011

Trace all events of a component

override public function dispatchEvent(event:Event):Boolean
{
  trace(event.type);
  return super.dispatchEvent(event);
}

Wednesday 12 October 2011

Remove items from Flex ArrayCollection

var alerts:ArrayCollection = new ArrayCollection();

for (var i:int = alerts.length; i > 0; i--)
{
   var alert:Alert = alerts.getItemAt(i-1) as Alert;
   if (alert.parentName == parentName)
   {
      alerts.removeItemAt(i-1);
   }
}

Note: alerts.length is initialized once and thus does not vary, on the contrary of:

for (var i:int =0; i < alerts.length; i++)

Monday 10 October 2011

Friday 7 October 2011

Flex Client - Jcaps JMS messaging-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<service id="message-service" class="flex.messaging.services.MessageService">

    <adapters>
            <adapter-definition id="jms" class="flex.messaging.services.messaging.adapters.JMSAdapter" />
    </adapters>

    <default-channels>
        <channel ref="my-polling-amf" />
    </default-channels>

    <destination id="jcapsBefund">
        <adapter ref="jms" />
        <properties>
            <jms>
                <destination-type>Topic</destination-type>
                <message-type>javax.jms.TextMessage</message-type>
                <connection-factory>connectionfactories/topicconnectionfactory</connection-factory>
                <destination-jndi-name>topics/tOibbefundFromSpacelab</destination-jndi-name>
                <delivery-mode>NON_PERSISTENT</delivery-mode>
                <message-priority>DEFAULT_PRIORITY</message-priority>
                <acknowledge-mode>AUTO_ACKNOWLEDGE</acknowledge-mode>
                <initial-context-environment>
                    <property>
                        <name>Context.INITIAL_CONTEXT_FACTORY</name>
                        <value>com.stc.jms.jndispi.InitialContextFactory</value>
                    </property>
                    <property>
                        <name>Context.PROVIDER_URL</name>
                        <value>stcms://blabla.uhbs.ch:12345</value>
                    </property>
                    <property>
                        <name>Context.SECURITY_PRINCIPAL</name>
                        <value>Hello</value>
                    </property>
                    <property>
                        <name>Context.SECURITY_CREDENTIALS</name>
                        <value>World</value>
                    </property>
                </initial-context-environment>
            </jms>
        </properties>
    </destination>
</service>

Thursday 6 October 2011

Flex Binding Example

    [Bindable]
    public class Configuration extends EventDispatcher
    {
        public static const URL_CHANGED:String = "urlChanged";
       
        private var _host:String;
        private var _port:String;
        private var _context:String;
       
        public function Configuration(host:String, port:String, context:String)
        {
            this.host = host;
            this.port = port;
            this.context = context;
        }
       
        public function get host():String
        {
            return _host;
        }
       
        public function set host(value:String):void
        {
            _host = value;
            dispatchEvent(new Event(URL_CHANGED));
        }
       
        public function get port():String
        {
            return _port;
        }
       
        public function set port(value:String):void
        {
            _port = value;
            dispatchEvent(new Event(URL_CHANGED));
        }
       
        public function get context():String
        {
            return _context;
        }
       
        public function set context(value:String):void
        {
            _context = value;
            dispatchEvent(new Event(URL_CHANGED));
        }

        // DO NOT USE the URL_CHANGED constant

        [Bindable(event="urlChanged")]
        public function get url():String
        {
            return "http://" + host + ":" + port + "/" + context + "/messagebroker/amfpolling";
        }