2011-03-24 2 views
-1

나는 초보자이며 튜토리얼 : http://www.webwasp.co.uk/tutorials/018/tutorial.php ... "라이브 페인트/그리기"효과를 만드는 방법을 배우려면 .... AS2에서 무언가를 만들면, 루트 AS3 파일에이 파일을 임베드 (및 작동) 할 수 없다는 사실을 깨닫지 못했다. AS2 코드를 AS3으로 변경하는 방법에 대한 팁을 따르려고했으나 작동하지 않습니다. 나는 그것이 단순한 코드라는 것을 알고 있으며, 거기에있는 어떤 천재는 그것을 이해할 수 있지만, 나는 손실에 처해있다. 도와주세요! 여기간단한 플래시 AS2 코드를 AS3으로 변환

_root.createEmptyMovieClip("myLine", 0); 

_root.onMouseDown = function() { 
    myLine.moveTo(_xmouse, _ymouse); 
    ranWidth = Math.round((Math.random() * 10)+2); 
    myLine.lineStyle(ranWidth, 0xff0000, 100); 
    _root.onMouseMove = function() { 
     myLine.lineTo(_xmouse, _ymouse); 
    } 
} 

_root.onMouseUp = function() { 
    _root.onMouseMove = noLine; 
} 
+0

에서 똑같은 일이지만 요청 누군가가 당신을 위해 일을 가지고 :

다음은 AS2 코드입니다. AS3 전환에 어려움을 겪고 계신 경우 다음 번에 전환을 시도하는 게시글을 보내 주시면 누군가가 귀하의 작업을 수행하는 대신 올바른 방향으로 안내 할 수 있습니다. – 1owk3y

답변

6

을이 정말 문제가 아닙니다 AS3

import flash.display.Sprite; 
import flash.events.MouseEvent; 

var ranWidth:Number; 

//creation of a new clip (Sprite is the base class of MovieClip, 
//it's the same without the unneeded timeline) 
var myLine:Sprite = new Sprite(); 
addChild(myLine); 

//in AS3 the main container is stage, not _root 
//you see here the main difference between beginner AS3 and beginner AS2: 
//event listeners 
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown); 


function onMouseDown(event:MouseEvent):void 
{ 
    myLine.graphics.moveTo(mouseX, mouseY); 
    ranWidth = Math.round((Math.random() * 10)+2); 
    myLine.graphics.lineStyle(ranWidth, 0xff0000, 100); 
    stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 
    stage.addEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
} 

//nesting function in other functions is not a good practice 
function onMouseMove(event:MouseEvent):void 
{ 
    myLine.graphics.lineTo(mouseX, mouseY); 
} 

function onMouseUp(event:MouseEvent):void 
{ 
    stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 
    stage.removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); 
} 
+0

정말 고마워요 !! 나는 영원히 감사한다! – Nicolle

+1

나는 너의 영원한 감사를 받아 들인다. 나는 너에게 나의 대답을 기쁘게 받아 들일 것이다 :) 서명 됨, 코디 악, 플래시 Afficionado – Kodiak

+0

나는 코디 악의 노력에 정말로 감사한다. 그러나 기억해라.이 사이트는 사람들을 돕는 것에 관한 질문이다. 그들. – 1owk3y

관련 문제