"페이스북 플래시웹앱 개발"의 두 판 사이의 차이

96번째 줄: 96번째 줄:
*"Properties for RelightMyFireWeb" --- Flex Compiler --- [ ] Generate HTML wrapper file --- [OK]
*"Properties for RelightMyFireWeb" --- Flex Compiler --- [ ] Generate HTML wrapper file --- [OK]
*"Overwriting Files" --- [OK]
*"Overwriting Files" --- [OK]
*Project --- Clean --- "Clean" --- [OK]


==아이콘 추가==
==아이콘 추가==

2012년 9월 8일 (토) 21:41 판

Crystal Clear action info.png 작성 중인 문서입니다.
페이스북 플래시웹앱 개발
플래시 페이스북앱 개발

1 사전 작업

2 새 프로젝트

  • File --- New --- Flex Project
  • "New Flex Project" --- Project name: 프로젝트명(예: RelightMyFireWeb) --- (O) Web (runs in Adobe Flash Player) --- (O) Use default SDK (currently "Flex 4.6.0") --- [Finish]

3 SDK 추가

  • http://code.google.com/p/facebook-actionscript-api/ 접속
  • "Downloads" --- GraphAPI_Web_1_8_1.swc 클릭 --- GraphAPI_Web_1_8_1.swc 클릭하여 다운로드
  • 탐색기에서 GraphAPI_Web_1_8_1.swc 선택, 복사 ( Ctrl+C )
  • 플래시 빌더 --- "Package Explorer"의 libs 폴더 선택, 붙여넣기 ( Ctrl+V )

Fb flash web dev 01.png

4 RelightMyFireWeb.mxml 수정

RelightMyFireWeb.mxml 파일 내용을 다음으로 교체

<?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" minWidth="600" minHeight="300"
			   creationComplete="application1_creationCompleteHandler(event)">
	<fx:Script>
		<![CDATA[
			import com.facebook.graph.Facebook;
			import mx.events.FlexEvent;
			protected function application1_creationCompleteHandler(event:FlexEvent):void {
				Facebook.init("YOUR APPLICATION ID HERE",loginHandler);
			}
			protected function loginHandler(success:Object,fail:Object):void {
				if(!success) return;
				currentState="loggedin";
				Facebook.api("/me",getMeHandler);	
				userImg.source=Facebook.getImageUrl(success.uid,"large");
			}
			protected function login():void {
				Facebook.login(loginHandler,{scope:"user_birthday"});
			}
			protected function logout():void {
				Facebook.logout(logoutHandler);
				currentState="loggedout";
			}
			protected function logoutHandler(response:Object):void {}
			protected function getMeHandler(result:Object,fail:Object):void {
				nameLbl.text=result.name;
				birthdayLbl.text=result.birthday;
			}
		]]>
	</fx:Script>
	<s:states>
		<s:State name="loggedout"/>
		<s:State name="loggedin"/>
	</s:states>
	<fx:Declarations>
		<!-- Place non-visual elements (e.g., services, value objects) here -->
	</fx:Declarations>
	<s:Button id="loginoutBtn" right="10" top="10" label="Log out" click.loggedin="logout()" label.loggedout="Log in" click.loggedout="login()"/>
	<s:Image id="userImg" includeIn="loggedin" left="10" top="68" width="100"/>
	<s:Label id="nameLbl" includeIn="loggedin" x="10" y="10"/>
	<s:Label id="birthdayLbl" includeIn="loggedin" x="10" y="39"/>
</s:Application>

5 index.html 파일

  • 패키지 탐색기 --- RelightMyFireWeb --- src 우클릭 --- New --- File
  • "New File" --- File name:index.html --- [Finish]
  • 패키지 탐색기 --- RelightMyFireWeb --- src --- index.html 우클릭 --- Open With --- Text Editor
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml">
	<head>	 	
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script>
		<script type="text/javascript" src="http://connect.facebook.net/en_US/all.js"></script>	
	</head>
	<body>
		<div id="fb-root"></div>
		<div id="flashContent">
			<h1>You need at least Flash Player 10.2 to view this page.</h1>
			<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
		</div>  
		<script type="text/javascript">
			swfobject.embedSWF("RelightMyFireWeb.swf", "flashContent", "600", "300", "10.2", null, null, null, {name:"flashContent"}); 			
		</script>
	</body>
</html>

6 HTML wrapper 해제

  • 패키지 탐색기 -- RelightMyFireWeb 우클릭 --- Properties
  • "Properties for RelightMyFireWeb" --- Flex Compiler --- [ ] Generate HTML wrapper file --- [OK]
  • "Overwriting Files" --- [OK]
  • Project --- Clean --- "Clean" --- [OK]

7 아이콘 추가

8 같이 보기

9 참고 자료

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}