incubator-flex-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Left Right <olegsivo...@gmail.com>
Subject Re: [jira] [Updated] (FLEX-51) Please check support for ExactValue initializer
Date Wed, 25 Apr 2012 07:59:06 GMT
> Are you saying the compiler doesn't determine what the change events for
> each token in the chain?  That would definitely be "very far from
reality".

That is some different sort of parsing, it is not based strictly on AS3
grammar, it doesn't contribute to the parse tree generation in the end. In
order to generate parse tree you need to know everything about the lexical
environment you are adding a node to, at that point compiler cannot
possibly know it because the AS3 code that is a part of the environment is
not yet generated. In other words, parse trees are generated on the way
from AS3 to bytecode, not on the way from MXML to AS3.

Below is an example, which illustrates some cases when parsing of the
binding will fail to determine what change events it should listen to:

package actionscript
{
import flash.display.BlendMode;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
import flash.utils.describeType;
 import mx.events.PropertyChangeEvent;
 public class BindingChecker extends EventDispatcher
{
[Bindable("propertyChange")]
public function get mode():String
{
// this getter is called only once, when component is set up, but never
again
trace("updating binding");
return this._newMode;
}
 private var _oldMode:String;
 private var _newMode:String;
 private var _modes:Array;
 public function BindingChecker(target:IEventDispatcher = null)
{
super(target);
this._newMode = this.getMode();
super.addEventListener(Event.ENTER_FRAME, this.enterFrameHandler);
}
 private function enterFrameHandler(event:Event):void
{
this._oldMode = this._newMode;
this._newMode = this.getMode();
super.dispatchEvent(
PropertyChangeEvent.createUpdateEvent(
this, "mode", this._oldMode, this._newMode));
}
 private function getMode():String
{
if (!this._modes)
{
this._modes = [];
for each (var mode:XML in describeType(BlendMode).constant.@name)
this._modes.push(BlendMode[mode.toString()]);
}
return this._modes[int(Math.random() * this._modes.length)];
}
}
}
==== using it ====
<mx:UIComponent blendMode="{this.getModes().mode}"/>
<fx:Script>
<![CDATA[
import actionscript.BindingChecker;
 private var _checker:BindingChecker;
 public function getModes():IEventDispatcher
{
if (!this._checker) this._checker = new BindingChecker(this);
return this._checker;
}
]]>
</fx:Script>

But it is not limited to this situation.

Best.

Oleg

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message