Class 에 해당하는 글2 개
2006/12/04   Tween class
2006/08/30   Classes in As and Java or C++

flash/As2.0 | 2006/12/04 20:30

//==================================================================
//@class name :   PropertyTweenEase.as
//@author            : vkimone. KimKiJeung  (http://kimkijeung.com)
//@last update   :2006. 12. 4
//@version          : V1.2
//==================================================================

/**
* @description
* 무비클립 속성  트윈 클래스 : 이징함수 설정으로 조절
* 트원할 속성의 갯수에 관계없이 오브젝트로 적용 가능
*
* 트윈이 끝났을 때 실행할 함수 및 파라미터 설정 방법
* 다른 클래스에서 직접 참조해서 호출 가능....
* @param referObj : reference object(caution--> 파라미터값 반드시 배열요소로 입력)
* @example
*     <code>
*        PropertyTweenEase.tween(targetMc,{_x:200,_y:100},Elastic.easeOut,30,{{func: 실행할 함수
이름 , obj: 참조오브젝트, param: [파라미터 배열로 들어감]}}
*     </code>
*/


class com.dstrict.UB.util.transitions.tween.PropertyTweenEase {
/**----------------------------------------------------------------------------------
* @param mc : MovieClip, 적용무비클립
* @param property : Object, 무비클립속성 오브젝트 ex. {_x:100,_y:200}
* @param func : Function, easing function
* @param durationFrame : Number, 지속프레임
*------------------------------------------------------------------------------------*/


public static function tween(mc:MovieClip,obj:Object,func:Function,durationFrame:Number):Void{
var time:Number=1;
var beginning:Array=new Array();
var change:Array=new Array();

 
for(var i in obj){
  beginning.push(mc[i]);
     change.push(obj[i]-mc[i]);
    
}
       var type=(typeof(arguments[4])=="object")? true : false;
       if(type){
        var referObj=arguments[4];
       }else{
        var p:Number=arguments[4];
        var referObj=arguments[5];
       }
  mc.onEnterFrame=function(){
  var objIdx:Number=0;
  for(var i in obj){
   mc[i]=func(time,beginning[objIdx],change[objIdx],durationFrame,p);
   objIdx++;
  }

     time++;
  if(time>durationFrame){
   delete this.onEnterFrame;
   if(referObj!=undefined){
    referObj.func.apply(referObj.obj,referObj.param);
   }
   
  }
};
}
}

기존에 동시에 2개의 속성을 트윈시킬 수 있었던 것에서 트원 속성 갯수에 관계없이
가능하도록 수정하였다.  이 클래스 하나로 무비클립 속성 트윈은 대부분 가능하다.
마지막 파라미터를 이용해 콜백함수를 호출할수 있다. 이징 함수 자체도 조절 가능하게
해보았지만 효율성 측면에서 생략했다.
어쩌면 이정도 길이에 가장 많은 기능을 제공하고 범용적으로 사용될수 있는 트윈클래스가 없지 않을듯 싶다...^^

<사용방법>

PropertyTweenEase.tween(mc,{_x:100,_y:200,_alpha:100},Regular.easeOut,20,
{func:this.onMotionFinished,obj:this});

function onMotionFinished():Void{
  trace("motion finished.......");
}


 
 
태그 : As2.0, Class, tween
이 글의 관련글(트랙백) 주소 :: http://kimkijeung.com/trackback/72

Name 
Password 
Homepage 
  secret
Comment 
  글쓰기

flash/As3.0 | 2006/08/30 17:37
Programmers familiar with object-oriented programming (OOP) in Java or C++ may think of
objects as modules that contain two kinds of members: data stored in member variables or
properties, and behavior accessible through methods. The ECMAScript edition 4 draft, the
standard upon which ActionScript 3.0 is based, defines objects in a similar but slightly
different way. In the ECMAScript draft, objects are simply collections of properties. These
properties are containers that can hold not only data, but also functions or other objects. If a function is attached to an object in this way, it is called a method.
While the ECMAScript draft definition may seem a little odd to programmers with a Java or C++ background, in practice, defining object types with ActionScript 3.0 classes is very similar to the way classes are defined in Java or C++. The distinction between the two definitions of object is important when discussing the ActionScript object model and other advanced topics, but in most other situations the term properties means class member variables as opposed to methods. The Flex 2 Language Reference, for example, uses the term properties to mean variables or getter-setter properties. It uses the term methods to mean functions that arepart of a class.
One subtle difference between classes in ActionScript and classes in Java or C++ is that in ActionScript, classes are not just abstract entities. ActionScript classes are represented by class objects that store the class’s properties and methods. This allows for techniques that may seem alien to Java and C++ programmers, such as including statements or executable code at the top level of a class or package.
Another difference between ActionScript classes and Java or C++ classes is that every ActionScript class has something called a prototype object. In previous versions of ActionScript, prototype objects, linked together into prototype chains, served collectively as the foundation of the entire class inheritance hierarchy. In ActionScript 3.0, however, prototype objects play only a small role in the inheritance system. The prototype object can still be useful, however, as an alternative to static properties and methods if you want to share a property and its value among all the instances of a class.
In the past, advanced ActionScript programmers could directly manipulate the prototype
chain with special built-in language elements. Now that the language provides a more mature
implementation of a class-based programming interface, many of these special language
elements, such as __proto__ and __resolve, are no longer part of the language. Moreover,
optimizations of the internal inheritance mechanism that provide significant Flash Player
performance improvements preclude direct access to the inheritance mechanism.

<Flex 2 language Reference 36 page>

actionscript 와 java or c++ 의 class 간의 개념이 약간 다르다.
어찌보면 다아나믹한 움직임을 구현하기 위해선 필요한 차이점인지 모른다.
그래도 ECMAScript 기반의 언어라 그런지 java 와는 외향이 거의 흡사해진다는 느낌이다.
prototype 은 뭔가 꺼림직해서 이전부터 건드리지 않은 부분이지만 아니나 다를까 성능에 문제가 있을 수 있다고 하니 protoype object 는 터치하지 말아야 겠다...

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

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