actionscript 3 - closures with popups using flex 4.6 -


I have this custom event handler that shows popups and accepts input from user:

  Private var mySkinnablePopupContainer: MySkinnablePopupContainer; Private function handleHogriGipopEvent (Event: Shugrid popupAvent): zero {varMouseDownOutSideHandler: Function = function (MDEvent: FlexMSEvent): Nil {// At this point, event.targetControl contains the wrong object (usually the last target control) (if mdEvent. RelatedObject! = Event.targetControl) {mySkinnablePopupContainer.close (); }} Var GridPoption Choice Handler: Function = Function (PopEvent: Popup Event): Zero {if (PopEvent Codeit) is returned; // At this point, the wrong object in event.targetData (usually the previous target data) is myModel.doSomethingWithData (popEvent.data.selectedItem, event.targetData); } If (! MySkinnablePopupContainer) {mySkinnablePopupContainer = New MySkinnablePopupContainer (); MySkinnablePopupContainer.addEventListener (popup event.CLOSE, GridPoppsectionHandler); MySkinnablePopupContainer.addEventListener (FlexMouseEvent.MOUSE_DOWN_OUTSIDE, mouseDownautSideHandler); } // At this point, the correct object in event.targetData is mySkinnablePopupContainer.dataProvider = getMyDPArrayCollection (event.targetData); mySkinnablePopupContainer.open (this); Var point: point = event.targetControl.localToGlobal (new point ()); MySkinnablePopupContainer.x = point.x + event.targetControl.width - mySkinnablePopupContainer.width; MySkinnablePopupContainer.y = point.y + event.targetControl.height; }   

The function handler is called every time, it will contain the correct Shogreid popup event object, but as long as it calls the GridPoppassingsHandler, it will contain old objects from the old call. This works for the first time, the call fails later. Either way the context of the event object changed somewhere between the opening and popup. Any ideas what I am doing wrong here? Is this a bug with Flex? The problem was detected because the mirror only adds the listener once, it will reference the old listener, In the context of old data. I feel that whenever I make closures, I was still hoping to update its references. Not in this case. Probably it is possible to remove the listener and add it again, but I left the idea of ​​closing to mention Riyasar, and apart from that the princely state that is mentioned is also impractical because it is only handler of every Creates a new function for the invitation and makes more overhead.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -