Tag Archive for 'Tip'

How to reduce the complie time with Flash IDE

Actionscript 의 덩치가 커지면서 Flash IDE 를 기본 액션에디터로 사용하는 것보다 인텔리젼트 기능이 탑재된 외부 에디터를 이용해 프로그래밍하는 것이 작업의 효율성 측면에서 상당한 개선 얻어올 수 있다.  이 포스팅 내용은 compile 도구로 반드시 Flash IDE 를 사용한다는 것을 전제로 한 내용이다.

작업 환경 조합으로는  Flash IDE + Eclipse(FDT) , Flash IDE  + Flashdevelop 과 같은 경우의 조합으로 많이 사용하는데 이런 외부 에디터를 사용할 경우 자동으로 syntax 를 사전에 체크해줘 compile 타임에 발생할 수 있는 코드의 문제점을 알아차릴 수 있다. 하지만 compile 을 위해 Flash IDE 와 외부에디터의 창을 이러저리 왔다갔다 하거나 compile 을 기다리는 시간 등,  compile 전체에 소모되는 시간이 생각보다 길다라고 느껴질 때가 있을것이다. 특히 수많은 클래스의 사용으로 더욱 그 시간이 길어질 때 더할 것이다. 그래서 이럴경우 compile 시간을 대폭(?) 줄일 수 있는 간단한 tip 하나를 소개할까 한다.

Flash IDE 에서 File -publish Settings… – Flash Tab – Settings…  를 실행하면 위와 같은 화면을 볼 수 있을것이다. 위 radio button 중 Warnings Mode 가 기본적으로는 체크되어있는데 이를 해제하자. Warnings Mode 는 As2.0 코드에서 As3.0 코드로 업데이트할때 발생할 수도 있는 Migration issue 를 리포팅해주는 기능이다.

따라서 체크를 해제하더라도 특별히 문제될건 없다. 이 기능을 해제하게 되면 컴파일 시간이 몰라볼 정도로 빨라지게 된다. 물론 영상이나 폰트를 임베드해서 컴파일이 오래걸리는 경우는 해당사항이 없다.  많은  클래스 파일을 사용하는 컨텐츠일 수록 효과가 크다.

quad core  , ram 4 GB , AS file 60개 정도의 환경으로 테스트 해본 결과 Warnings  Mode 를 체크를 했을 경우 16 sec 정도 걸리던 시간이 해제했을 경우에는 4 sec 정도로 4배이상 시간이 빨라졌다. 특별히 compile 안정성에 문제가 되는것이 아닌것 같으니 Flash IDE 를 사용하면서 class 를 많이 구성하여 사용하는 사람이라면 compile 에 걸리는 시간을 많이 줄일 수 있을 것이다.

Blink Effect

작업을 하다가 우연하게 발견한 팁이다.

전에는 아무생각없이 blink 효과를 구현하려면 그냥 간단하게 모션트윈으로 키프레임 에니메이션을 만들어서 사용하곤했다. 그런데 actionscript 로 blink 효과가 가능했다.

PropertyTweenEase class 는 이전 포스트에서 새롭게 구현한 방법을 사용했다.

import mx.transitions.easing.Bounce;
import com.dstrict.UB.util.transitions.tween.PropertyTweenEase;
 
function blink(){
	src_mc._alpha=0;
	PropertyTweenEase.tween(src_mc,{_alpha:100},Bounce.easeIn,8);
}
 
start_btn.onRelease=function(){
	blink();
}

플래시에서 기본으로 내장되어있는 이징 패키지 함수를 이용한 방법으로 Bounce 클래스는 뜻 그대로 뛰어오르는 느낌을 낼 수 있게 해준다.

따라서 Bounce 클래스에서 증가하는 느낌의 easeIn 함수를 사용하면 손쉽게 번쩍거리는 효과를 만들 수 있다.

Frame rates in the Flash Player

[퍼온글]
There have been numerous posts about frame rate issues in Flash over the years, sometimes with quite inconsistent tips and workarounds. As we are approaching the final phase of development for Flash Player 9 at Adobe our bug database is filling up with duplicate bugs concerning old known issues. What is frustrating to designers is that they perceive the Flash Player changing its behavior over the past few releases, although it has not. Well, that might actually be the problem.

Flash uses a relative timing model, meaning it does not really care about a global frame rate, but will instead try to enforce frame intervals as best as it can. Say you have f.ex. set your frame rate to 30 frames/sec. That means that the Flash Player will try to wait for 33 milliseconds before trying to display the next frame (excluding the time it takes to render the frame). This loose timing causes all kinds of problems. First, the Flash Player depends on high level OS events to deliver timing messages. In the worst case this means the use of WM_TIMER, dependence on the NetScape plugin API or in the best case we use multimedia timers provided by a special Internet Explorer API. Second, we round frame intervals to milliseconds since Windows and MacOS can’t support fractional time intervals. Third, the OS, the browser and the Flash Player will add overhead to the code executed on each frame, meaning that in the end the actual frame rate will sway between -10 to +5 frames/sec from the actual selected frame rate, depending in what environment you play it in. In Flash Player 8 and Flash Player 9 new overhead is originating mostly from the GC, something for which there is no workaround. As I said we do not calculate frame rates on a global basis so we can’t correct it actively.

Lets talk about maximum frame rates. In Internet Explorer this is 100 frames/sec. Why? Because the minimum time slice Windows timers can provide is 10 milliseconds. What about FireFox? FireFox does not use special timers and made a decision to limit the maximum frame rate for plugins. Why? The thinking is that users constantly complain that plugins take too much CPU time. A valid complaint I think and every designer who puts online ads out there at higher than 8-12 frames/sec and more that 2 or 3% CPU usage should be ashamed. While a single ad will not be a problem, most pages easily serve 2 or 3 ads on a single page.

The Mozilla team also decided that plugins would get no time when they are on a hidden tab so it would not render the browser unresponsive or less responsive by adding new tabs. So do not be surprised if your SWFs and FLVs do no play on hidden tabs. Apple went even a step further in Safari: If the browser is not active, plugins will only get about 4 frames/sec, mainly to save battery and avoid the dreaded noise of the fans. Try it, go to Google Video, play a video and then switch to another application. The frame rate will drop to about 4 frames/sec. While we could drive our own background thread and work around this, there is a reason they decided to take these steps. We would be ill advised to just hack around it.

What does this mean? Well, the frame rate you select does not really mean too much and you should not depend on it in a way to be accurate to the millisecond. This especially goes for ANY sort of synchronization. If you need synchronization your only choice is placing code in ActionScript which will ‘correct’ your timing or workarounds like placing a streaming sound on your main time line (In which case we use the audio device to report time correctly to the nanosecond. Due to bugs this does not work correctly on Linux right now, which is the reason audio and video are out of sync, even for FLVs :-( )

What does the future hold? As I explained in a earlier post we will likely add synchronization primitives into the player to allow SMILE like global timing at some point. But there is also a good chance we’ll limit what users can actually do when it comes to frame rates and overall CPU usage. There are various ways we could enforce low CPU usage. SWF files originating from a different domain (speaking advertisement) could get a lower priority and have a frame rate cap which would be user selectable. Secondly, with the advent of GPU support in the OS there will be a time when we finally add VBL wait, meaning tearing free drawing. In most cases this means the maximum frame rate will be 60 frames/sec. On high CPU load we might actually cut this into half, e.g. 30 frames/sec. OS X already does this in certain conditions.

firefox 와 safari 에서 유독 flash framerate 가 떨어지는 현상이 있다고 느꼈었는데… 강제로 플러그인에서 막아놓은 결과였다. 무분별한 framerate 의 사용으로 인해 사이트가 느려지고 사용자 컴퓨터가 다운되는 걸 막기 위한 궁여지책이 아닌가 생각든다.
flash player 9 에서는 framerate 0.1 에서 1000까지 지원한다고 나와있지만 과연 어느정도의 성능을 보여줄지..
위에서 언급한 내용대로라면 플레이어 근본을 바꾸지 않는다면 힘들다는 생각이 들지만 AS3 을 기반으로 제작한 flash player 9 의 성능은 AVM2 로 전혀 새로운 머신으로 탈바꿈했다고 하니 한번 기대해 볼만하다.
근데 사운드가 포함된 stream 파일도 200-300 framerate 를 지원할까궁금하다.

Image smoothing

플래시 8로 버전업이 되면서도 이미지 스케일 변경이나 회전시 안타깝게도 이미지 지글거림 현상 버그는 없어지지 않았다.
갤러리 사이트를 만들면서 이상한 현상을 하나 발견했는데 이 문제를 해결하는 방법은 fla 파일 최상의 루트에 한개의 프레임만 존재하면된다는 것이다..
기술적으로 이유는 설명할수는 없지만 이것을 염두에 두면 프로젝트 막판에 이유없이 이미지 울렁증이 일어나 스트레스 받는 일이 없을듯하다.

까먹으면 안되는데….반드시 상기!!!!!!타임라인에 넣었을때

타임라인에 직접 넣었을때                     프레임 한개에 넣었을때

IE 패치에 대한 Flash Extention

IE 패치로 플래시가 활성화되지 않는 문제점을 해결하는 방법이 Extention 으로 배포됐다.

전에는 js 파일로 일일이 플래시 파일을 따로 빼야되서 번거로웠는데 ..근데 코드를 덮어쓰면 지저분한 코드들이 생기는 듯싶다. 자세히는 안봤지만….

  1. publish setting 에서 html 탭의 템플릿을 Active Content Update 로 선택해서 html 을 생성.
  2. Command 메뉴에서 Apply Active Content Update(업데이트 컨텐츠 적용) 클릭 해서 전에생성한 html 페이지를 덮어쓴다.

Flash Extention download

Flash deep link

Tip  ://www.macromedia.com/kr/devnet/blueprint/articles/back_button.html
구현사이트 : Pet Market 응용 프로그램 센터
플래시 백버튼 구현을 하려고 고생했는데…이전에 하려고 했던 방법이랑 원리는 비슷하다. 다만 일일이 프레임에 들어가는 빈 html 페이지를 생성안해도 된다는 엄청난 팁…..
다음은 실행 흐름을 간략하게 요약한 것…..
1 .사용자가 Macromedia Flash 응용 프로그램의 상태를 변경합니다.
2 .Macromedia Flash 응용 프로그램에서 숨겨진 프레임을 호출하고 응용 프로그램의 현재 상태에 대한 정보를 전달합니다.
3 .숨겨진 프레임이 Macromedia Flash 응용 프로그램에서 전달한 정보를 읽은 다음, 이를 숨겨진 프레임 내에 내장된 Macromedia Flash 무비로 전달합니다.
4 .Macromedia Flash 무비는 LocalConnection 객체를 사용하여 이 정보를 주 Macromedia Flash 무비로 다시 전달합니다.
5 .브라우저의 뒤로 단추를 누르면 숨겨진 프레임이 이전 상태로 되돌아가서 이 상태를 Macromedia Flash 응용 프로그램으로 전달합니다.
6 .Macromedia Flash 응용 프로그램은 숨겨진 프레임에서 전송된 데이터를 기반으로 자신의 상태를 변경합니다.
공유객체(Shared Object)를 활용하면 좀더 디테일한 조정이 가능할듯…..

플래시 백버튼 구현을 하려고 고생했는데…이전에 하려고 했던 방법이랑 원리는 비슷하다. 다만 일일이 프레임에 들어가는 빈 html 페이지를 생성안해도 된다는 엄청난 팁…..

다음은 실행 흐름을 간략하게 요약한 것…..

  1. 사용자가 Macromedia Flash 응용 프로그램의 상태를 변경합니다.
  2. Macromedia Flash 응용 프로그램에서 숨겨진 프레임을 호출하고 응용 프로그램의 현재 상태에 대한 정보를 전달합니다.
  3. 숨겨진 프레임이 Macromedia Flash 응용 프로그램에서 전달한 정보를 읽은 다음, 이를 숨겨진 프레임 내에 내장된 Macromedia Flash 무비로 전달합니다.
  4. Macromedia Flash 무비는 LocalConnection 객체를 사용하여 이 정보를 주 Macromedia Flash 무비로 다시 전달합니다.
  5. 브라우저의 뒤로 단추를 누르면 숨겨진 프레임이 이전 상태로 되돌아가서 이 상태를 Macromedia Flash 응용 프로그램으로 전달합니다.
  6. Macromedia Flash 응용 프로그램은 숨겨진 프레임에서 전송된 데이터를 기반으로 자신의 상태를 변경합니다.

공유객체(Shared Object)를 활용하면 좀더 디테일한 조정이 가능할듯…..