본문 바로가기

전체 글

외부 SWF파일 사용하기 public function RuntimeAssetExplorer() { var path:URLRequest = new URLRequest("GeometricAssets.swf"); //LoaderContext 클래스는, Loader 클래스를 사용해, SWF 파일등의 미디어를 // 로드하는 옵션을 지정합니다. var context:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain); var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener (Event.COMPLETE,runtimeAssetsLoadComplete); loader.load(path,.. 더보기
가변인수와 default 인수 VC++에서 ... 을 사용하듯 AS에서도 ... 을 응용하고 있다. 그리고 디폴트 인수는 VC++과 동일하다.. function test(separator:String, ...args:Array):void { trace(rest.join(seperator)); } --> test(":", a,b,c,d); --> 출력: a:b:c:d test(".", 0,1,2,3); --> 출력: 0.1.2.3 더보기
as 의 기능 // RuntimeAssetExplorer.as 예제에서.. private function addAssetToStage(me:MouseEvent):void { // 캐스팅 시 타입이 맞지 않으면 예외가 발생하지만 as 를 써서 강제 캐스팅을 하게 되면 // 예외 발생이 아니라 디폴트 값을 넘겨준다, // 가령 var a:Sprite = new Sprite(Array()): --> 예외 발생 // var a:Sprite = new Array() as Spite; --> null 반환 // var a:Number = new Array() as Number; --> 0 을 반환 var AssetClass:Class = getDefinitionByName(cb.selectedItem.data) as Class;.. 더보기
객체 드래그 앤 드랍 private function startDragAsset(event:MouseEvent):void { var target:MovieClip = MovieClip(event.currentTarget); target.startDrag(); } private function stopDragAsset(event:MouseEvent):void { var target:MovieClip = MovieClip(event.currentTarget); target.stopDrag(); } 복잡하게 좌표로 할 필요가 없다... 정말 편하네.. ㅠㅠ 내가 원하는 객체로 잘 캐스팅만 해주면 된다. 더보기
fla 파일과 as 파일의 연동. 더보기
Sprite 클래스의 특징 Sprite object는 무비 클립과 닮아 있습니다만, 타임 라인을 가지지 않습니다. Sprite 는, 타임 라인을 필요로 하지 않는 object에 적절한 기본 클래스입니다. 예를 들어, Sprite 는, 통상은 타임 라인을 사용하지 않는 유저 인터페이스 (UI) 컴퍼넌트의 논리 기본 클래스가 됩니다. MovieClip 클래스 (Sprite 클래스의 서브 클래스)에서 buttonMode property를 사용하면, 버튼에 몇개의 기능을 추가할 수가 있습니다. _up, _over, 및 _down 의 label가 붙은 프레임을 짜넣으면, 자동 상태 변화가 됩니다 (이전의 버젼의 ActionScript 로 제공되고 있던, 버튼으로서 사용되는 무비 클립용의 기능과 닮은 기능). 이러한 자동 상태 변화는, 스프.. 더보기
프로퍼티를 클래스로... package com.example.programmingas3.playlist { /** * A pseudo-enum representing the different properties by which a Song instance * can be sorted. */ public final class SortProperty { // ------- Public Constants ------- // These constants represent the different properties // that the list of songs can be sorted by, // providing a mechanism to map a "friendly" name to the actual property name pub.. 더보기
AS3 에서 array 사용... VC++에서 typedef 를 이용한 것 처럼.. Array를 이용할 수 있다.. import testArrItem; // 사용자 지정 클래스.. public class testArr { public function testArr() { } public function test():void { var arr:Array = new Array(); var item:testArrItem = new testArrItem(); item.m_name = "1-name"; item.m_id = 24; arr.push(item); trace(arr[0].m_name, arr[0].m_id); } } 제대로 값이 출력된다. 더보기