1 Reply Latest reply on Jan 21, 2013 9:42 AM by jdhughen

    need help with offset calculation for animation stage

    jdhughen Level 1

      I'm using..


      ON CLICK


      word1 = sym.createChildSymbol("ways1", "Stage");

      word1Element = word1.getSymbolElement();

      var posX = (e.pageX- ($(word1Element).width()/2)) + "px";

      var posY = (e.pageY- ($(word1Element).height()/2)) + "px";

      sym.$(word1Element).css({"position":"absolute", "top":posY, "left":posX});


      this works great to get the users mouse click position and create a symbol on the stage at that position.


      The problem now is when the stage is displayed in the browser it's on the far left so I use...






      to center the stage in the browser.


      The problem is that this totally throughs off getting the users click position using the

      var posX = (e.pageX- ($(word1Element).width()/2)) + "px";

      approach cause it different on different machines/browsers based on screen size.

      I need to know how to account for the stage being centered in the current browser widow.

      Is there some kind of "offset" I could use in the code to account for this ??


      I tried creating a html wrapper in the webpage but still had the same problem. As long as the stage is aligned on the left side of the browser it all works fine. but it's thrown off when the stage is centered in the webpage.




      Joel H