블로그 이동


[Flex] SkinnablePopUpContainer 팝업창 드래그 Flex

<?xml version="1.0" encoding="utf-8"?>
<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">
<fx:Script>
<![CDATA[
import mx.events.FlexEvent;
protected function btnPopUp_clickHandler(event:MouseEvent):void
{
var _popUp:PopUp = new PopUp;
_popUp.open(this,true);
}
protected function skinnablePopUp_creationCompleteHandler(event:FlexEvent):void
{
// TODO Auto-generated method stub
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Button id="btnPopUp" label="팝업" click="btnPopUp_clickHandler(event)"/>
</s:Application>


=================PopUp.mxml==============
<?xml version="1.0" encoding="utf-8"?>
<s:SkinnablePopUpContainer xmlns:fx="http://ns.adobe.com/mxml/2009" 
  xmlns:s="library://ns.adobe.com/flex/spark" 
  xmlns:mx="library://ns.adobe.com/flex/mx" width="200" height="150"
  creationComplete="skinnablepopupcontainer1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import mx.core.FlexGlobals;
import mx.events.FlexEvent;
protected function skinnablepopupcontainer1_creationCompleteHandler(event:FlexEvent):void
{
this.addEventListener(MouseEvent.MOUSE_DOWN,thisMouseDownEventHandler);
this.addEventListener(MouseEvent.MOUSE_UP,thisMouseUpEventHandler);
}
protected function thisMouseDownEventHandler(event:MouseEvent):void
{
var rec:Rectangle = new Rectangle(0,0,FlexGlobals.topLevelApplication.width - this.width,FlexGlobals.topLevelApplication.height - this.height);
this.startDrag(false,rec);
}
protected function thisMouseUpEventHandler(event:MouseEvent):void
{
this.stopDrag();
}
protected function btnClose_clickHandler(event:MouseEvent):void
{
this.close();
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Rect top="0" bottom="0" left="0" right="0">
<s:fill>
<s:SolidColor color="red" alpha="0.8"/>
</s:fill>
</s:Rect>
<s:Button id="btnClose" label="닫기" click="btnClose_clickHandler(event)" verticalCenter="0" horizontalCenter="0"/>
 
</s:SkinnablePopUpContainer>





testSkinnablePopUp.swf

[Air] MP3 플레이어 Air




로컬 MP3 파일을 읽어 오는게 아니라 원격 MP3 파일을 읽어서 재생 합니다.

[Flex Mobile] 텍스트 입력할때 키보드가 뜨면서 화면이 자동으로 키보드 위로 올라가는 문제 Flex Mobile

텍스트 입력 할때 softKeyBoard가 뜨면서 어플 자체가 키보드 위로 올라가는 현상이 있는데요 간단하게 해결 할 수 있네요 ㅡㅡ;;

메인.mxml 에서 
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
xmlns:s="library://ns.adobe.com/flex/spark"
resizeForSoftKeyboard="true" >

resizeForSoftKeyboard="true"  가 디폴트 인데요

resizeForSoftKeyboard="false" 를 해주면 키보드 위로 어플이 올라가는 현상이 없어지고 스크롤이 있다면 스크롤이 자동으로 텍스트 입력 하는 TextInput 컴퍼넌트 위치로 내려가네요 ㅋㅋ 

[Flex Mobile] FileReference 사용이 가능하네요 ㅋ Flex Mobile

다운로드 기능만 사용해봤는데 다운 잘 됩니다.
사용 방법은 기존 Flex랑 같구요 다만

app.xml 에서 권한을
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
열어주셔야 됩니다. 

[Flex Mobile] navigator.pushView() 와 navigator.popView() 할때 화면 전환 모드 바꾸기 Flex Mobile


<fx:Declarations>
<s:FlipViewTransition id="transition" duration="1000" mode="card" />
<s:FlipViewTransition id="transition1" duration="1000" mode="cube" />
<s:CrossFadeViewTransition id="cTransition" duration="1000" />
</fx:Declarations>

정의 한다음에

navigator.pushView(view,null,null,transition);
navigator.popView(transition);

쓰면 되네요 

card는 카드 넘기는 것처럼 화면이 전환 되고  cube는 큐브를 돌리는 것처럼 바뀌고
 s:CrossFadeViewTransition  는 전에 화면이 사라지면서 천천히 다음 화면으로 바뀌는 모드네요.

[Flex Mobile] 절전 모드로 전환 되지 않도록 설정 Flex Mobile

app.xml 에 manifest 권한에
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
정의 하고

메인.mxml 초기화 함수에 
NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
NativeApplication.nativeApplication.addEventListener(Event.USER_IDLE,idleHandler);

protected function idleHandler(event:Event):void
{
trace(event);
}

하면 강제로 대기 모드 버튼을 누루지 않은 이상 계속 화면이 켜져있는 상태로 되네요.~

[Flex mobile] Back 키 눌렀을때 자동으로 어플 종료되는것을 Alert 창을 띄어 어플을 종료 하는 방법(?) Flex Mobile

특정 어플들을 보면 Back키를 눌렀을때 한번더 누루면 종료 된다고 메세지가 뜨거나 창을 띄어서 예 아니오 여부를 묻고 어플을 종료 하는 방식이 있는데요 Flex mobile에서 어떻게 구현 해야 되나 생각 하다가 간단한 방법으로 해결 했습니다.

메인.mxml 파일에 

변수 
private var alertShowYb:Boolean = false;  // 창을 한번만 띄움
초기화 함수에 
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN,backKeyDownEventHandler);
NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_UP,backKeyUpEventHandler);

정의 하고 

이벤트 핸들러로 

protected function backKeyDownEventHandler(event:KeyboardEvent):void
{
if(event.keyCode  == Keyboard.BACK){
event.preventDefault();
}
}
protected function backKeyUpEventHandler(event:KeyboardEvent):void
{
if(event.keyCode  == Keyboard.BACK){
event.preventDefault();
if(!alertShowYb){
Alert.show(this,'종료하시겠습니까?','종료',Alert.TYPE_YESorNO,alertCloseHandler);   // Alert 창은 만듬.
alertShowYb = true;
}
}
}

private function alertCloseHandler(event:PopUpEvent):void
{
alertShowYb = false;
if(event.data == Alert.YES){
NativeApplication.nativeApplication.exit();
}
}

[Flex] 자동으로 닫히는 Alert Flex

package AutoClose
{
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.controls.Alert;
import mx.effects.Fade;
import mx.effects.Move;
import mx.effects.Parallel;
import mx.effects.easing.Elastic;
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
public class CALERT extends Alert
{
private static var alert:Alert;
private static var alertTimer:Timer;
private static var parellel:Parallel;
private static var _fade:Fade;
private static var _move:Move;
public function CALERT()
{
super();
}
private static function init():void{
_fade = new Fade;
_fade.duration = 500;
_move = new Move;
_move.yFrom = 0;
_move.easingFunction = Elastic.easeOut;
_move.duration = 1000;
parellel = new Parallel;
parellel.addChild(_fade);
parellel.addChild(_move);
}
public static function show(text:String = "", title:String = "알림", parent:Sprite = null ,delay:Number = 3000):Alert{
init();
alertTimer = new Timer(delay,1);
alertTimer.addEventListener(TimerEvent.TIMER_COMPLETE, removeAlert);
alertTimer.start();
Alert.yesLabel = '확인';
alert = Alert.show(text,title,Alert.YES,parent,alertClose);
alert.isPopUp = false;
alert.cacheAsBitmap = true;
alert.setStyle('creationCompleteEffect',parellel);
return alert;
}
private static function alertClose(event:CloseEvent):void
{
// TODO Auto Generated method stub
alertTimer.stop();
}
private static function removeAlert(event:TimerEvent):void
{
// TODO Auto-generated method stub
alertTimer.stop();
PopUpManager.removePopUp(alert);
}
}
}

지정한 시간이 지나면 자동으로 close 되는 Alert 창입니다.

사용 방법은 
CALERT.show('내용');

[FLEX] TextArea 자동 크기 변환 Flex

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" xmlns:local="*">
<mx:Script>
<![CDATA[
protected function textarea1_changeHandler(event:Event):void
{
// TODO Auto-generated method stub
trace(NaN);
}
protected function testTe_changeHandler(event:Event):void
{
// TODO Auto-generated method stub
testTe.height = testTe.textHeight + testTe.baselinePosition;
canvas.verticalScrollPosition = canvas.maxVerticalScrollPosition;
}
]]>
</mx:Script>
<mx:Canvas id="canvas" width="100%" height="150">
<mx:TextArea id="testTe" width="100%" height="100%" verticalScrollPolicy="off" change="testTe_changeHandler(event)"
maxHeight="200" backgroundAlpha="0" borderStyle="none" borderThickness="0" focusAlpha="0"/>
</mx:Canvas>
</mx:Application>


1 2 3 4 5 6


통계 위젯 (화이트)

157
22
9892