Highlighted

Issues with removing Flex data binding to use Air 14

Participant ,
Jul 28, 2014

Copy link to clipboard

Copied

Hello,

I was wondering if anyone had optimal solution for replacing the Flex data binding classes in Air 14. I'm unable to merge the Flex and Air SDK together anymore so all the binding handlers need to be replaced. Has anyone else run into this issue yet? The automated binding generation and handling was the best feature of Flex and now that it's broken it creates huge issues for me.

This is for Air desktop and mobile applications. They still build just no of the event handling works.

Cheers,

Pete

I had forgotten I solved this myself last Dec. So basically from what I can tell the precompiler no longer does any [Bindable] conversions so you have to manually create the getters and setters for your model when this changes. I hope this helps anyone who may run into the same problem. There's literally no documentation on this any wheres.

i.e.

[Bindable]

public var username : String;

becomes

private var _username : String;

    

        [Bindable(event="propertyChange")]

        public function get username():String

        {

            return this._serviceState;

        }

    

        public function set username(value:String):void

        {

            var oldValue:Object = this._username;

            if (oldValue !== value)

            {

                this._username = value;

                if (this.hasEventListener("propertyChange"))

                    this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "username", oldValue, value));

            }

        }

You also need to make sure what ever class contains this property implements IEventDispatcher and has the following functions:

//IEventDispatcher implementation
//
private var _bindingEventDispatcher:flash.events.EventDispatcher =
new flash.events.EventDispatcher(flash.events.IEventDispatcher(this));
/**
  * @inheritDoc
  */
public function addEventListener(type:String, listener:Function,
  useCapture:Boolean = false,
  priority:int = 0,
  weakRef:Boolean = false):void
{
_bindingEventDispatcher.addEventListener(type, listener, useCapture,
priority, weakRef);
}
/**
  * @inheritDoc
  */
public function dispatchEvent(event:flash.events.Event):Boolean
{
return _bindingEventDispatcher.dispatchEvent(event);
}
/**
  * @inheritDoc
  */
public function hasEventListener(type:String):Boolean
{
return _bindingEventDispatcher.hasEventListener(type);
}
/**
  * @inheritDoc
  */
public function removeEventListener(type:String,
listener:Function,
useCapture:Boolean = false):void
{
_bindingEventDispatcher.removeEventListener(type, listener, useCapture);
}
/**
  * @inheritDoc
  */
public function willTrigger(type:String):Boolean
{
return _bindingEventDispatcher.willTrigger(type);
}
TOPICS
Development

Views

180

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Issues with removing Flex data binding to use Air 14

Participant ,
Jul 28, 2014

Copy link to clipboard

Copied

Hello,

I was wondering if anyone had optimal solution for replacing the Flex data binding classes in Air 14. I'm unable to merge the Flex and Air SDK together anymore so all the binding handlers need to be replaced. Has anyone else run into this issue yet? The automated binding generation and handling was the best feature of Flex and now that it's broken it creates huge issues for me.

This is for Air desktop and mobile applications. They still build just no of the event handling works.

Cheers,

Pete

I had forgotten I solved this myself last Dec. So basically from what I can tell the precompiler no longer does any [Bindable] conversions so you have to manually create the getters and setters for your model when this changes. I hope this helps anyone who may run into the same problem. There's literally no documentation on this any wheres.

i.e.

[Bindable]

public var username : String;

becomes

private var _username : String;

    

        [Bindable(event="propertyChange")]

        public function get username():String

        {

            return this._serviceState;

        }

    

        public function set username(value:String):void

        {

            var oldValue:Object = this._username;

            if (oldValue !== value)

            {

                this._username = value;

                if (this.hasEventListener("propertyChange"))

                    this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "username", oldValue, value));

            }

        }

You also need to make sure what ever class contains this property implements IEventDispatcher and has the following functions:

//IEventDispatcher implementation
//
private var _bindingEventDispatcher:flash.events.EventDispatcher =
new flash.events.EventDispatcher(flash.events.IEventDispatcher(this));
/**
  * @inheritDoc
  */
public function addEventListener(type:String, listener:Function,
  useCapture:Boolean = false,
  priority:int = 0,
  weakRef:Boolean = false):void
{
_bindingEventDispatcher.addEventListener(type, listener, useCapture,
priority, weakRef);
}
/**
  * @inheritDoc
  */
public function dispatchEvent(event:flash.events.Event):Boolean
{
return _bindingEventDispatcher.dispatchEvent(event);
}
/**
  * @inheritDoc
  */
public function hasEventListener(type:String):Boolean
{
return _bindingEventDispatcher.hasEventListener(type);
}
/**
  * @inheritDoc
  */
public function removeEventListener(type:String,
listener:Function,
useCapture:Boolean = false):void
{
_bindingEventDispatcher.removeEventListener(type, listener, useCapture);
}
/**
  * @inheritDoc
  */
public function willTrigger(type:String):Boolean
{
return _bindingEventDispatcher.willTrigger(type);
}
TOPICS
Development

Views

181

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 28, 2014 0
Participant ,
Jul 28, 2014

Copy link to clipboard

Copied

I had forgotten I solved this myself last Dec. So basically from what I can tell the precompiler no longer does any [Bindable] conversions so you have to manually create the getters and setters for your model when this changes. I hope this helps anyone who may run into the same problem. There's literally no documentation on this any wheres.

i.e.

[Bindable]

public var username : String;

becomes

private var _username : String;

    

        [Bindable(event="propertyChange")]

        public function get username():String

        {

            return this._serviceState;

        }

    

        public function set username(value:String):void

        {

            var oldValue:Object = this._username;

            if (oldValue !== value)

            {

                this._username = value;

                if (this.hasEventListener("propertyChange"))

                    this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "username", oldValue, value));

            }

        }

You also need to make sure what ever class contains this property implements IEventDispatcher and has the following functions:

//IEventDispatcher implementation
//
private var _bindingEventDispatcher:flash.events.EventDispatcher =
new flash.events.EventDispatcher(flash.events.IEventDispatcher(this));
/**
  * @inheritDoc
  */
public function addEventListener(type:String, listener:Function,
  useCapture:Boolean = false,
  priority:int = 0,
  weakRef:Boolean = false):void
{
_bindingEventDispatcher.addEventListener(type, listener, useCapture,
priority, weakRef);
}
/**
  * @inheritDoc
  */
public function dispatchEvent(event:flash.events.Event):Boolean
{
return _bindingEventDispatcher.dispatchEvent(event);
}
/**
  * @inheritDoc
  */
public function hasEventListener(type:String):Boolean
{
return _bindingEventDispatcher.hasEventListener(type);
}
/**
  * @inheritDoc
  */
public function removeEventListener(type:String,
listener:Function,
useCapture:Boolean = false):void
{
_bindingEventDispatcher.removeEventListener(type, listener, useCapture);
}
/**
  * @inheritDoc
  */
public function willTrigger(type:String):Boolean
{
return _bindingEventDispatcher.willTrigger(type);
}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 28, 2014 0