Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    27
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setting module x and y coordinates

    Hello,
    I'm pretty baffled by the lack of information I've found about this and even more baffled that it doesn't look like there's support for this functionality.

    I'm building a custom module loader and I want to send x, y, width, height coordinates for each module I'm loading so I can dynamically place modules where I want them.

    I have my moduleReadyHandler as such but when I set the x, y coords the modules placement is unaffected

    Code:
    private function moduleReadyHandler(event:ModuleEvent):void
    {
    	child = module.factory.create() as DisplayObject;
    	dispatchEvent(event);
    
    	if(child)
    	{
    		child.x = 100;
    		child.y = 100;
    		addChild(child);
    	}
    }
    Any ideas?

    Thanks,
    Eric

  • #2
    New to the CF scene
    Join Date
    Mar 2010
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Two possibilities come to mind, the first, and most likely, is lifecycle. You're probably trying to set the coords before the DisplayObject is available to the stage. For these circumstances, I've placed my parameters in a reference variable on the object, to be filled in when the object via event handler becomes available.

    The other possibility is the Application's layout mode, defined in its mxml tag. If layout is still being calculated (e.g. layout="relative") while placing your objects on the stage, coords may not yet be available for placement.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •