728x90
반응형
graphics을 이용하여 비행기 형체를 그린다.
(자세한 이미지가 아닌 형체를 나타내기 위한 것이기에 선과 삼각형을 이용하여 그림)

graphics의 자세한 내용은 버터백통님의 블로그를 참조하면 좋을것 같다.

이때 나타나는 비행기의 모향은 아래와 같다.


소스는 아래를 참조
728x90
반응형
728x90
반응형

지난번 포스트의 소스를 수정해보았다.

뭔가 잘 이해가 되지는 않지만...그래도 일단은 절반의 성공?


소스는 아래와 같다. (TEST 용 소스라 주석따윈 없다..)

728x90
반응형
728x90
반응형

마우스 이벤트에서 clickdoubleClick 를 동시에 사용하려고 했더니 원하는 동작이 되지 않았다.
이유는 간단하다..더블클릭을 제대로 인식하지 않아서 그런건데..인터벌을 300ms 줘서 동작하도록 하면 끝~
자세한 내용은 밑에 블로그에서 확인하도록 하자.



위 블로그의 내용을 이용하여 예제를 한번 만들어 봤다.


소스는 아래 참고
728x90
반응형
728x90
반응형

일단 Flash에서는 마우스 오른쪽 버튼에 대한 이벤트가 지원이 안된다.
이것을 나만 고민한게 아닌듯...

구글에서 진행중인 프로젝트가 있는데 IE7, 크롬, 파이어폭스3 에서 구동 확인 했다.
참고하면 좋을듯..;;; (약간 꼼수를 쓰는것 같은데..ㅋㅋㅋ)


데모

다시한번 생각하는거지만...역시 대단한 놈들..;;;
728x90
반응형
728x90
반응형

브라우져의 내용을 화면 전체로 보여주기위한 내용이다.

일단 예제 화면은 아래 주소를 참조 하면 좋을것 같다.

EX>

SOURCE>

지금 현재 지도에 관련된 작업테스트를 하는 도중 찾게된것인데, 내가 소스를 만들어서 실행하니 안됬다.

근데 다운받은 소스를 실행하니..된다..ㅡ.ㅡ;;;

굉장히 당황해서 소스를 좀 수정해보니... toggleFullScreen() 함수 부분에서 예외가 발생하였다.

에러 메세지는...

SecurityError: Error #2152: Full screen mode is not allowed.
at flash.display::Stage/set displayState()

풀스크린모드를 사용할수 없다...;;;;

뭔지 모르고 이것 저것 찾다보니 해외에서 답을 찾았다.

다음 글을 참조하면 좋을듯 하다. [참조글]

FLEX 3 빌더에서 자동으로 만들어지는 html-template 폴더의 index.template.html 파일에 
allowFullScreen의 값을 지정하지 않아서 발생하는 문제다.

자동으로 생성된 index.template.html을 열고 수정을 해주면 문제는 해결된다.

아래는 참고 소스

... 생략 ...

if ( hasProductInstall && !hasRequestedVersion ) {
// DO NOT MODIFY THE FOLLOWING FOUR LINES
// Location visited after installation is complete if installation is required
var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
var MMredirectURL = window.location;
    document.title = document.title.slice(0, 47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

AC_FL_RunContent(
"src", "playerProductInstall",
"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowScriptAccess","sameDomain",
"allowFullScreen", "true",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);
} else if (hasRequestedVersion) {
// if we've detected an acceptable version
// embed the Flash Content SWF when all tests are passed
AC_FL_RunContent(
"src", "${swf}",
"width", "${width}",
"height", "${height}",
"align", "middle",
"id", "${application}",
"quality", "high",
"bgcolor", "${bgcolor}",
"name", "${application}",
"allowScriptAccess","sameDomain",
"allowFullScreen", "true",
"type", "application/x-shockwave-flash",
"pluginspage", "http://www.adobe.com/go/getflashplayer"
);

... 중략 ...

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
id="${application}" width="${width}" height="${height}"
codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
<param name="movie" value="${swf}.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="${bgcolor}" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="true" />
<embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
width="${width}" height="${height}" name="${application}" align="middle"
play="true"
loop="false"
quality="high"
allowScriptAccess="sameDomain"
allowFullScreen="true"
type="application/x-shockwave-flash"
pluginspage="http://www.adobe.com/go/getflashplayer">
</embed>
</object>



728x90
반응형
728x90
반응형

Tracy Spratt <tspratt@lariatinc.com> 의 아이디어입니다

 

<?xml version="1.0" encoding="utf-8"?>

<!-- Tree control example. -->

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">

<mx:Script><![CDATA[

  [Bindable]

  public var _xmlData:XML;

 

  public function initApp():void

  {

    _xmlData = <element eid="hello">

         <element eid="world">

            <element eid="123"/>

            <element eid="graham"/>

            <element eid="weldon">

               <element eid="office">

                  <element eid="thing"/>

                  <element eid="boat"/>

                  <element eid="chair"/>

               </element>

               <element eid="person"/>

                </element>

             </element>

          </element> ;

  

  }//initapp

     

  private function expandParents(xmlNode:XML):void

  {

    while (xmlNode.parent() != null) { 

      xmlNode = xmlNode.parent();

      myTree.expandItem(xmlNode,true, false);

    }

  }//expandParents

 

         

            private function findNodeById(sId:String):void

            {

                        var xmllistDescendants:XMLList  = _xmlData.descendants().(@eid == sId);

                        expandParents(xmllistDescendants[0]);

                        myTree.selectedItem = xmllistDescendants[0];

            }//findNodeById          

]]></mx:Script>

 

 

 

    <mx:Panel title="Tree Control Example" height="75%" width="75%"

        paddingTop="10" paddingLeft="10" paddingRight="10" paddingBottom="10">

        <mx:HBox>

          <mx:TextInput id="tiId" text="boat" />

          <mx:Button label="Find" click="findNodeById(tiId.text)" />        

        </mx:HBox>

        <mx:Tree id="myTree" width="50%" height="100%" labelField="@eid"

            showRoot="false" dataProvider="{_xmlData}" />     

    </mx:Panel>

</mx:Application>

728x90
반응형
728x90
반응형

아래 코드를 좀 응용하면 될듯...

var nowDate:Date = new Date();
var sday:String = nowDate.date.toString();
var smonth:String = (nowDate.month+1).toString();

if(sday.length == 1){
sday = "0"+sday;
}
if(smonth.length == 1){
smonth = "0"+smonth
}

snowDate = nowDate.fullYear.toString()+"-"+ smonth +"-"+sday;

728x90
반응형
728x90
반응형
앞글( http://tylee82.tistory.com/62 )에 이어서 클라이언트 작성을 알아보도록 한다.
이글은 머그초보의 블로그( http://mudchobo.tomeii.com/tt/239?category=8 ) 의 글을 참고로 작성됨을 알려드리며, 문제가 발생시 자삭 하겠습니다.

<< service-config.xml파일을 수정 >>

<factories>
  <factory id="springfactory" class="flex.messaging.factory.SpringFactory" /> 
</factories>
를 추가합니다.

<< remote-config.xml 파일을 수정 >>
<destination id="productmanager">
 <properties>
  <factory>springfactory</factory> 
  <source>productManager</source>
 </properties>
</destination> 

자세히 보시면 factory는 위에 service-config.xml파일에 정의한 놈이고, source는 bean이름입니다.
즉 applicationContext.xml파일에 정의한 그 bean이름을 저기에 적어 놓으면 됩니다.
그러면 그 bean을 flex로 가져와서 쓸 수 있습니다.


아 그리고 프로젝트에서 이상하게 contextroot가 WebContent로 되어있는데 프로젝트이름으로 고쳐줍시다-_-; 
---> (원래 WebContent 나오는게 정상 아닌가?? 뭐 난 아무것도 모르는 초보니깐.. 그냥 시키는데로...)

프로젝트 이름에 대고 마우스오른쪽버튼(alt+enter) properties를 선택, Flex Server부분 클릭.
context root를 프로젝트이름(SpringAndBlazeds)으로 바꿔줍시다.


<< FLEX 작성 >>
자 그러면 flex_src에 있는 SpringAndBlazeds.mxml을 수정해봅시다.
SpringAndBlazeds.mxml


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
 
applicationComplete="init();">
 
 
<mx:Script>
  <![CDATA[
   import mx.controls.Alert;
   import mx.rpc.events.FaultEvent;
   import mx.rpc.events.ResultEvent;
   import mx.rpc.remoting.RemoteObject;
   
   private function init():void {
    var remoteObject:RemoteObject = new RemoteObject();
    remoteObject.destination = "productmanager";
    remoteObject.addEventListener(ResultEvent.RESULT, resultHandler);
    remoteObject.addEventListener(FaultEvent.FAULT, faultHandler);
    remoteObject.getProducts();
   }
   
   private function resultHandler(event:ResultEvent):void{        
       dg.dataProvider = event.result;  
      }      
   
      private function faultHandler(event:FaultEvent):void{        
       Alert.show("실패 메세지 : " + event.fault.message);  
      }  
  ]]>
 
</mx:Script>
 
 
<mx:DataGrid id="dg" width="100%" height="100%" />
</mx:Application>

간단하게 Manager에 있는 getProducts를 호출해서 DataGrid에 넣는 코드입니다.

<< 실행 >>
이클립스 오른쪽아래에 server에다가 SpringAndBlazeds프로젝트를 추가합니다.
서버에 대고, 오른쪽버튼누르면, Add and Remove Project클릭해서 추가하면 됩니다.
서버를 가동합니다.
Run Flex Application을 실행해봅시다!


 - 후기
이번 예제를 실행하면서 나의 실력에 부족한점을 알아냈다.
  • Spring 프레임워크의 부족한 점 보안 
  • Flex에서 DataBase의 연동시 처리 방법 보안
  • iBatis의 데이터 베이스 정의 및 사용방법 보안
실질적으로 사용을 하기위한 프로젝트로 만들기 위해서는 많은 점을 보안해야 겠지만, 일단 오늘 돌려본 이 예제가 엄청난 도움이 될거라 생각한다. 아직 Spring 프로젝트 경험도 공부도 해본적이 없지만, EJB시스템 및 좀더 거대한 프로젝트를 위해서는 아무래도 공부를 해야겠다.

개인적으로 참 괜찮다고 생각한 DB 처리 java 소스들이 있어서 언제나 그것을 가지고 개발을 했는데, 아무래도 이제는 iBatis를 이용해 봐야겠다. 

FLEX의 컴포넌트 구조도 아는것이 없었는데, 일단 DB와 연동을 시켜봤으니 게시판부터 한번 개발 해보려 한다.

다시한번 머그초보님에게 감사를 표시합니다.

728x90
반응형
728x90
반응형

앞글 ( http://tylee82.tistory.com/61 )에 이은 포스트입니다.
이 글은 머드초보의 블로그 ( http://mudchobo.tomeii.com/tt/238?category=8 )의 글을 기초로 작성 됨을 알려드리며, 문제 발생시 자삭하겠습니다.

<< Manager클래스 작성 >>
실제로 BlazeDS를 이용해서 가져오는 놈은 이 Manager클래스가 됩니다.
Java Resources: src에서 오른쪽버튼 클릭하고, New를 해서 interface를 구현합니다.

package springapp.service;

import java.util.List;
import springapp.domain.Product;

public interface ProductManager {
 
public List<Product> getProducts();
}

getProducts라는 메소드가 하나 있군요! 구현해봅시다!!!

package springapp.service;

import java.util.List;

import springapp.dao.ProductDao;
import springapp.domain.Product;

public class ProductManagerImpl implements ProductManager {

 
private ProductDao productDao;
 
 
@Override
 
public List<Product> getProducts() {
 
return productDao.getProductList();
 
}

 
public void setProductDao(ProductDao productDao) {
 
this.productDao = productDao;
 
}
}

getProducts라는 함수는 Dao에서 getProductList를 호출하는 놈이네요.
요 아래에는 setter가 있네요. 이건 spring에서 DI를 하기위해 존재하는 setter입니다^^
서비스도 완성이 되었네요! 이제 설정파일을 작성해봅시다.

WEB-INF/applicationContext.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xmlns:p="http://www.springframework.org/schema/p"
 
xmlns:aop="http://www.springframework.org/schema/aop"
 
xmlns:tx="http://www.springframework.org/schema/tx"
 
xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
 http://www.springframework.org/schema/aop
 http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
 http://www.springframework.org/schema/tx
 http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
>

 
<!-- Enable @Transactional support -->
 
<tx:annotation-driven />

 
<!-- Enable @AspectJ support -->
 
<aop:aspectj-autoproxy />

 
<aop:config>
 
<aop:advisor pointcut="execution(* *..ProductManager.*(..))"
   
advice-ref="txAdvice" />
 
</aop:config>

 
<tx:advice id="txAdvice">
 
<tx:attributes>
   
<tx:method name="save*" />
   
<tx:method name="get*" read-only="true" />
 
</tx:attributes>
 
</tx:advice>

 
<bean id="productManager"
 
class="springapp.service.ProductManagerImpl">
 
<property name="productDao" ref="productDao" />
 
</bean>

</beans>

Dao부분의 설정파일인 applicationContext-ibatis.xml파일을 봅시다.
WEB-INF/applicationContext-ibatis.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 
xmlns:p="http://www.springframework.org/schema/p"
 
xmlns:aop="http://www.springframework.org/schema/aop"
 
xmlns:tx="http://www.springframework.org/schema/tx"
 
xsi:schemaLocation="http://www.springframework.org/schema/beans
 http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/aop
    http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"
>

 
<bean id="propertyConfigurer"
 
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"
 
p:location="classpath:properties/jdbc.properties" />

 
<bean id="dataSource"
 
class="org.springframework.jdbc.datasource.DriverManagerDataSource"
 
p:driverClassName="${jdbc.driverClassName}" p:url="${jdbc.url}"
 
p:username="${jdbc.username}" p:password="${jdbc.password}" />

 
<!-- Transaction manager for iBATIS Daos -->
 
<bean id="transactionManager"
 
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
 
<property name="dataSource" ref="dataSource" />
 
</bean>

 
<!-- SqlMap setup for iBATIS Database Layer -->
 
<bean id="sqlMapClient"
 
class="org.springframework.orm.ibatis.SqlMapClientFactoryBean">
 
<property name="dataSource" ref="dataSource" />
 
<property name="configLocation"
   
value="classpath:springapp/dao/SqlMapConfig.xml" />
 
</bean>

 
<!-- Add additional Dao definitions here -->
 
<bean id="productDao"
 
class="springapp.dao.ProductDaoImpl">
 
<property name="sqlMapClient" ref="sqlMapClient" />
 
</bean>
 
</beans>

jdbc.properties파일은 properties라는 package를 만들고, jdbc.properties파일을 넣어버립시다.

jdbc
.driverClassName=com.mysql.jdbc.Driver
jdbc
.url=jdbc:mysql://DB주소
jdbc
.username=DB아이디
jdbc
.password=DB비밀번호

이 설정들의 bean들의 관계를 보고 싶다면-_-;
Spring Elements에서 오른쪽버튼 클릭하고 properties를 선택.
Bean Support를 선택, Add한 뒤 두개의 설정파일(applicationContext.xml, applicationContext-ibatis.xml)선택.
Config set에서 New하고 Name에 applicationContext라고 하고, 두개다 체크 오케이~
그럼 이제 스프링 설정파일에서 에러를 찾아낼 수 있어요!
bean들의 관계를 그래프로도 볼 수 있네요!
Config set에 추가한 applicationContext에다가 마우스오른쪽버튼을 클릭하면 open graph로 볼 수 있어요!

이제 클라이언트 구현으로....다음 시간에-_-;
728x90
반응형
728x90
반응형

세팅 ( http://tylee82.tistory.com/60 )이 완료되면 이제 코딩을 해보겠습니다.
머드초보의 블러그의 글을 참고로 작성된 글임을 다시한번 강조합니다.



<< MySQL >>
일단 DB 구조입니다. 
CREATE TABLE `products` (

  `id` int(11) NOT NULL,
  `description` varchar(255) default NULL,
  `price` decimal(15,2) default NULL,
  PRIMARY KEY  (`id`),
  KEY `products_description` (`description`)
) ENGINE=MyISAM DEFAULT CHARSET=UTF8;

INSERT INTO `products` (`id`, `description`, `price`) VALUES 
(1, 'Lamp', 391.50),
(2, 'Table', 2918.85),
(3, 'Chair', 884.27);

※ mysql 설치시 charset을 utf-8로 설정을 하였기때문에 UTF8로 charset을 잡았습니다.

<< 프로젝트 구조 >>

그냥 src폴더는 자바서버단 폴더구요. flex_src폴더는 플렉스클라이언트단 폴더입니다.



<< web.xml 의 수정 (스프링 설정) >>

web.xml 아래 코드 추가
<context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext*.xml</param-value>
</context-param>


<listener>
 <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

applicationContext*라고 적어 놓은 이유가 ibatis랑 분리를 하려고 합니다.
설정파일은 applicationContext.xml과 applicationContext-ibatis.xml 두개를 사용할껍니다.

※ 위 코드 추가시 주의 사항 : web.xml의 엘리먼트의 위치는 순서가 있습니다. 순서가 맞지 않는다면 에러가 납니다. ( 참고글 : http://woongbox.tistory.com/tag/The%20content%20of%20element%20type%20"web-app"%20must%20match )

<< 소스코딩 >>
src에다가 코딩을 해봅시다.
java는 perspective를 Java EE로 바꾸고 합시다.


우선 domain부분에 ValueObject를 하나 만들어봅시다.
Java Resources:src에다가 New를 하고 class를 선택합니다.
package는 springapp.domain이라고 하구요.
Name은 Product라고 하고 Finish

Product.java

package springapp.domain;

public class Product {

 
private int id;
 
private String description;
 
private Double price;

 
public int getId() {
 
return id;
 
}

 
public void setId(int id) {
 
this.id = id;
 
}

 
public String getDescription() {
 
return description;
 
}

 
public void setDescription(String description) {
 
this.description = description;
 
}

 
public Double getPrice() {
 
return price;
 
}

 
public void setPrice(Double price) {
 
this.price = price;
 
}
}

ProductDao를 만들어봅시다.
Java Resource:src에 New해서 interface를 추가합시다.
package에다가 springapp.dao라고 써놓고, 
Name에다가 ProductDao라고 씁시다.

package springapp.dao;

import java.util.List;
import springapp.domain.Product;

public interface ProductDao {
 
public List<Product> getProductList();
}

딸랑 ProductList만 가져오는 메소드가 있어요! 
저 Dao인터페이스를 구현해봅시다!!!

package springapp.dao;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import springapp.domain.Product;

public class ProductDaoImpl extends SqlMapClientDaoSupport implements
 
ProductDao {

 
protected final Log logger = LogFactory.getLog(getClass());

 
@SuppressWarnings("unchecked")
 
@Override
 
public List<Product> getProductList() {
  logger
.info("Getting products!");
 
return getSqlMapClientTemplate().queryForList("getProductList");
 
}
}

<< ibatis >>
ibatis부분인데요. 설정파일을 보도록 하겠습니다.

src/springapp/dao/SqlMapConfig.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMapConfig      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">


<sqlMapConfig>
 
<typeAlias alias="Product" type="springapp.domain.Product"/>

 
<sqlMap resource="springapp/dao/MySQLProduct.xml" />
</sqlMapConfig>

alias지정해주고, resource는 src/springapp/dao/MySQLProduct.xml파일입니다.

MySQLProduct.xml

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">


<sqlMap namespace="Product">

 
<resultMap id="ProductMap" class="Product">
 
<result property="id" column="id" />
 
<result property="description" column="description" />
 
<result property="price" column="price" />
 
</resultMap>

 
<select id="getProductList" resultMap="ProductMap">
  select id, description, price from products
 
</select>

</sqlMap>

getProductList라는 것은 products테이블에서 내용을 select하는 것이네요.
Dao가 완성되었네요! 너무 길어지니 다음이시간에 ...

728x90
반응형

+ Recent posts