2 Replies Latest reply on Nov 24, 2009 5:37 AM by manofspirit

    Learning Co-ordinate System - Problem

    manofspirit Level 1



      I created a sample project to epxlain my problem.

      There are two canvases in the main application. outerspace canvas and innerspace canvas.

      innerspace canvas has a visual component "mainBox"

      and there is also a visual component in outerspace canvas named "overBox"


      now i want user to map the x-xis and y-xis of overBox to mainBox, so when user will click re-arrange, overbox will completely cover the mainBox.

      This is actually a problem of different co-oridatane systems and i dont know how to map them into one.


      Here is the code.

      Application File

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="*">
                          private function arrange(event:MouseEvent):void{
                               var point:Point = mainBox.localToGlobal(new Point());
                               overBox.x = point.x;
                               overBox.y = point.y;
           <mx:Canvas width="80%" height="80%" horizontalCenter="0" verticalCenter="0" id="outerSpace" backgroundColor="#A9A9A9">
                <mx:Canvas width="80%" height="80%" horizontalCenter="0" verticalCenter="0" id="innerSpace" backgroundColor="#8DB5FF">
                     <ns1:Node horizontalCenter="0" verticalCenter="0" width="100" height="100" id="mainBox">
                <ns1:Node x="21" y="10" id="overBox" width="100" height="100" backgroundColor="#FFA352">
           <mx:Button label="Re-Arrange" click="arrange(event)" left="10" top="10"/>



      Project is also attached.