FlashBuilder 프로젝트에서 가장 확실하게 rebuild하는 방법은 다음과 같다.
특히 소스가 변경되지 않고 assets등의 리소스 파일이 변경되었을때 쓰는 방법이다.
1. 일단 리소스 파일이 프로젝트파일 리스트에 추가가 되었을 경우에 FlashBuilder에서 일단 파일 목록을 Refresh 해준다.
2. Project를 Clean한다.
3. Project를 Clean한 직후에 Rebuild하겠다고 체크를 하면 자동으로 Rebuild한다. 이 Rebuild과정에서 추가된 리소스를 복사한다.
Showing posts with label Flash. Show all posts
Showing posts with label Flash. Show all posts
Saturday, April 25, 2015
Flex AIR Starling 예제
Flex환경에서 Starling을 사용할 경우에 처음에는 화면에 이미지가 도시되지 않는다. 이 문제의 해결 방법은 반드시 application에 backgroundAlpha="0"를 넣어주는 것이다.
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
addedToStage="application1_addedToStageHandler(event)" backgroundAlpha="0">
그리고 stats클래스의 경우에는 UIComponent에 실어서 application에 addElement하면 되고 Startling클래스의 경우는 바로 application.stage를 넘겨주면 된다.
protected function windowedapplication1_addedToStageHandler(event:Event):void
{
// TODO Auto-generated method stub
stats = new Stats();
var ui:UIComponent = new UIComponent();
ui.addChild(stats);
this.addElement(ui);
myStarling = new Starling(Game, stage);
myStarling.antiAliasing = 1;
myStarling.start();
}
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
addedToStage="application1_addedToStageHandler(event)" backgroundAlpha="0">
그리고 stats클래스의 경우에는 UIComponent에 실어서 application에 addElement하면 되고 Startling클래스의 경우는 바로 application.stage를 넘겨주면 된다.
protected function windowedapplication1_addedToStageHandler(event:Event):void
{
// TODO Auto-generated method stub
stats = new Stats();
var ui:UIComponent = new UIComponent();
ui.addChild(stats);
this.addElement(ui);
myStarling = new Starling(Game, stage);
myStarling.antiAliasing = 1;
myStarling.start();
}
Flex AIR Starling - This application is not correctly embedded (wrong wmode value)
Flex AIR에서 Starling 프로그래밍시 This application is not correctly embedded (wrong wmode value) 에러메세지가 발생할 경우에는 xml파일을 열어서 다음과 같이 수정해 준다.
<renderMode>direct</renderMode>
웹모드일 경우에는 wmode라는 parameter를 수정하는데 AIR에서는 xml이 direct값 설정을 담당한다.
만약 웹모드일 경우에는 html-template/index.template.html에서 다음과 같은 문장을 추가한다.
params.wmode = "direct";
<renderMode>direct</renderMode>
웹모드일 경우에는 wmode라는 parameter를 수정하는데 AIR에서는 xml이 direct값 설정을 담당한다.
만약 웹모드일 경우에는 html-template/index.template.html에서 다음과 같은 문장을 추가한다.
params.wmode = "direct";
Flash HTML을 탐색기에서 열었을 경우 보안문제
탐색기에서 웹용 Flash SWF가 포함된 HTML 파일을 열었을때 보안문제로 잘 안보이는 경우가 있다. 원인은 인증된 주소를 플래시에서 추가를 안해줬기 때문이다.
아래와 같이 웹에서 해주거나 제어판 플래시에서 원하는 로컬 폴더를 추가해 준다.
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manage
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manage
Flex SDK 3.6에서 4.6으로 마이그레이션
Flex SDK 3.6에서 작성된 app.xml파일을 4.6으로 빌드하려고 하면 다음과 같은 에러메세지가 발생한다.
invalid application descriptor versionnumber must have a non-empty value
1. 일단 아래의 SDK버전 숫자를 1.5.3 -> 3.1로 변경한다.
<application xmlns="http://ns.adobe.com/air/application/3.1">
2. 버전 정보를 변경한다.
Flex SDK 3.6: <version>v1</version>
Flex SDK 4.6: <versionNumber>0.0.0</versionNumber>
invalid application descriptor versionnumber must have a non-empty value
1. 일단 아래의 SDK버전 숫자를 1.5.3 -> 3.1로 변경한다.
<application xmlns="http://ns.adobe.com/air/application/3.1">
2. 버전 정보를 변경한다.
Flex SDK 3.6: <version>v1</version>
Flex SDK 4.6: <versionNumber>0.0.0</versionNumber>
FlashBuilder out of memory 해결
An out of memory error has occurred. Consult the "running eclipse" section of the read me file for information on prevention this kind of error in the future.
you are recommended to exit the workbench.
Subsequent errors may happen and may terminate the workbench without warning.
See the .log file for more details.
Do you want to exit the workbench?
그럴때는 FlashBuilder.ini를 열어서 다음과 같이 수정하여 메모리 할당량을 늘려준다.
-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-XX:PermSize=256m
you are recommended to exit the workbench.
Subsequent errors may happen and may terminate the workbench without warning.
See the .log file for more details.
Do you want to exit the workbench?
그럴때는 FlashBuilder.ini를 열어서 다음과 같이 수정하여 메모리 할당량을 늘려준다.
-Xms512m
-Xmx1024m
-XX:MaxPermSize=512m
-XX:PermSize=256m
Flash AIR for Android default orientation 고정하기
app.xml
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
private function onAddedToStage( event:Event ):void {
stage.addEventListener( Event.RESIZE, onStageResize );
NativeApplication.nativeApplication.addEventListener( Event.ACTIVATE, onNativeApplicationActivate );
}
private function onStageResize( event:Event ):void {
checkForOrientationChange();
}
private function onNativeApplicationActivate( event:Event ):void {
checkForOrientationChange();
}
private function checkForOrientationChange():void {
if ( height > width ) {
if ( stage ) {
stage.setOrientation( StageOrientation.ROTATED_RIGHT );
} else {
// The first ACTIVATE event occurs before the Application has been added to the stage
callLater( checkForOrientationChange );
}
}
}
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
private function onAddedToStage( event:Event ):void {
stage.addEventListener( Event.RESIZE, onStageResize );
NativeApplication.nativeApplication.addEventListener( Event.ACTIVATE, onNativeApplicationActivate );
}
private function onStageResize( event:Event ):void {
checkForOrientationChange();
}
private function onNativeApplicationActivate( event:Event ):void {
checkForOrientationChange();
}
private function checkForOrientationChange():void {
if ( height > width ) {
if ( stage ) {
stage.setOrientation( StageOrientation.ROTATED_RIGHT );
} else {
// The first ACTIVATE event occurs before the Application has been added to the stage
callLater( checkForOrientationChange );
}
}
}
Flash timestamp 얻기
아래는 퍼포먼스 측정을 하기위해서 timestamp을 얻는 소스이다.
time중에서 시,분,초 말고 1970년부터 누적 millisecond를 얻을수 있다.
물론 date.hours, date.minutes...를 하면 개별 시간을 얻을수 있다.
package
{
import flash.display.Sprite;
import flash.events.Event;
[SWF(frameRate=30,width=800,height=600)]
public class Test1 extends Sprite
{
public function Test1()
{
this.addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(evt:Event):void
{
var date:Date = new Date();
trace(date.time);
}
}
}
time중에서 시,분,초 말고 1970년부터 누적 millisecond를 얻을수 있다.
물론 date.hours, date.minutes...를 하면 개별 시간을 얻을수 있다.
package
{
import flash.display.Sprite;
import flash.events.Event;
[SWF(frameRate=30,width=800,height=600)]
public class Test1 extends Sprite
{
public function Test1()
{
this.addEventListener(Event.ENTER_FRAME, enterFrame);
}
private function enterFrame(evt:Event):void
{
var date:Date = new Date();
trace(date.time);
}
}
}
Thursday, September 18, 2014
FlashBuilder에서 FlexFormatter 사용하기
FlashBuilder에서는 Flex 소스의 Formatting을 해주는 FlexFormatter라는 플러그인이 있다.
이 플러그인을 설정하면 여러가지 소스를 단일한 코딩 스타일로 맞출 수가 있다.
메뉴 [Help] - [Install New Software]를 클릭
Add Repository를 하여 FlexFormatter를 수동입력하고 다음과 같이 주소를 입력
http://flexformatter.googlecode.com/svn/trunk/FlexFormatter/FlexPrettyPrintCommandUpdateSite
이제 주소가 생겼으니 Select All하여 설치하자
다 설치하면 위에 /*/* /* ... Fx 이런 툴바가 새로 뜬다. 이게 FlexFormatter 관련 툴바이다.
Preferences에서도 FlexFormatter가 있다. 나는 개인적으로 Tab을 Space로 하는 것을 좋아하니 설정한다.
뭐 기타 잡다한 코딩 스타일을 설정할수 있다.
단 ActionScript(*.as)와 MXML(*.mxml)이 분리되어 있다.
써보면 정말 좋다는걸 알수 있다.
이클립스가 단축키가 Visual Studio와 달라서 코딩스타일 맞추는데 애먹는데 이것을 사용하면 일단 코딩 후에 나중에 다 맞출 수 있다.
이 플러그인을 설정하면 여러가지 소스를 단일한 코딩 스타일로 맞출 수가 있다.
http://flexformatter.googlecode.com/svn/trunk/FlexFormatter/FlexPrettyPrintCommandUpdateSite
이제 주소가 생겼으니 Select All하여 설치하자
이클립스가 단축키가 Visual Studio와 달라서 코딩스타일 맞추는데 애먹는데 이것을 사용하면 일단 코딩 후에 나중에 다 맞출 수 있다.
Flash ActionScript에서 Object ID 확인하기
어떤 오브젝트의 메모리 주소 포인터(@b123c11) 또는 유니크한 ID를 보고 싶을때가 있다.
메모리 주소를 AcrionScript에서 보기위해서는 다음과 같은 클래스를 작성하여 호출하면 된다.
package Lib
{
public class DebugUtils
{
public static function getObjectMemoryHash(obj:*):String
{
var memoryHash:String;
try
{
FakeClass(obj);
}
catch (e:Error)
{
memoryHash = String(e).replace(/.*([@|\$].*?) to .*$/gi, '$1');
}
return memoryHash;
}
}
}
internal final class FakeClass { }
메모리 주소를 AcrionScript에서 보기위해서는 다음과 같은 클래스를 작성하여 호출하면 된다.
package Lib
{
public class DebugUtils
{
public static function getObjectMemoryHash(obj:*):String
{
var memoryHash:String;
try
{
FakeClass(obj);
}
catch (e:Error)
{
memoryHash = String(e).replace(/.*([@|\$].*?) to .*$/gi, '$1');
}
return memoryHash;
}
}
}
internal final class FakeClass { }
Monday, September 1, 2014
Flex Module Compile
하나의 Flex 프로젝트에서 여러 개의 SWF 파일이 생성되는 경우가 있다.
이는 특정 MXML 파일을 Module이라고 해서 별도의 SWF 파일로 컴파일 한후에 그것을 Load Module하여 사용하는 것을 말한다. 윈도우의 Visual C++에서 DLL을 만드는 것과 유사하다.
다음과 같이 프로젝트 속성에서 Flex Modules 탭으로 간다음에 SWF로 생성할 MXML을 고르면 다음 빌드시 SWF파일이 만들어진다.
이는 특정 MXML 파일을 Module이라고 해서 별도의 SWF 파일로 컴파일 한후에 그것을 Load Module하여 사용하는 것을 말한다. 윈도우의 Visual C++에서 DLL을 만드는 것과 유사하다.
다음과 같이 프로젝트 속성에서 Flex Modules 탭으로 간다음에 SWF로 생성할 MXML을 고르면 다음 빌드시 SWF파일이 만들어진다.
Subscribe to:
Posts (Atom)