2013-06-11 17 views
0

사용자가 스테이지의 아무 곳이나 터치 할 때마다 심볼을 생성/트리거하려는 가장자리 애니메이션 문서가 있습니다. 나는 기호의 중심이 포인터가 클릭했을 때 무대에 위치했으면한다.클릭 위치에서 클릭시 심볼 생성

나는 자바 스크립트를 사용하여 클릭 x, y 좌표를 결정하는 방법을 알고 있지만 어떻게 그 위치에 심볼을 배치합니까?

답변

0

내가 이런 식으로했다 : 아마 Y는 반전

//Create symbol on stage. 
//The number 1 indicates the position in the list 
//of the symbol instances on the stage, 
//like the one you see in the right panel called "Elements". 
//Use it to set the z-index (position elements in front or in background). 
var myNewSymbol = sym.createChildSymbol("myNewSymbol", "Stage", 1); 
var x = e.pageX; 
var y = e.pageY; 

// I wanted position to be in percentage 
var bodyHeight = $(window).height(); 
var bodyWidth = $(window).width(); 
var xPercent = 100 * x/bodyWidth; 
var yPercent = 100 * y/bodyHeight; 

//Set the position 
myNewSymbol.getSymbolElement().css("position", "absolute"); 
myNewSymbol.getSymbolElement().css("left", xPercent + "%"); 
myNewSymbol.getSymbolElement().css("top", yPercent + "%"); 
+0

을 ... 어쩌면 당신이 최고 100 yPercent로 설정해야합니다 (또는 픽셀 사용하는 경우 : 차체 높이 - y)를. 시도 해봐. – Ena

관련 문제