2010년 10월 22일 금요일

IOS view 메모리관리 팁

delloc 메소드에
자신이 생성한 UI객체는 release해준다!

-(void) delloc {
      [myui release];
}

viewDidUnload 메소드에
자신이 생성한 UI객체를 nil로 할당 해준다!

 -(void) viewDidUnload {
       self.myui = nil;
}

IOS 키 입력창 제거 하는 방식 정리

IOS 개발시 키보드 입력창을 사라지게 하는 방법이 두가지 있다
중요하지 않다고 생각하는지 자꾸 잊어버린다.

1. 컨트롤러에 testFieldDondEditing 메소드를 추가 하는 방법
    ex) -(IBAction)textFieldDoneEditing:(id)sender{
                [sender resignFirstResponder];
          }

1번의 방법은 키 입력시 Done이라는 버튼이 있을 경우이다
허나 숫자 전용 입력키에는 Done버튼이 없다!

이럴경우엔 뷰영역(백그라운드)를 클릭하면 사라지게 하는 방법으로 처리

2.백그라운드에 탭, 또는 클릭 이벤트 콜백을 생성
   - (IBAction)backgroundClick:(id)sender{
             [textfield resingFirstResponder]; //텍스트 필드 갯수만큼 추가
      }

    이때! 뷰의 클래스를 UIView에서 UIControl로 변경 해주어야 한다
     UIControl은 UIView를 상속함

   

2010년 10월 21일 목요일

flash touch 샘플코드

Hi. Could someone explain how come one both of these examples work when compiled to iPhone, but only the Example2 works with MacBook Pro Touchpad? MTouch works with gestures, but not with the TouchEvent.

Note that the Example1 has a maximum touches left, but when I do the same thing for the Example2 I get "zero" as the result, but again... it still works on the touchpad in MacBook.

Seems to me that it's the Multitouch.inputMode = MultitouchInputMode.GESTURE and TransformGestureEvent. Note that in order to move the image in the Example2 example you need to use both fingers - this is kind of crappy. I wanted to add a regular TouchEvent to handle simple moving or even tracing something to the output box (look at the code), but it simply doesn't work.

Also... it would be great if someone could show me the way of testing this with a mouse - basically can I somehow code for taps and touch events, but test with my mouse (mouseevent) without rewriting or commenting out a lot of code?

Thanks

Example1

import flash.display.Sprite;
import flash.events.TouchEvent;
import flash.text.AntiAliasType;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;


var dots:Object;
var labels:Object;
var labelFormat:TextFormat;
var dotCount:uint;
var dotsLeft:TextField;
var LABEL_SPACING:uint = 15;


this.labelFormat = new TextFormat();
labelFormat.color = 0xACF0F2;
labelFormat.font = "Helvetica";
labelFormat.size = 11;

this.dotCount = 0;

this.dotsLeft = new TextField();
this.dotsLeft.width = 300;
this.dotsLeft.defaultTextFormat = this.labelFormat;
this.dotsLeft.x = 3;
this.dotsLeft.y = 0;
this.stage.addChild(this.dotsLeft);
this.updateDotsLeft();

this.dots = new Object();
this.labels = new Object();

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
this.stage.addEventListener(TouchEvent.TOUCH_BEGIN, onTouchBegin);
this.stage.addEventListener(TouchEvent.TOUCH_MOVE, onTouchMove);
this.stage.addEventListener(TouchEvent.TOUCH_END, onTouchEnd);


function onTouchBegin(e:TouchEvent):void
{
if (this.dotCount == Multitouch.maxTouchPoints)
{
return;
}
var dot:Sprite = this.getCircle();
dot.x = e.stageX;
dot.y = e.stageY;
this.stage.addChild(dot);
dot.startTouchDrag(e.touchPointID, true);
this.dots[e.touchPointID] = dot;

++this.dotCount;

var label:TextField = this.getLabel(e.stageX + ", " + e.stageY);
label.x = 3;
label.y = this.dotCount * LABEL_SPACING;
this.stage.addChild(label);
this.labels[e.touchPointID] = label;

this.updateDotsLeft();
}

function onTouchMove(e:TouchEvent):void
{
var label:TextField = this.labels[e.touchPointID];
label.text = (e.stageX + ", " + e.stageY);
}

function onTouchEnd(e:TouchEvent):void
{
var dot:Sprite = this.dots[e.touchPointID];
var label:TextField = this.labels[e.touchPointID];

this.stage.removeChild(dot);
this.stage.removeChild(label);

delete this.dots[e.touchPointID];
delete this.labels[e.touchPointID];

--this.dotCount;

this.updateDotsLeft();
}

function getCircle(circumference:uint = 40):Sprite
{
var circle:Sprite = new Sprite();
circle.graphics.beginFill(0x1695A3);
circle.graphics.drawCircle(0, 0, circumference);
return circle;
}

function getLabel(initialText:String):TextField
{
var label:TextField = new TextField();
label.defaultTextFormat = this.labelFormat;
label.selectable = false;
label.antiAliasType = AntiAliasType.ADVANCED;
label.text = initialText;
return label;
}

function updateDotsLeft():void
{
this.dotsLeft.text = "Touches Remaining: " + (Multitouch.maxTouchPoints - this.dotCount);
}


Example2


import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.events.TransformGestureEvent;
import flash.events.TouchEvent;
import flash.text.TextField;
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.MouseEvent;


Multitouch.inputMode = MultitouchInputMode.GESTURE;
var sq:Sprite;


sq = new Sprite();
addChild(sq);


this.addEventListener(TransformGestureEvent.GESTURE_ZOOM, scaleObj);
this.addEventListener(TransformGestureEvent.GESTURE_PAN, panObj);
this.addEventListener(TransformGestureEvent.GESTURE_ROTATE, rotObj);
this.addEventListener(TouchEvent.TOUCH_TAP, taptap);

var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, addImg);
l.load(new URLRequest("http://lobby.blox.pl/resource/LOBBY_logo1.jpg"));

function disp():void{
dispatchEvent(new Event(TouchEvent.TOUCH_TAP));
}

function taptap(e:TouchEvent):void{
trace("this doesn't work for some reason");
}

function addImg(e:Event):void{
sq.addChild(e.target.content);
sq.scaleY = sq.scaleX = .2;
}


function rotObj(e:TransformGestureEvent):void{
sq.rotation += e.rotation;
}


function panObj(e:TransformGestureEvent):void{
sq.x += e.offsetX * 2;
sq.y += e.offsetY * 2;
}


function scaleObj(e:TransformGestureEvent):void{
sq.scaleX *= e.scaleX;
sq.scaleY *= e.scaleY;
}

trace(Multitouch.maxTouchPoints);

2010년 10월 14일 목요일

플래시 타임라인을 액션스크립트로 제어 관련

타임라인의 프레임 넘버를 감지하여 액션을 추가하는 방법
addFrameScript 메소드를 사용한다.

targetMC.addFrameScript(5, testFunc);
function testFunc():void
{
       trace("testFunc");
}

* 5프레임 이후에 testFunc가 호출 된다.
 액션이 일어날 프레임 넘버에서 1을 빼서 기입하도록 한다.
 

타임라인에서 라벨링 되어있는 프레임 또는 프레임 종료시점을
찾아서 이벤트로 디스패치하는 클래스를 아래에서 제공한다.
http://www.adobe.com/devnet/flash/articles/timelinewatcher.html

2010년 10월 11일 월요일

php 에러 노출 예외설정

php개발중 Function eregi() is deprecated... 라는 에러가 노출될때가 있다 
대략 앞으로 없어질 함수이니 쓰지 말도록~ 라는 내용인데 


함수가 동작을 안한는건 아니니 에러 문구만 좀 안나타났으면 할때 
php.ini파일의 에러 리포팅 부분에 아래와 같이 설정해서 에러 노출을 회피할수 있다.

error_reporting = E_ALL & ~E_DEPRECATED 



2010년 10월 10일 일요일

air sqlite 데이터베이스 성능향상 팁

AIR 와 Sqlite 로 개발했던 소스를 개선 하는 과정에서
성능향상 팁을 발견했다.

모바일용 AIR 어플을 개발할때 성능향상 최적화는 필수! 

http://help.adobe.com/ko_KR/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7d47.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7d45


추가로 sqlStatement 에서 매개별수를 이용하여 쿼리문을
확장성있게 사용하는 방법

http://help.adobe.com/ko_KR/AIR/1.5/devappsflash/WS5b3ccc516d4fbf351e63e3d118666ade46-7d47.html#WS5b3ccc516d4fbf351e63e3d118666ade46-7d45

2010년 10월 7일 목요일