[flexcoders] Re: PopUpManager quick help
Let's see: PopUpManager.createPopUp( cn, AddSubscriptionModal, true ) do follow: * create AddSubscriptionModal. The constructor call PopUpManager.centerPopUp( this ); This center the window to its parent. Parent is not defined at present time - error * add created window to canvas the Canvas is not required - you can add the window to application just like you added Canvas to it this is fixed code - just move centerPopUp to Startup public function Startup() { var asm:AddSubscriptionModal = PopUpManager.createPopUp( Application.application as DisplayObject, AddSubscriptionModal, true ) as AddSubscriptionModal; PopUpManager.centerPopUp( asm); } if you want to have self centered window handle add event --- In flexcoders@yahoogroups.com, "aaron smith" <[EMAIL PROTECTED]> wrote: > > I'm trying to understand the popup manager better, i created a quick test > just to get it working and test it out.. most works fine but having problems > understanding how to center the popup.. > > here is my code: > > > MXML::: > > > http://www.adobe.com/2006/mxml"; > layout="horizontal" creationComplete="initApp()"> > > import Startup; > > private function initApp():void > { > var st:Startup = new Startup(); > } > > > > > Startup.as::: > > package > { > > import mx.managers.PopUpManager; > import mx.containers.Canvas; > import mx.core.Application; > import mx.containers.TitleWindow; > import AddSubscriptionModal; > > public class Startup > { > public function Startup() > { > var cn:Canvas = new Canvas(); > cn.percentWidth = 100; > cn.percentHeight = 100; > > Application.application.addChild( cn ); > > var asm:AddSubscriptionModal = PopUpManager.createPopUp( cn, > AddSubscriptionModal, true ) as AddSubscriptionModal; > } > } > } > > > AddSubscriptionModal.as::: > > package > { > > import mx.containers.TitleWindow; > import mx.managers.PopUpManager; > import mx.events.CloseEvent; > > public class AddSubscriptionModal extends TitleWindow > { > public function AddSubscriptionModal() > { > doInit(); > addEventListener( CloseEvent.CLOSE, handleCloseModal ); > } > > private function doInit():void > { > title = "test"; > showCloseButton = true; > width = 400; > height = 200; > //PopUpManager.centerPopUp( this ); //this causes an run-time > error, not sure why?? > } > > private function handleCloseModal( ce:CloseEvent ):void > { > PopUpManager.removePopUp( this ); > } > } > } > > > > I am wondering if giving the createPopUp method the canvas as parent is the > problem? > > can someone glance at this quick and see if you can help? or does someone > have an example already? > > thanks all! > > smith >
Re: [flexcoders] Re: PopUpManager quick help
its cool, i actually got it figured out for what i need. What i was looking for actually was to center the popup to the stage. so I just created this class that I extend from instead.. It makes sense now that if you want to center inside of the parent object, you use PopUpManager.centerPopUp. or you can jsut specify the x and y, in this classes case, the stage width and height.package{ import mx.core.Application; import mx.containers.TitleWindow; import mx.events.FlexEvent; import mx.events.ResizeEvent; /** * a class that handles centering itself in the entire application window, * does a center when the swf is resized, or when you call selfCenter * from one of it's subclassed implementations */ public class SelfCenteringTitleWindowPopUp extends TitleWindow { /** * constructor */ public function SelfCenteringTitleWindowPopUp() { super(); addEventListener( FlexEvent.CREATION_COMPLETE, handleCreationComplete ); } /** * when the creation of the TitleWindow is complete, add listener for resize events * @param fe */ protected function handleCreationComplete( fe:FlexEvent ):void { Application.application.addEventListener( ResizeEvent.RESIZE, selfCenterFromResize ); } /** * the resize event handler method, uses selfCenter * @param re */ protected function selfCenterFromResize( re:ResizeEvent ):void { selfCenter(); } /** * the method that does the centering of this popup */ protected function selfCenter():void { x = ( Application.application.width - width ) / 2; y = ( Application.application.height - height ) / 2; } }}MXML::: http://www.adobe.com/2006/mxml" layout="horizontal" creationComplete="initApp()"> import Startup; private function initApp():void { var st:Startup = new Startup(); } Startup.as::: package{ import mx.managers.PopUpManager; import mx.containers.Canvas; import AddSubscriptionModal; public class Startup { public function Startup() { var cn:Canvas = new Canvas(); Application.application.addChild( cn ); var asm:AddSubscriptionModal = PopUpManager.createPopUp( cn, AddSubscriptionModal, true ) as AddSubscriptionModal; } }}AddSubscriptionModal.as:::package{ import mx.managers.PopUpManager; import mx.events.CloseEvent; import SelfCenteringTitleWindowPopUp; public class AddSubscriptionModal extends SelfCenteringTitleWindowPopUp { public function AddSubscriptionModal() { doInit(); addEventListener( CloseEvent.CLOSE , handleCloseModal ); } private function doInit():void { title = "test"; showCloseButton = true; width = 400; height = 200; selfCenter(); } private function handleCloseModal( ce:CloseEvent ):void { PopUpManager.removePopUp( this ); } }} I appreciate your help though..smithOn 9/18/06, Tim Hoff <[EMAIL PROTECTED]> wrote: Perhaps it's because you are using AS to create the canvas. Possibly a race condition (asynchronous) is occurring as the canvas is resized and the popup is centered. You could always just use mx:Canvas in your main application class instead. It all gets turned into AS anyway. Sorry that I couldn't be of more help -TH --- In flexcoders@yahoogroups.com, "aaron smith" <[EMAIL PROTECTED]> wrote: > > doesnt seem to work correctly. It actually puts the popup in the negative > window space. (see attachment) > I wonder why it would do that. is it something to do with canvas / > percentWidth / percentHeight. i've event tried commenting that out and it > still only puts it at 0,0. > > > > > > > > > > > > On 9/18/06, Tim Hoff <[EMAIL PROTECTED]> wrote: > > > > Hi Aaron, > > > > This code will center the popup relative to the popups's parent. In > > your case "cn". > > > > PopUpManager.centerPopUp(asm); > > > > -TH > > > > --- In flexcoders@yahoogroups.com 40yahoogroups.com>, "aaron > > smith" > > > > wrote: > > > > > > I'm trying to understand the popup manager better, i created a > > quick test > > > just to get it working and test it out.. most works fine but > > having problems > > > understanding how to center the popup.. > > > > > > here is my code: > > > > > > > > > MXML::: > > > > > > > > > http://www.adobe.com/2006/mxml" > > > layout="horizontal" creationComplete="initApp()"> > > > > > > import Startup; > > > > > > private function initApp():void > > > { > > > var st:Startup = new Startup(); > > > } > > > > > > > > > > > > > > > Startup.as::: > > > >
[flexcoders] Re: PopUpManager quick help
Perhaps it's because you are using AS to create the canvas. Possibly a race condition (asynchronous) is occurring as the canvas is resized and the popup is centered. You could always just use mx:Canvas in your main application class instead. It all gets turned into AS anyway. Sorry that I couldn't be of more help -TH --- In flexcoders@yahoogroups.com, "aaron smith" <[EMAIL PROTECTED]> wrote: > > doesnt seem to work correctly. It actually puts the popup in the negative > window space. (see attachment) > I wonder why it would do that. is it something to do with canvas / > percentWidth / percentHeight. i've event tried commenting that out and it > still only puts it at 0,0. > > > > > > > > > > > > On 9/18/06, Tim Hoff <[EMAIL PROTECTED]> wrote: > > > > Hi Aaron, > > > > This code will center the popup relative to the popups's parent. In > > your case "cn". > > > > PopUpManager.centerPopUp(asm); > > > > -TH > > > > --- In flexcoders@yahoogroups.com , "aaron > > smith" > > > > wrote: > > > > > > I'm trying to understand the popup manager better, i created a > > quick test > > > just to get it working and test it out.. most works fine but > > having problems > > > understanding how to center the popup.. > > > > > > here is my code: > > > > > > > > > MXML::: > > > > > > > > > http://www.adobe.com/2006/mxml"; > > > layout="horizontal" creationComplete="initApp()"> > > > > > > import Startup; > > > > > > private function initApp():void > > > { > > > var st:Startup = new Startup(); > > > } > > > > > > > > > > > > > > > Startup.as::: > > > > > > package > > > { > > > > > > import mx.managers.PopUpManager; > > > import mx.containers.Canvas; > > > import mx.core.Application; > > > import mx.containers.TitleWindow; > > > import AddSubscriptionModal; > > > > > > public class Startup > > > { > > > public function Startup() > > > { > > > var cn:Canvas = new Canvas(); > > > cn.percentWidth = 100; > > > cn.percentHeight = 100; > > > > > > Application.application.addChild( cn ); > > > > > > var asm:AddSubscriptionModal = PopUpManager.createPopUp > > ( cn, > > > AddSubscriptionModal, true ) as AddSubscriptionModal; > > > } > > > } > > > } > > > > > > > > > AddSubscriptionModal.as::: > > > > > > package > > > { > > > > > > import mx.containers.TitleWindow; > > > import mx.managers.PopUpManager; > > > import mx.events.CloseEvent; > > > > > > public class AddSubscriptionModal extends TitleWindow > > > { > > > public function AddSubscriptionModal() > > > { > > > doInit(); > > > addEventListener( CloseEvent.CLOSE, handleCloseModal ); > > > } > > > > > > private function doInit():void > > > { > > > title = "test"; > > > showCloseButton = true; > > > width = 400; > > > height = 200; > > > //PopUpManager.centerPopUp( this ); //this causes an > > run-time > > > error, not sure why?? > > > } > > > > > > private function handleCloseModal( ce:CloseEvent ):void > > > { > > > PopUpManager.removePopUp( this ); > > > } > > > } > > > } > > > > > > > > > > > > I am wondering if giving the createPopUp method the canvas as > > parent is the > > > problem? > > > > > > can someone glance at this quick and see if you can help? or does > > someone > > > have an example already? > > > > > > thanks all! > > > > > > smith > > > > > > > > > > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
Re: [flexcoders] Re: PopUpManager quick help
doesnt seem to work correctly. It actually puts the popup in the negative window space. (see attachment)I wonder why it would do that. is it something to do with canvas / percentWidth / percentHeight. i've event tried commenting that out and it still only puts it at 0,0. On 9/18/06, Tim Hoff <[EMAIL PROTECTED]> wrote: Hi Aaron, This code will center the popup relative to the popups's parent. In your case "cn". PopUpManager.centerPopUp(asm); -TH --- In flexcoders@yahoogroups.com, "aaron smith" <[EMAIL PROTECTED]> wrote: > > I'm trying to understand the popup manager better, i created a quick test > just to get it working and test it out.. most works fine but having problems > understanding how to center the popup.. > > here is my code: > > > MXML::: > > > http://www.adobe.com/2006/mxml" > layout="horizontal" creationComplete="initApp()"> > > import Startup; > > private function initApp():void > { > var st:Startup = new Startup(); > } > > > > > Startup.as::: > > package > { > > import mx.managers.PopUpManager; > import mx.containers.Canvas; > import mx.core.Application; > import mx.containers.TitleWindow; > import AddSubscriptionModal; > > public class Startup > { > public function Startup() > { > var cn:Canvas = new Canvas(); > cn.percentWidth = 100; > cn.percentHeight = 100; > > Application.application.addChild( cn ); > > var asm:AddSubscriptionModal = PopUpManager.createPopUp ( cn, > AddSubscriptionModal, true ) as AddSubscriptionModal; > } > } > } > > > AddSubscriptionModal.as::: > > package > { > > import mx.containers.TitleWindow; > import mx.managers.PopUpManager; > import mx.events.CloseEvent; > > public class AddSubscriptionModal extends TitleWindow > { > public function AddSubscriptionModal() > { > doInit(); > addEventListener( CloseEvent.CLOSE, handleCloseModal ); > } > > private function doInit():void > { > title = "test"; > showCloseButton = true; > width = 400; > height = 200; > //PopUpManager.centerPopUp( this ); //this causes an run-time > error, not sure why?? > } > > private function handleCloseModal( ce:CloseEvent ):void > { > PopUpManager.removePopUp( this ); > } > } > } > > > > I am wondering if giving the createPopUp method the canvas as parent is the > problem? > > can someone glance at this quick and see if you can help? or does someone > have an example already? > > thanks all! > > smith > __._,_.___ -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com SPONSORED LINKS Software development tool Software development Software development services Home design software Software development company Your email settings: Individual Email|Traditional Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___ <>
[flexcoders] Re: PopUpManager quick help
Hi Aaron, This code will center the popup relative to the popups's parent. In your case "cn". PopUpManager.centerPopUp(asm); -TH --- In flexcoders@yahoogroups.com, "aaron smith" <[EMAIL PROTECTED]> wrote: > > I'm trying to understand the popup manager better, i created a quick test > just to get it working and test it out.. most works fine but having problems > understanding how to center the popup.. > > here is my code: > > > MXML::: > > > http://www.adobe.com/2006/mxml"; > layout="horizontal" creationComplete="initApp()"> > > import Startup; > > private function initApp():void > { > var st:Startup = new Startup(); > } > > > > > Startup.as::: > > package > { > > import mx.managers.PopUpManager; > import mx.containers.Canvas; > import mx.core.Application; > import mx.containers.TitleWindow; > import AddSubscriptionModal; > > public class Startup > { > public function Startup() > { > var cn:Canvas = new Canvas(); > cn.percentWidth = 100; > cn.percentHeight = 100; > > Application.application.addChild( cn ); > > var asm:AddSubscriptionModal = PopUpManager.createPopUp ( cn, > AddSubscriptionModal, true ) as AddSubscriptionModal; > } > } > } > > > AddSubscriptionModal.as::: > > package > { > > import mx.containers.TitleWindow; > import mx.managers.PopUpManager; > import mx.events.CloseEvent; > > public class AddSubscriptionModal extends TitleWindow > { > public function AddSubscriptionModal() > { > doInit(); > addEventListener( CloseEvent.CLOSE, handleCloseModal ); > } > > private function doInit():void > { > title = "test"; > showCloseButton = true; > width = 400; > height = 200; > //PopUpManager.centerPopUp( this ); //this causes an run-time > error, not sure why?? > } > > private function handleCloseModal( ce:CloseEvent ):void > { > PopUpManager.removePopUp( this ); > } > } > } > > > > I am wondering if giving the createPopUp method the canvas as parent is the > problem? > > can someone glance at this quick and see if you can help? or does someone > have an example already? > > thanks all! > > smith > -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/