English 中文(简体)
单州法院不可撤销的原始功能从未在具有约束力的数据表述中要求
原标题:Bindable getter function of singleton instance never being called in a data binding expression

我有一个单一州级,大致看着类似情况(只有更具有约束性的公共财产):

public class Session extends EventDispatcher
{
    private var _Id:String;
    private static const _instance:Session = new Session( SingletonLock );
    private static const SESSID_CHANGED:String =  SessionIdChanged ;


    public function Session( lock:Class ){
    //SingletonLock is an empty class not available outside this file
        if( lock != SingletonLock ){
            throw new Error("Don t instantiate Session. Use Session.instance");
        }
        _Id = "";

    }

    public static function get instance():Session{
        return _instance;
    }

    // Changes a blob object (from the server xml for sessions) to a session object
    public function updateFromXMLObj(s:ObjectProxy):void
    {
        _instance.Id = s.Id;
    }

    [Bindable(event=SESSID_CHANGED)]
    public function get Id():String{
        return _Id;
    }

    public function set Id(new_id:String):void{
        if(this._Id != new_id){
            this._Id = new_id;
            this.dispatchEvent(new Event(SESSID_CHANGED));
        }
    }

    public function registerOnSessionChange(listener:Function):void{
        addEventListener(SESSID_CHANGED,listener);
    }

    public function unregisterOnSessionChange(listener:Function):void{
        removeEventListener(SESSID_CHANGED,listener);
    }
}

想法是,在一些哺乳动物法典中,我有数据约束性表述,如:

<mx:HTTPService id="homeReq" url="{URLs.homepath(Session.instance.Id)}" ... />

希望在本届会议上更新<代码>homeReq 的索引 变化。 此外,守则的其他部分(行动说明)需要能够在届会时登记其听众。 缩略语

异常的“I m”发现,通过<条码>登记在SessionChange上的活动聆听器的确在会议Id改动时被点名,但具有约束力的数据和元数据交换数据表示没有更新。 我尝试了在捕捉阶段发送活动的所有组合,使其无法取消,但却没有结果。 我对[Bindable(event=......)]的理解是, MXML应当更新在发出具体事件时的舱面,因此,我做了什么错误或误解?

注:我认识到,在《行动说明》中,有多种不同的做法,但除非我这样做的方式实际上造成我的问题,否则我不希望通过讨论替代办法而回避。

问题回答

我认为,{URLs.homepath(Session.instance.Id)} 这对变数不具有约束力,相反,如果你试图做这样的事情,就执行一种物体方法:

[Bindable]
private var _url:*

之后,将初始价值确定为:

_url = {URLs.homepath(Session.instance.Id)};

数据和元数据交换中具有约束力的变量的链接

<mx:HTTPservice id=“homeReq” url=“{_url}”....../>

Then updating the _url variable should automatically update the HTTPService url...

  1. Make an MXML form containing a combobox for course number of 5th semester. On selecting the coruse, display the course name and max marks for the selected course. Data Binding: <mx:Binding>




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Multiple Remote call made simultenously

I was making multiple remote calls and they are done sequentially and when I am getting a result event back it s triggering calls to all the methods with ResultEvent as an argument . I am supposed to ...

Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Clearing RSL in Cache

I have built a flex application which has a "main" project and it is assosciated with a few RSL s which are loaded and cached once i run my "main" application. The problem i am facing is that the ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签