Monthly Archive for July, 2006

Mouse image scroll

mouse 반응에 따라 그리고 화면 사이즈에 따라 image movieclip 이 scroll 되도록 제작하려면 상황이 제작할때마다 달라 상당히 번거로웠는데 모든 경우를 일반활 할 수 있도록 모듈을 제작했다.
scroll_mc —> 스크롤될 무비클립

scroll_mc._height > Stage.height 일 경우에만 –> scroll Active!!!

*limit position setting : mouse 가 화면에서 움직일경우 scroll_mc이 움직일수 있는 한계값을설정

Top–> Stage.height – scroll_mc._height

Bottom—> 0

*화면사이즈에 비례한 단위 움직임 계산

Stage.height : (Bottom-Top) = 1 : x

x= -(Bottom-Top)/Stage.height

= Top/Stage.height

= Stage.height – scroll_mc._height / Stage.height

= 1- scroll_mc._height/Stage.height

따라서 , 현재 mouse point 좌표값(Ymouse) 에서 scroll_mc 의 Target position !!!

==> Ymouse * 1- scroll_mc._height/Stage.height

Actionscript initialization

flash에서 어느정도 actionscript 를 다룰줄 아는 사람이라면 output 창을 통해 출력되는 에러메시지나 오류를 해석해서 문제를 해결할 수 있다. 하지만 정말정말 코딩 자체에 사소한 실수가 없다는 생각이 들때,…..

왜 생각한대로 작동안하는걸까?…이건 분명 프로그램 버그일거야….

라는 생각이 들때가 있다…..하지만 컴퓨터는 거짓말을 하지 않는다. 분명 어떤 문제로 인해 생각한대로 작동하지 않을뿐이다.
이런 문제의 상당부분은 바로 플래시의 초기화 문제이다.(많은 경우가 이런 상황에 부딪힐수 있다는 의미) 즉 무비클립을 attach 하거나 컴포넌트(component) 를 사용했을경우…..특히 자주 발생하는 듯 싶다.

무비클립의 초기화 과정은 타임라인 이후에 일어난다. 따라서 제아무리 처리속도가 빠르다 하더라도 덩치가 큰 프로그램일경우 초기화하는  과정에 어느정도  딜레이가 발생하게 된다.

특히 웹에서 실행할경우 로딩을 고려하지 않고 제작할 경우 문제가 심각해진다. 또한 클래스로 제작할경우 즉 좀 복잡한 로직에 의해 구현되는 어플리케이션이나 사이트일 경우 연결한 무비클립이나 컴포넌트와 같은 프레임 상에 클래스를 사용하여 코딩을 했을 경우 초기화 타임으로 인한 오류가 발생할수 있다는 것이다.

플래시에서 제공하는 컴포넌트는 특히 덩치가 더 커서 상대적으로 프레임에 나타났을때 인식하는 속도가 느리다.(사람이 체감하지 못하겠지만 컴퓨터처리속도는 아마도…)

따라서 컴포넌트를 사용할경우 그것에 해당하는 클래스의 처리순서를 똑 어느정도 딜레이를 주어 처리한다면 초기화 문제를 해결할수 있을 것이다. 1frame 정도 후에 처리한다면 초기화하고도 충분한(?) 시간…..^^

/*----------------------------------------------------------------------------------
  @description 프레임 딜레이 함수
  @param scope : Object, 실행할 함수의 스코프
  @param callback : Function, 콜백함수
  @param delayFrame : Number, 딜레이프레임
*---------------------------------------------------------------------------------/
 
  public static function frameDelay():Void{
    var obj = arguments.shift();
    var func = arguments.shift();
    var delayFrame=arguments.shift();
 
   var p:Array=arguments;
   var mc:MovieClip=_root.createEmptyMovieClip("frameDelay",_root.getNextHighestDepth());
 
   mc.onEnterFrame=function(){
    trace(delayFrame);
    delayFrame--;
    if(delayFrame<1){
 
     delete  this.onEnterFrame;
     func.apply(obj,p);
        this.removeMovieClip();
     }
   }
 
  }

Eclipse and Mac OS X

[퍼온글] 출처 http://developer.apple.com/tools/eclipse.html

Editor’s Note: To learn more about Eclipse and Java development on Mac OS X, register for the Apple Worldwide Developers Conference 2004.

Thanks to its highly optimized but fully standard Java implementation, Mac OS X has garnered a reputation amongst developers as an excellent platform for developing and deploying Java applications. The most recent release of Eclipse, the well-respected open-source IDE, for Mac OS X only strengthens the case, as this flexible and highly extensible tool is a favorite of many Java developers. This article provides a quick overview of Eclipse for Mac OS X and explains how to download the latest version and get started.

What is Eclipse?

Eclipse was originally designed for building integrated development environments (IDEs), that were versatile enough to create applications for a range of programming languages. The intention was to provide tools makers with an IDE that would include mechanisms and rules that would consistently result in seamless tools integration. Since then, Eclipse has evolved to include an IDE that provides benefits for a wide range of development projects.

Because it is Java-based, Eclipse includes the Java Development Kit (JDK); and yet its architecture supports all major programming languages from C/C++ to Cobol.

Eclipse is a free download, and is available on a number of platforms. Since IBM launched Eclipse in November 2001, more than 18 million download requests have been logged from over 125 countries.

A growing consortium of high-profile companies and organizations are actively supporting and extending Eclipse’s ongoing development and giving the platform momentum. These organizations contribute support and technology, and they determine the direction and scope of Eclipse’s growth.

Highly Extensible

Because it is a highly extensible, open framework, Eclipse allows you to use—and create your own—plug-in tools to extend the basic Eclipse IDE for developing your applications.

This means that if you are developing an application using Eclipse for Mac OS X, and you need a special tool to facilitate development on your project, you can choose from literally hundreds of available plugin tools that work seamlessly with Eclipse and with any of the plugin tools you are using.

These plugins, which have been developed by a wide variety of companies and individuals, run the gamut from traditional coding tools such as source code analyzers, graphical layout tools, and compilers to productivity enhancers like bug trackers, source code managers, and even games. When you download and unzip the plugin tools, they are automatically integrated into the Eclipse framework enabling you to create high-quality applications in less time.

Eclipse’s architecture has fostered a worldwide community of plugin developers. As more plugins are created that address the entire development cycle, Eclipse becomes increasingly useful, and popular.

The range of plugins is amazing. One biotech consultant uses the Jmechanic plugin, saying, “our clients could quickly identify many performance problems, and could then decide whether it was something they wanted to fix, outsource, or live with.” Using the Eclipse plugin saved licensing costs, and gave each developer on their team the freedom to run a time profile before checking in their code.

Another developer uses Eclipse as his primary IDE, and says, “the Sysdeo Tomcat launcher plugin is essential for my daily work, because it allows me to do runtime debugging of my web application from within Eclipse.”

Figure 1 shows the Eclipse user interface on Mac OS X, with an open example of a sample plug-in project.

Figure 1: Eclipse User Interface on Mac OS X

Speed development

You will quickly discover that one of the reasons Eclipse is popular with developers is that it is intuitive to learn and use. The Eclipse framework includes the workbench component that provides Eclipse with its user interface, a collection of views and editors. When you select a perspective, you are specifying the set of tools you need to use for the task at hand. This elegant workbench metaphor makes the Eclipse environment highly intelligent.

Eclipse’s features are well implemented and very effective, and are designed to increase the speed of the development cycle by automating tedious tasks that distract you from coding.

Other strengths include built-in CVS integration that makes it convenient to synchronize code with the CVS server. One Eclipse user says, ” the Synchronize view makes it easy to merge changes and view changes before I decide to update. The Annotation view allows me to determine when each line of a file was added and who added it. This feature is great for tracking down bugs.”

Eclipse integrates a best-of-breed implementation of features such as:

  • Code Refactoring – Allows you to reorganize and make other global changes to your code such as changing the name of a method or changing parameters. Refactoring is a way of making system-wide code changes without affecting the behavior of the program.
  • Content Assist – Displays a list of phrases that you can select from to complete what you are typing when editing Java code. This list is based on an ongoing analysis of your Java code.
  • Quick Fix – Enables you to correct a wide variety of problems, from spelling errors and missing import statements to declaring local variables and classes. The Java editor offers corrections to problems found while typing and after compiling.
  • Extract Method – Creates a method for the highlighted code.
  • Unit Testing – Provides you with an easy way to run all tests in a specified Java project, source folder, or package.
  • Import Management – Provides you with several features that help you manage import statements.
  • Documentation Lookup – Displays documentation relating to the method you point to with the cursor. The comment displayed shows the method name, documentation for method parameters, and the return value.
  • Debugger – Enables you to detect and diagnose errors in your programs running either locally or remotely. The debugger includes “hot code replace” that allows you to change source code during a debugger session.

Cross-Platform Development Teams

When used with Eclipse, Mac OS X supports heterogeneous development teams, enabling you to mix Mac OS X, Linux, UNIX and XP computing environments. This means that if you have a dozen Windows users and a dozen Mac users on your development team, these team members on different platforms can work on the same project without barriers.

Eclipse is great for organizing multiple projects with a large team of developers who can work collaboratively. “I found that Eclipse gave us a very clear picture of the hundred or so interlocking projects at one client” a developer told us. “It made it easy to see where these projects connected, and allowed us to refactor core libraries easily.” This developer explained that their bid to reduce inter-project dependencies for a client required splitting a dozen core projects into separate units. With Eclipse, one of their team finished the coding work in under a week. He says, “I suspect that the manual method would have taken a month, and thus would not have been cost effective. You cannot have your core libraries in turmoil for that long.”

In fact, in some industries, such as biotech, a significant percentage of developers currently are using Mac OS X and PowerBooks because they can develop applications for Mac, Windows, Linux, and Solaris deployments, with one box. Our biotech developer says, “Most of our work is in Java, though we also do Perl, C++, MATLAB, and whatever else our clients ask. We choose this platform because the Java implementation is good, we have access to a full underlying Unix layer, and we have a good suite of productivity applications. Without Mac OS X, we would likely have to carry around two different machines, with a dual boot Linux option on at least one of them.”

Why Do Java Development on the Mac?

The ease of use of Mac OS X, the power and stability of UNIX, the integration of Java into Mac OS X and the availability of great development environments like Eclipse make the Mac a great Java development environment.

UNIX users feel at home in Darwin, the robust UNIX-based environment that underlies Mac OS X. That environment is accessible at any time from the Terminal application. All of the standard UNIX utilities and scripting languages are included in Mac OS X—editors such as emacs, vim and pico; file management tools such as cp, mv, ls and gnutar; shell scripts including bash, tcsh (csh) and zsh; and scripting languages such as Perl, PHP, tcl, Ruby and Python. For Java-based web engineers, Apache, Tomcat and JBoss are also included, so you can do JSP development or enterprise class J2EE applications.

Mac OS X also gives you a highly mobile platform. The PowerBook series provides a high-powered workstation that is completely portable and allows you to pick up and go, and then quickly resume work at a new location. Even as you open your laptop, network connections are being reestablished and the computer is immediately up and running.

Apple has made Java a core component of Mac OS X—every Mac ships with the full version of Java 2, Standard Edition included—meaning you have the Java Developer Kit (JDK) and the HotSpot virtual machine (VM) without downloading, installing or configuring anything. And because Apple has optimized Java on Mac OS X, Java applications act as first-class citizens on Mac OS X.

In addition to Eclipse many of the industry leading tools are available, including IntelliJ’s IDEA, Borland’s JBuilder, Oracle’s JDeveloper, and Sun’s NetBeans, just to name a few. Mac OS X also includes free developer tools which support rapid Java development right out of the box.

Getting Started

You can get a copy of Eclipse by visiting the Eclipse download page and downloading the latest build. (The current version of Eclipse requires Mac OS X v10.3 Panther.) All builds are delivered as .ZIP files.

Download and install Eclipse

  1. Using your Safari browser, go to the eclipse.org Website.
  2. Click Downloads.
  3. Click Main Eclipse Download Site. If you are not located in North America, use the mirror site closet to your location.
  4. Click the name of the Release Build you want. At the time of this writing, the “3.0 Stream Stable Build” is the latest developer preview of version 3.0. This version is currently fine for daily use.
  5. Under “Eclipse SDK, find “Mac OSX (Mac/Carbon) (Supported Versions)”—the file name is also displayed. Select either the HTTP or FTP download option.
  6. After reading the Notes, click “Download” at the bottom of the page.
  7. When the download is complete, unzip the archive into the appropriate folder.(Older versions of Stuffit truncated file names and caused problems with Eclipse. Make sure you are using the appropriate version.)Your installation is now complete.
  8. Click the Eclipse icon to launch the IDE.

The first time you run Eclipse, it completes a few remaining install tasks—such as creating a workspace directory—before the Eclipse environment appears.

Work through the tutorials

With Eclipse installed and running, you can begin by looking at an overview of Eclipse features and plugins installed on your system, and then doing a tutorial that guides you through building a simple Java application.

To see the overview of the Eclipse features: from the Help menu, choose About Eclipse Platform

To do a tutorial on building a simple Java application: from the Help menu, choose Java Development User Guide > Getting Started > Basic Tutorial

Resources for More Information

Posted: 2004-06-07

Adapter pattern(1)

상속에 의한 Adapter 패턴 -  가장 기본이 되는 클래스를 중심으로 클래스를 확장하는 방법으로 인터페이스로 구현하는 방식, 어쩌면 클래스 확장에 있어 가장 기본이 되는 디자인 패턴인듯 싶다.

플래시에서도 가장 쉽게 적용되는 방식이다.

*Adaptee – Banner Class

접합하는 측이 아니라 접합되는 측. 이미 준비되어있는 메소드를 가지고 있는 역할.

public class Banner{
  private String string;
 
  public Banner(String string){
  this.string=string;
  }
 
  public void showWithParen(){
    System.out.printIn("("+string+")");
  }
 
  public void showWithAster(){
    System.out.printIn("*"+string+"*");
  }
 
}

*Target – Print Interface

필요로 하는 메소드를 제공하는 역할.

 public interface Print{
    public abstract void printWeak();
 
    public abstract void printStrong();
 
}

*Adapter – PrintBanner Class

Adaptee 역할의 메소드를 사용하여 Target 역할을 충족시키는 역할.

public class PrintBanner extends Banner implements Print{
 
public PrintBanner(String string){
    super(string);
}
 
public void printWeak(){
  showWithParen();
}
 
public void printStrong(){
  showWithAster();
}
 
}

*Client – Main Class

Target 역할의 메소드를 사용해서 일을 하는 역할

public class Main{
 
public static void main(String[] args){
 
Print p= new PrintBanner("Hellow");
 
p.printWeak();
 
p.printStrong();
 
}
 
}

Print interface 를 사용하여 구현하고 있다는 점을 강조하기 위해 인스턴스 변수를 Print 형 변수에 대입하여 사용함…