Fix the x & y axis of popup in a swf file that is being loaded in another swf file
I load a "cal" swf file in another swf files mdi_window. So the window is moveable inside the application.
The issue is with the x y axis for the popups that open up in cal swf. The code for the function that opens popup is:
private var eventPanel:ElixirEventPanel = null;
private function showEventEditPanel(item:CalendarItem,x:int,y:int):void{
eventPanel = ElixirEventPanel.sharedInstance;
eventPanel.setStyle("modalTrasparancy",0);
eventPanel.setStyle("modalTransparencyBlur",0);
eventPanel.setStyle("modalTransparencyColor",0xffffff);
eventPanel.setStyle("modalTransparencyDuration",0);
PopUpManager.addPopUp(eventPanel,DisplayObject(super), false);
eventPanel.calendarItem = item;
eventPanel.x = x - eventPanel.width;
eventPanel.y = y - eventPanel.height/2;
if(eventPanel.y < this.parent.scaleY + 100)
eventPanel.y = this.parent.scaleY + 100;
}
Now as this swf is being loaded in another file using : (as you can see I am trying to convert the local co-ordinates to Global, using localToGlobal function, but I guess I am doing something wrong in that)
<s:SWFLoader id="template" source="Cal.swf" loadForCompatibility="true" width="100%" height="100%" scaleContent="true" complete="dump(event);"/>
<fx:Script>
<![CDATA[
private function dump(event:Event): void {
var panel:MovieClip = MovieClip(template.content);
var pt:Point = panel.localToGlobal(new Point(panel.x, panel.y));
}
]]>
</fx:Script>
The x &开发者_JAVA技巧; y axis of the popup act wired based on the location of the mdi_window in which the Cal.swf is being loaded. The x & y axis work fine if I move the mdi_window all the way on the top left corner of the application.
The first image shows how the popup opens when I double-click on the 10:00 AM purple color event on my calendar.
and now when I move my window the popup moves to the side as well. I clicked on the same 10:00Am purple event again here:
How can I solve this issue.Any suggestions are appreciated.
Best Zee
Have you tried localToGlobal() to translate a local point to a global point? It should work but I've never tried it with SWFLoader.
精彩评论