⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 binding.as

📁 如遇MD5加密文件
💻 AS
📖 第 1 页 / 共 2 页
字号:
class mx.data.binding.Binding
{
    var is2way, dest, source, value, format, value2, immediate, binding;
    function Binding(source, dest, format, is2way)
    {
        mx.events.EventDispatcher.initialize(this);
        var _loc5 = this;
        _loc5.source = source;
        _loc5.dest = dest;
        _loc5.format = format;
        _loc5.is2way = is2way;
        mx.data.binding.Binding.registerBinding(this);
        this.calcShortLoc(source);
        this.calcShortLoc(dest);
        _global.__dataLogger.logData(null, "Creating binding " + this.summaryString() + (is2way ? (", 2-way") : ("")), {binding: this});
        ++_global.__dataLogger.nestLevel;
        mx.data.binding.ComponentMixins.initComponent(dest.component);
        if (source.component != undefined)
        {
            mx.data.binding.ComponentMixins.initComponent(source.component);
        } // end if
        dest.component.addBinding(this);
        if (source.component != undefined)
        {
            source.component.addBinding(this);
            this.setUpListener(source, false);
            if (is2way)
            {
                this.setUpListener(dest, true);
                this.setUpIndexListeners(source, false);
                this.setUpIndexListeners(dest, true);
            }
            else
            {
                this.setUpIndexListeners(source, false);
                this.setUpIndexListeners(dest, false);
            } // end else if
        }
        else
        {
            this.execute();
        } // end else if
        --_global.__dataLogger.nestLevel;
    } // End of the function
    function execute(reverse)
    {
        var _loc3;
        var _loc4;
        if (reverse)
        {
            if (!is2way)
            {
                _global.__dataLogger.logData(null, "Warning: Can\'t execute binding " + this.summaryString(false) + " in reverse, because it\'s not a 2 way binding", {binding: this}, mx.data.binding.Log.BRIEF);
                return (["error"]);
            } // end if
            _loc3 = dest;
            _loc4 = source;
        }
        else
        {
            _loc3 = source;
            _loc4 = dest;
        } // end else if
        _global.__dataLogger.logData(null, "Executing binding " + this.summaryString(reverse), {binding: this});
        ++_global.__dataLogger.nestLevel;
        var _loc10;
        if (_loc3.constant != undefined)
        {
            _loc10 = {value: new mx.data.binding.TypedValue(_loc3.constant, "String"), getAnyTypedValue: function ()
            {
                return (value);
            }, getTypedValue: function ()
            {
                return (value);
            }, getGettableTypes: function ()
            {
                return (["String"]);
            }};
        }
        else
        {
            _loc10 = _loc3.component.getField(_loc3.property, _loc3.location, true);
        } // end else if
        var _loc20;
        var _loc16;
        var _loc13 = "";
        var _loc6 = _loc4.component.getField(_loc4.property, _loc4.location);
        if (format != null)
        {
            var _loc5 = mx.data.binding.Binding.getRuntimeObject(format);
            if (_loc5 != null)
            {
                if (reverse)
                {
                    _loc5.setupDataAccessor(_loc4.component, _loc4.property, _loc4.location);
                    _loc5.dataAccessor = _loc6;
                    _loc6 = _loc5;
                }
                else
                {
                    _loc5.setupDataAccessor(_loc3.component, _loc3.property, _loc3.location);
                    _loc5.dataAccessor = _loc10;
                    _loc10 = _loc5;
                } // end if
            } // end if
        } // end else if
        var _loc15 = format == null ? (_loc6.getSettableTypes()) : (null);
        var _loc11 = _loc10.getAnyTypedValue(_loc15);
        var _loc7 = new Object();
        if (_loc6.type.readonly == true)
        {
            _global.__dataLogger.logData(null, "Not executing binding because the destination is read-only", null, mx.data.binding.Log.BRIEF);
            var _loc8 = new Object();
            _loc8.type = "invalid";
            _loc8.property = _loc4.property;
            _loc8.location = _loc4.location;
            _loc8.messages = [{message: "Cannot assign to a read-only data field."}];
            _loc4.component.dispatchEvent(_loc8);
            _loc7.event = _loc8;
        }
        else
        {
            _global.__dataLogger.logData(null, "Assigning new value \'<value>\' (<typeName>) " + _loc13, {value: _loc11.value, typeName: _loc11.typeName, unformattedValue: _loc20, formatterFrom: _loc16});
            var _loc14 = _loc6.setAnyTypedValue(_loc11);
            _loc6.validateAndNotify(_loc7, false, _loc14);
            _loc4.component.dispatchEvent({type: "bindingExecuted", binding: this});
        } // end else if
        if (_loc7.event != null)
        {
            if (_loc3.component != null)
            {
                var _loc9 = new Object();
                _loc9.type = _loc7.event.type;
                _loc9.property = _loc3.property;
                _loc9.location = _loc3.location;
                _loc9.messages = _loc7.event.messages;
                _loc9.to = _loc4.component;
                _loc3.component.dispatchEvent(_loc9);
            } // end if
        } // end if
        --_global.__dataLogger.nestLevel;
        return (_loc7.event.messages);
    } // End of the function
    function queueForExecute(reverse)
    {
        if (!queued)
        {
            if (_global.__databind_executeQueue == null)
            {
                _global.__databind_executeQueue = new Array();
            } // end if
            if (_root.__databind_dispatch == undefined)
            {
                _root.createEmptyMovieClip("__databind_dispatch", -8888);
            } // end if
            _global.__databind_executeQueue.push(this);
            queued = true;
            this.reverse = reverse;
            _root.__databind_dispatch.onEnterFrame = mx.data.binding.Binding.dispatchEnterFrame;
            
        } // end if
    } // End of the function
    static function dispatchEnterFrame()
    {
        _root.__databind_dispatch.onEnterFrame = null;
        for (var _loc4 = 0; _loc4 < _global.__databind_executeQueue.length; ++_loc4)
        {
            var _loc3 = _global.__databind_executeQueue[_loc4];
            _loc3.execute(_loc3.reverse);
        } // end of for
        var _loc5;
        while (_loc5 = _global.__databind_executeQueue.pop(), _global.__databind_executeQueue.pop() != null)
        {
            _loc5.queued = false;
            _loc5.reverse = false;
        } // end while
    } // End of the function
    function calcShortLoc(endpoint)
    {
        var _loc1 = endpoint.location;
        if (_loc1.path != null)
        {
            _loc1 = _loc1.path;
        } // end if
        endpoint.loc = _loc1 instanceof Array ? (_loc1.join(".")) : (_loc1);
    } // End of the function
    function summaryString(reverse)
    {
        var _loc2 = "<binding.dest.component>:<binding.dest.property>:<binding.dest.loc>";
        var _loc3 = "<binding.source.component>:<binding.source.property>:<binding.source.loc>";
        if (source.constant == null)
        {
            if (reverse == true)
            {
                return ("from " + _loc2 + " to " + _loc3);
            }
            else
            {
                return ("from " + _loc3 + " to " + _loc2);
            } // end else if
        }
        else
        {
            return ("from constant \'<binding.source.constant>\' to " + _loc2);
        } // end else if
    } // End of the function
    static function getRuntimeObject(info, constructorParameter)
    {
        if (info.cls == undefined)
        {
            info.cls = mx.utils.ClassFinder.findClass(info.className);
        } // end if
        var _loc3 = new info.cls(constructorParameter);
        if (_loc3 == null)
        {
            _global.__dataLogger.logData(null, "Could not construct a formatter or validator - new <info.className>(<params>)", {info: info, params: constructorParameter}, mx.data.binding.Log.BRIEF);
        } // end if

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -