From: <do...@cr...> - 2005-08-10 17:41:30
|
Bob, Some information that we need includes the following: The make and version of web browser you are experiencing the poroblem in. The OS on which you are running said browser. The version of DynAPI 3.. is it the beta found in the downloads section, or did you download the latest version from cvs. That said I have mashed together the following test html. In IE 6 and FireFox 1.0.6 the results are as expected. The only thing that comes to mind is maybe the fact that your photo layer is set to have an x and y of 0. Thus, if the parent layer's top left corner is at 0x0 then the x and y values of the child layer will reflect this (10 pixels from the top of a layer that is at 0px from the top of the page will be 10px from the top of the page. When I change the Photo layer's x and y to 10x10 and then move the child layer to the top-left I get x and y of 0x0 as expected. <html> <head> <script language="JavaScript" src="src/dynapi.js"></script> <script language="Javascript"> dynapi.library.setPath('src/'); dynapi.library.include('dynapi.api'); dynapi.library.include('dynapi.gui.BorderManager'); dynapi.library.include('DragEvent'); </script> <script language=javascript> var debugLayer = dynapi.document.addChild(new DynLayer(null,610,0,100,100)); var photo = dynapi.document.addChild(new DynLayer(null,10,10,600,400)); var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); bg1.setHTML('<img src="examples/images/f1-sky.jpg" border="1" width="600" height="400">'); bg1.setInnerBorder(0,{top:'black',right:'black',bottom:'black',left:'black'}); bg1.setZIndex(2); bg1.addEventListener({ onclick:function(e){ var x = e.getX(); //debugtext.setHTML('<span class="text_11">' + x + '</span>'); lyr1.setX(x); lyr1.setY(e.getY()); //document.editcamera.valueX.value = lyr1.getX(); //document.editcamera.valueY.value = lyr1.getY(); debugLayer.setHTML("X=" + lyr1.getX() + " and Y=" + lyr1.getY()) } }); var lyr1 = photo.addChild(new DynLayer(null,5,5,10,10,'red')); lyr1.setZIndex(3); DragEvent.enableDragEvents(lyr1); DragEvent.setDragBoundary(lyr1, {left:0, right:0, top:0, bottom:0}); lyr1.addEventListener({ ondragend:function(e){ var o=e.getSource(); o.setZIndex(3); //document.editcamera.valueX.value = lyr1.getX(); //document.editcamera.valueY.value = lyr1.getY(); debugLayer.setHTML("X=" + lyr1.getX() + " and Y=" + lyr1.getY()) } }); </script> </head> <body> <script language=javascript> dynapi.document.insertChild(photo,'relative'); </script> </body> </html> Bob Jamison <bob...@gr...> said: > I've been banging my head against the wall trying to get this to work, and no luck so far. I have a child layer, in which I want to be able to click and get the x and y values of where I clicked -- so far, it's getting the x and y value relative to the page, not the layer. I'm using 3.0. What am I doing wrong? (This is being used in PHP, so you may see some variables that are coming from that) > > > var photo = dynapi.document.addChild(new DynLayer(null,0,0,600,400)); > > > var bg1 = photo.addChild(new DynLayer(null,0,0,600,400)); > bg1.setHTML('<img src="$url" border="1" width="600" height="400">'); > bg1.setInnerBorder(0,{top:'black',right:'black',bottom:'black',left:'black'}); > bg1.setZIndex(2); > bg1.addEventListener({ > onclick:function(e){ > var x = e.getX(); > debugtext.setHTML('<span class="text_11">' + x + '</span>'); > lyr1.setX(x); > lyr1.setY(e.getY()); > document.editcamera.valueX.value = lyr1.getX(); > document.editcamera.valueY.value = lyr1.getY(); > } > }); > > var lyr1 = photo.addChild(new DynLayer(null,$x,$y,10,10,'red')); > lyr1.setZIndex(3); > DragEvent.enableDragEvents(lyr1); > DragEvent.setDragBoundary(lyr1, {left:0, right:0, top:0, bottom:0}); > lyr1.addEventListener({ > ondragend:function(e){ > var o=e.getSource(); > o.setZIndex(3); > document.editcamera.valueX.value = lyr1.getX(); > document.editcamera.valueY.value = lyr1.getY(); > } > }); > > > I have a relative layer down in the html: dynapi.document.insertChild(photo,'relative'); > > Help, please! > > -- > _______________________________________________ > Graffiti.net free e-mail @ www.graffiti.net > Check out our value-added Premium features, such as a 1 GB mailbox for just US$9.95 per year! > > > Powered By Outblaze > > > ------------------------------------------------------- > SF.Net email is Sponsored by the Better Software Conference & EXPO > September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices > Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA > Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > https://lists.sourceforge.net/lists/listinfo/dynapi-help > -- |