mouse 에 해당하는 글2 개
2006/08/25   Mouse Event in AS3.0
2006/08/13   Detecting When the Mouse Leaves...

flash/As3.0 | 2006/08/25 11:29

기존에 AS2.0 까지는 MovieClip 안에 버튼을 넣고 MovieClip 에 마우스 이벤트를 걸면 작동이 되질 않았다. 즉 버튼안에 버튼이 있는 상태는 마우스 이벤트가 발생하지 않아 네비게이션 같은 작업을 할때 정말 쉽지 않았다.
편법으로 hitTest 를 통해 이벤트를 체크했지만 리소스 측면에서 별로 바람직하지 못한 방법이다.

<AS2.0>


clip.onRollOver=function()
{
    trace("rollOver "+ this);
}
clip 이라는 무비클립안에 버튼이 들어가 있는 상태. 무비클립에 마우스 이벤트를 설정해도 작동하지 않는다.

<AS3.0>

function onRollOver(objEvent:Event)
{
trace("RollOver ", objEvent.target, objEvent.target.name);
}
clip.addEventListener(MouseEvent.MOUSE_OVER, this.onRollOver);

버튼으로 작동하는 clip 무비클립 안에 버튼이 있어도 이벤트를 발생시킨다.

download sample


 
 
태그 : As2.0, AS3.0, Event, mouse
이 글의 관련글(트랙백) 주소 :: http://kimkijeung.com/trackback/53

Name 
Password 
Homepage 
  secret
Comment 
  글쓰기

flash/As3.0 | 2006/08/13 19:13
One thing about previous versions of ActionScript was that you could never tell when the user no longer had his or her mouse over the Flash movie. This made it hard for people to know whether or not the user is still interacting with their movie or if they've given up and moved on to something more interesting. This was especially a problem for custom cursors where, if the user moved the cursor off the Flash movie, the custom cursor would still remain in the Flash movie not moving while the real cursor could be seen moving around every where else.

ActionScript 3 now allows you to detect when the mouse has left the flash movie using the stage's mouseLeave event. This event happens whenever the mouse exits the Flash movie. There is no mouseEnter event, but you can use mouseMove for that since mouseMove only occurs in Flash (for the stage, or really any, object) when the mouse is within the bounds of the movie.

html에서의 플래시 영역 밖으로 마우스 커서를 옮겼을경우 이전에는 정확히 그것을 알아낼 방법이 없었다. 마우스 커서가 안보인다 하더라도 엄연히 플래시 오브젝트 안에 남아서 실행되고 있었는데
이것을 as3.0 에서는 체크할수 있게 되었다.

package {
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.ui.Mouse;
   
    public class Test extends Sprite {
       
        private var cursor:Sprite = new Sprite();
       
        public function Test() {
            cursor.graphics.beginFill(0xFF);
            cursor.graphics.drawRect(0, 0, 25, 25);
            addChild(cursor);
           
            stage.addEventListener(Event.MOUSE_LEAVE, cursorHide);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, cursorFollow);
            Mouse.hide();
        }
       
        public function cursorHide(evt:Event):void {
            cursor.visible = false;
        }
       
        public function cursorFollow(evt:MouseEvent):void {
            if (!cursor.visible) cursor.visible = true;
            cursor.x = stage.mouseX;
            cursor.y = stage.mouseY;
            evt.updateAfterEvent();
        }
    }
}

 
 
태그 : AS3.0, mouse
이 글의 관련글(트랙백) 주소 :: http://kimkijeung.com/trackback/46

Name 
Password 
Homepage 
  secret
Comment 
  글쓰기


[PREV] [1] [NEXT]

 
전체 (105)
flash (74)
math&physics (4)
programming (11)
Flex2 (1)
Mac (2)
photo (0)
project (6)
주저리주저리 (3)
유용한 자료들 (1)
diary (0)
Book (1)
web (2)
«   2009/01   »
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31