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();
        }
    }
}

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

Name 
Password 
Homepage 
  secret
Comment 
  글쓰기


[PREV] [1] ... [59][60][61][62][63][64][65][66][67] ... [105] [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