'전체 글'에 해당되는 글 1803건

  1. 2011.05.12 as3 callback function 2
  2. 2011.05.12 as3 callback function 1
  3. 2011.05.09 motion tracking_object mapping
  4. 2011.05.04 monoshift
  5. 2011.05.02 email RegExp
  6. 2011.04.20 사용자 계정 컨트롤 설정

as3 callback function 2

Adobe Flash/ActionScript 3.0 2011. 5. 12. 11:25
반응형


package {
 import flash.display.Sprite;

 /**
  * @author Jang sang wook ( smilejsu@nate.com )
  * @version 1.0
  * @date 2011. 5. 12.
  */
 public class Main extends Sprite {
  
  private var _sample:Sample;
  
  public function Main() {
   _sample = new Sample();
   this.addChild(_sample);
   _sample.callback = fn;
  }
  
  private function fn($str:String):void{
   trace($str);
  }
  
 }//class
}//package


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

 /**
  * @author Jang sang wook ( smilejsu@nate.com )
  * @version 1.0
  * @date 2011. 5. 12.
  */
 public class Sample extends Sprite {
  
  private var _callback:Function;
  
  public function Sample() {
   this.graphics.beginFill(Math.random() * 1000000);
   this.graphics.drawCircle(275, 200, 100);
   this.graphics.endFill();
   this.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
  }

  private function mouseDownHandler(event : MouseEvent) : void {
   _callback("click");
  }
  
//  public function get callback() : Function {
//   return _callback;
//  }

  public function set callback(callback : Function) : void {
   _callback = callback;
  }
  
 }//class
}//package

반응형

'Adobe Flash > ActionScript 3.0' 카테고리의 다른 글

Flash custom component  (0) 2011.05.18
Tile Base Game  (0) 2011.05.17
as3 callback function 1  (0) 2011.05.12
Flash CS5 Code Hint for Mac  (0) 2011.04.19
SWC + FDT4 = SWF  (0) 2011.03.10
:

as3 callback function 1

Adobe Flash/ActionScript 3.0 2011. 5. 12. 10:53
반응형
" Dispatch & Listen "

 

 
" CallBack "


 

 
// CallBack.as
package
{
 import flash.display.DisplayObject;
 import flash.display.Sprite;
 import flash.events.MouseEvent;
 
 [SWF(backgroundColor = 0x000000)]
 public class CallBack extends Sprite
 {
   public function CallBack()
   {
    super();  // Sprite 객체 생성
  
    configreListeners(); // stage 설정
   }
  
   /**
    *  @private
    *  화면 설정
    */
   private function configreListeners():void
   {
    stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler); // 화면 전체 영역 이벤트 등록
   }

   /**
    *  @private
    *  마우스 효과
    *
    *  seedTransparent : 내부 메서드
    *  seed.onTransparent : 외부 Seed 클래스 내부의 _onTransprarent 속성에
    *                                 seedTransparent함수 전달.
    *  scaleX, scaleY : 객체의 가로, 세로 크기 (백분율)
    */
   private function mouseMoveHandler(event:MouseEvent):void
   {
    var seed:Seed = new Seed(); // 마우스효과 줄 객체 생성
  
    seed.onTransparent = seedTransparent; // 함수명만 적어주면됨
  
    seed.x = mouseX; // 객체의 X좌표 값을 현재 마우스의 X좌표로 위치 설정 
    seed.y = mouseY; // 객체의 y좌표 값을 현재 마우스의 y좌표로 위치 설정
  
    var ratio:Number = Math.random(); // 임의의 비율값
  
    seed.scaleX = ratio; // 객체 가로크기 임의의 비율값 적용
    seed.scaleY = ratio; // 객체 세로크기 임의의 비율값 적용
  
    seed.alpha = Math.random(); // 임의의 알파값 적용
  
    addChild(seed); // 객체 화면에 표시
   }

   /**
    *  @private
    *  객체 제거
    *
    *  @param  diaplay  Seed 객체
    */
   private function seedTransparent(display:DisplayObject):void
   {
    removeChild(display); // 화면에서 제거
   }
  
 }//class
}//package

//Seed.as
package
{
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.geom.ColorTransform;

 public class Seed extends Sprite
 {
  private var vx:Number;
  private var vy:Number;
  private var gravity:Number; 
  private var _onTransparent:Function;
  
   public function Seed()
   {
   super();  // Sprite 객체 생성
  
   var sp:Sprite = new Sprite();
   sp.graphics.beginFill(Math.random() * 0x1000000);
   sp.graphics.drawCircle(mouseX, mouseY, 10);
   sp.graphics.endFill();
   this.addChild(sp);
   
   vx = Math.random() * 10 - 5; // -5 ~ 5 사이값
   vy = Math.random() * 10; //0 ~ 10 사이값 : 아래로 떨어질거라 무조건 상수값
   gravity = 1; // 중력가속도 값 설정
   
   addEventListener(Event.ENTER_FRAME, alphaEnterFrameHandler);
   }
 
  /**
  *  @private
  *  seeTransparent() 설정
  *
  *  @param   value  CallBack 클래스의 seedTransparent() 메서드
  */
  public function set onTransparent(value:Function):void
  {
   _onTransparent = value; // seeTransparent()를 _onTransparent로 설정
  }
 
 
  /**
   *  @private
   *  seeTransparent() 조정
   */
   public function get onTransparent():Function
   {
    return _onTransparent;
   }
 
  /**
   *  @private
   *  객체 알파값 설정
   */
  private function alphaEnterFrameHandler(event:Event):void
  {
    vy = vy + gravity; // 중력가속도값(gravity)에 임의의 y속도를 더하여 중력가속도가 됨
    this.x += vx; // X속도 값을 현재 객체의 x좌표값으로 설정
    this.y += vy; // Y속도 값을 현재 객체의 Y좌표값으로 설정
    this.alpha -= 0.05; // 화면에서 점점사라지게 설정
    this.scaleX += 0.05; // 가로크기 증가
    this.scaleY += 0.05; // 세로크기 증가
    var ct:ColorTransform = this.transform.colorTransform; // 객체 색상 변경
    ct.color = Math.random() * 0xFFFFFF; // 임의의 색상 설정
    this.transform.colorTransform = ct; // 설정 색상값 적용
  
    if(this.alpha < 0) // 객체가 화면에 보이지 않으면
    {
     removeEventListener(Event.ENTER_FRAME, alphaEnterFrameHandler); //알파로 안보일뿐 사라지지(삭제)는 않음
   
     if(_onTransparent != null) // _onTransparent속성에 함수가 설정되지 않으면
     {
      _onTransparent(this); // CallBack 클래스의 seedTransparent()의 파리미터로 객체를 넘겨준다.
     }//if
    }//if
  }//alphaEnterFrameHandler
 
 }//class 
}//package


참조: http://butibutiuk.blogspot.com/

반응형

'Adobe Flash > ActionScript 3.0' 카테고리의 다른 글

Tile Base Game  (0) 2011.05.17
as3 callback function 2  (0) 2011.05.12
Flash CS5 Code Hint for Mac  (0) 2011.04.19
SWC + FDT4 = SWF  (0) 2011.03.10
FlashDevelop + Molehill + Away3d_4.0.0  (0) 2011.03.10
:

motion tracking_object mapping

Private 2011. 5. 9. 11:37
반응형
반응형

'Private' 카테고리의 다른 글

Useful Sites & Blogs  (0) 2011.05.18
nikon d80  (0) 2011.05.17
monoshift  (0) 2011.05.04
Motion tracking & Image composition  (0) 2011.04.06
hazzysbaghug  (0) 2011.03.11
:

monoshift

Private 2011. 5. 4. 18:26
반응형
반응형

'Private' 카테고리의 다른 글

Useful Sites & Blogs  (0) 2011.05.18
nikon d80  (0) 2011.05.17
motion tracking_object mapping  (0) 2011.05.09
Motion tracking & Image composition  (0) 2011.04.06
hazzysbaghug  (0) 2011.03.11
:

email RegExp

카테고리 없음 2011. 5. 2. 23:15
반응형
function validateEmail(str:String):Boolean
{
var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/;
var result:Object = pattern.exec(str);
if(result == null){
return false;
}
return result;
}

위 정규표현식에는 "-", "_" 이 안된다고 한다.. 해결방법을 찾아야 겠다.

참고: http://blog.naver.com/ddandongne?Redirect=Log&logNo=90005703908
반응형
:

사용자 계정 컨트롤 설정

ETC 2011. 4. 20. 15:07
반응형

사용자 계정 컨트롤 설정

반응형

'ETC' 카테고리의 다른 글

VisualSVN Sever & TortoiseSVN  (0) 2011.06.17
여성의류  (0) 2011.06.02
window xp 자동 정품인증  (0) 2011.06.02
What is SVG ?  (0) 2011.05.18
what is runtime?  (0) 2011.05.13
: