RG1967
RG1967

Reputation: 378

flex: referencing calling object from popUp

I have a situation where I have some images on screen with business properties(value, quantity, qualitygrade) assigned to them. When I click on them, a popUp window needs to open and allow me to change properties for the item under the image. How do I reference a) object that caused the popup to open b) properties of the object that are housed in a array- both for initial view and change

I have the images enabled for doubleclick as follows

newImage.doubleClickEnabled=true;
newImage.addEventListener(MouseEvent.DOUBLE_CLICK,createModifyPopUp);

I am currently calling the popUp window as follows

private function createModifyPopUp(evt:MouseEvent):void{
var mywin1:Modify=PopUpManager.createPopUp(this,Modify,true) as Modify;
PopUpManager.centerPopUp(mywin1);
}

I don't seem to be passing an event into the popup- Is there a way I can work based on the image clicked in the original application to build and capture information in the modify.

Upvotes: 1

Views: 471

Answers (1)

aav
aav

Reputation: 2489

simply use PopUpManager.addPopup instead of PopUpManager.createPopUp

your example should look like this:

//define properties in the Modify class (Modify.as3 or Modify.mxml)
public var someData: Array;
public var eventTarget: Object;


// listener
private function createModifyPopUp(evt:MouseEvent):void{
   var modify: Modify = new Modify();
   // pass parameters to the instance of Modify class
   modify.someData = arr;
   modify.eventTarget = evt.target;

   // show popup
   PopUpManager.addPopUp(modify, this, true);
   PopUpManager.centerPopUp(modify);
}

Upvotes: 4

Related Questions