티스토리 뷰
728x90
반응형
여러개의 썸네일들을 마우스오버시 다른 썸네일보다 최상위에 배치하여 썸네일을 보여줘야 하고
또 마우스 아웃시엔 다시 원래대로의 뎁스를 유지시켜야 하는 머 그럴때가 종종 있다~
그래서 그것을 위해 만들어본 클래스~ 만든지는 꽤 되었으나~ 여지껏 새롭게 수정을 해놓지 않고 있다~
분명 분명~~~~~~~~먼가 더 좋게 만들 수 있음에도 ㅋㅋㅋㅋ 그래도 나름 쓸만해서 그냥 쓴다~
귀차니즘~ 고고싱~
자식이 추가되는 시점에다 해당 클래스를 인스턴화시켜야 한다.
그래야 DepthUtils클래스 내부에서 자식검색시 자식이 등록이 되기에.........
아래는 짧막하게 예시.....ㅋ
또 마우스 아웃시엔 다시 원래대로의 뎁스를 유지시켜야 하는 머 그럴때가 종종 있다~
그래서 그것을 위해 만들어본 클래스~ 만든지는 꽤 되었으나~ 여지껏 새롭게 수정을 해놓지 않고 있다~
분명 분명~~~~~~~~먼가 더 좋게 만들 수 있음에도 ㅋㅋㅋㅋ 그래도 나름 쓸만해서 그냥 쓴다~
귀차니즘~ 고고싱~
package oddeye.utils { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; /** * ... * @author .... */ public class DepthUtils { private var _childs:Array = []; private var _parent:DisplayObjectContainer; private var _childDepths:Array = []; /** * 뎁스 조절~ * @param parent- 상위 부모객체를 등록한다. */ public function DepthUtils( parent:DisplayObjectContainer ) { _parent = parent; _childs = getChilds( parent ); _childDepths = getChildDepth( parent, _childs ); //Debug.to(_childs); } public function getChildDepth( parent:DisplayObjectContainer, childs:Array ):Array { var depths:Array = []; for ( var i:int = 0; i < childs.length; i++) { depths.push( parent.getChildIndex( childs[i]) ); } return depths; } /** * 자식들 등록~ * @param parent - 상위(부모)객체 * @return */ public function getChilds( parent:DisplayObjectContainer ):Array { var depthList:Array = []; for (var i:int = 0; i < parent.numChildren; i++) { depthList.push( parent.getChildAt( i ) ); } return depthList; } /** * 뎁스를 순서대로 다시 재 정렬~ */ public function resetDepth():void { var count:int = 0; for each(var child:DisplayObject in _childs) { _parent.setChildIndex( child, _childDepths[count] ); ++count; } } /** * 뎁스를 최상위로 올려놓는다~ * @param target - 최상위 뎁스를 지정할 객체 */ public function setHighestDepth(target:DisplayObject):void { _parent.setChildIndex( target, _parent.numChildren - 1); } /** * 뎁스를 뒤집는다. */ public function depthReverse():void { for ( var i:int = _childs.length-1; i >= 0; i-- ) { _parent.setChildIndex( _childs[i], _childs.length-1 ); } } } }사용법~ 일단 주의 할 점은 우선적으로 컨테이너를 등록해야 함~
자식이 추가되는 시점에다 해당 클래스를 인스턴화시켜야 한다.
그래야 DepthUtils클래스 내부에서 자식검색시 자식이 등록이 되기에.........
아래는 짧막하게 예시.....ㅋ
//전역에 선언 private var _depths:DepthUtils; private function init():void { for( var i:int=0;i<100;i++) { container.addChild( 썸네일 ); 썸네일.addEventListener( MouseEvent.MOUSE_OVER, onOver ); 썸네일.addEventListener( MouseEvent.MOUSE_OUT, onOut ); } _depths=new DepthUtils( container ); } private function onOver( e:MouseEvent ):void { _depths.setHighestDepth( DisplayObject( e.currentTarget ) ); } private function onOut( e:MouseEvent ):void { _depth.resetDepth(); }
728x90
반응형
'Programming language > Flash' 카테고리의 다른 글
mac에서 MouseEvent.MOUSE_WHEEL 적용하기.. (0) | 2012.02.08 |
---|---|
XML에서 이스케이프 시퀀스 삭제해버리기~ ㅎ (0) | 2012.02.08 |
getBounds(targetCoordinateSpace:DisplayObject) 요놈 물건이네~ (0) | 2012.02.08 |
나만 유용한 클래스2~ FlashVarUtils.as (0) | 2012.02.08 |
나만 유용한 클래스1~ StageRefer.as (0) | 2012.02.08 |
댓글
250x250
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- react
- 코도바
- Aptana
- git checkout -b
- 아이콘 폰트 만들기
- for of 구문
- icon font
- React.StrictMode
- svg 폰트
- git
- react-router-dom
- vue-router
- IntrinsicElements
- 앵귤러
- svg icon font
- Vue3
- 태그
- svg모션
- Angular
- anime.js
- CSS
- interceptors
- 반복문
- Intrinsic
- JsDoc
- cordova
- RefreshToken
- 자바스크립트
- 내장요소
- 리프래시토큰
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함