SlideShare a Scribd company logo
1 of 8
Flash Communicate
Giảng viên: Nguyễn Tuấn Anh
Outline
• Sử dụng Flashvar
• Sử dụng ShareObject
• Phối hợp với PHP
• Nói chuyện với JS
Flashvar
• Là cách thức sử dụng trong mã nhúng html (thẻ object)
để gửi biến và giá trị vào tập tin swf.
• Các biến này có thể bao quát toàn bộ chương trình
• Hữu ích khi bạn muốn làm việc với dữ liệu động được
thông qua từ URL hoặc từ các thẻ đối tượng cho phép
bạn rút ngắn thời gian truyền nhận vì có thể tạo đối
tượng flash chỉ cần một lần
ShareObject
• SharedObject được sử dụng để đọc
và lưu trữ dữ liệu trên máy tính của người dùng
hoặc trên một máy chủ.
• Đối tượng chia sẻ cung cấp chia sẻ dữ liệu thời gian
thực giữa các tập tin SWF trên máy tính hoặc máy
chủ từ xa.
• Được coi như là “Flash cookies”
Flash với Php
• Flash client có thể sử dụng giao thức TCP/IP ( và mới
đây là Peer-to-Peer ). Tuy nhiên thông dụng nhất vẫn là
qua HTTP.
• REQUEST
var url:String = “http://hallopatidu.com/testxml.php”
var request:URLRequest = new URLRequest(url);
• POST / GET method
Flash với javascript
• From ActionScript:
Gọi hàm Javascript.
Gửi các đối số với tên của chúng.
Gửi được một vài kiểu dữ liệu (Boolean, Number, String, and so on).
Nhận và trả về giá trị lấy từ Javascript.
function test(val){
alert(val);
}
• From JavaScript:
Gọi được các hàm từ Actionscript
Gửi các đối số theo chuẩn.
Trả về như bình thường với một javascript function.
– var call_java:uint;
– call_java = ExternalInterface.call('test','666');
Practice
• Truy cập vào file php đặt trên máy chủ
• Truy cập vào database thông qua php
Homework
• Tạo lưu điểm cho game
• Hướng dẫn:
- Gửi điểm lên host thông qua php
- Xử lý php ghi vào cơ sở dữ liệu
- Hiển thị điểm của người chơi có điểm
cao nhất

More Related Content

Similar to Lesson 22: Flash communicate

Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)Linh Nguyen
 
Slide 01-Web Application Overview (1).pdf
Slide 01-Web Application Overview (1).pdfSlide 01-Web Application Overview (1).pdf
Slide 01-Web Application Overview (1).pdfHuyVnh4
 
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...VKhang Yang
 
PHP có thể làm gì? 9 Thứ thú vị có thể làm với PHP
PHP có thể làm gì?  9 Thứ thú vị có thể làm với PHPPHP có thể làm gì?  9 Thứ thú vị có thể làm với PHP
PHP có thể làm gì? 9 Thứ thú vị có thể làm với PHPNIIT - ICT Hà Nội
 
Javascript tong-hop a-z
Javascript tong-hop a-zJavascript tong-hop a-z
Javascript tong-hop a-zManhh Nguyễn
 
Bottle web framwork for python
Bottle web framwork for pythonBottle web framwork for python
Bottle web framwork for pythonKhánh Nguyễn
 
Net06 asp.net applications & state management
Net06 asp.net applications & state managementNet06 asp.net applications & state management
Net06 asp.net applications & state managementhoangnguyentien
 
lap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdf
lap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdflap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdf
lap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdfdinhson2000
 
Lập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biếnLập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biếnSon Nguyen
 
Go micro framework to build microservices
Go micro framework to build microservicesGo micro framework to build microservices
Go micro framework to build microservicesTechMaster Vietnam
 

Similar to Lesson 22: Flash communicate (20)

Bai44-48.pptx
Bai44-48.pptxBai44-48.pptx
Bai44-48.pptx
 
Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)Bai tap lap trinh mang(1)
Bai tap lap trinh mang(1)
 
Slide 01-Web Application Overview (1).pdf
Slide 01-Web Application Overview (1).pdfSlide 01-Web Application Overview (1).pdf
Slide 01-Web Application Overview (1).pdf
 
Php 01 modau
Php 01 modauPhp 01 modau
Php 01 modau
 
Dsd05 02a-xml-rpca
Dsd05 02a-xml-rpcaDsd05 02a-xml-rpca
Dsd05 02a-xml-rpca
 
Node.js căn bản
Node.js căn bảnNode.js căn bản
Node.js căn bản
 
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
Lập trình background job bằng azurequeue và webjob sử dụng azure storage emul...
 
PHP có thể làm gì? 9 Thứ thú vị có thể làm với PHP
PHP có thể làm gì?  9 Thứ thú vị có thể làm với PHPPHP có thể làm gì?  9 Thứ thú vị có thể làm với PHP
PHP có thể làm gì? 9 Thứ thú vị có thể làm với PHP
 
chuong_02.ppt
chuong_02.pptchuong_02.ppt
chuong_02.ppt
 
Ung dun web chuong 2
Ung dun web  chuong 2Ung dun web  chuong 2
Ung dun web chuong 2
 
Javascript tong-hop a-z
Javascript tong-hop a-zJavascript tong-hop a-z
Javascript tong-hop a-z
 
Tổng hợp nè
Tổng hợp nèTổng hợp nè
Tổng hợp nè
 
Bottle web framwork for python
Bottle web framwork for pythonBottle web framwork for python
Bottle web framwork for python
 
Net06 asp.net applications & state management
Net06 asp.net applications & state managementNet06 asp.net applications & state management
Net06 asp.net applications & state management
 
lap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdf
lap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdflap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdf
lap-trinh-mang_nguyen-cao-dat_bai-tap-lon - [cuuduongthancong.com].pdf
 
Scaling php
Scaling phpScaling php
Scaling php
 
Lab lap trinhmang_v3
Lab lap trinhmang_v3Lab lap trinhmang_v3
Lab lap trinhmang_v3
 
Lập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biếnLập trình web với các công nghệ phổ biến
Lập trình web với các công nghệ phổ biến
 
Go micro framework to build microservices
Go micro framework to build microservicesGo micro framework to build microservices
Go micro framework to build microservices
 
Giao trinh java script
Giao trinh java scriptGiao trinh java script
Giao trinh java script
 

More from Hallo Patidu

Video - lesson21 - reference
Video - lesson21 - referenceVideo - lesson21 - reference
Video - lesson21 - referenceHallo Patidu
 
Lesson 18: Tween Effect
Lesson 18: Tween EffectLesson 18: Tween Effect
Lesson 18: Tween EffectHallo Patidu
 
Lession 13: Dynamic data access
Lession 13: Dynamic data accessLession 13: Dynamic data access
Lession 13: Dynamic data accessHallo Patidu
 
Homework: Math In Flash
Homework: Math In FlashHomework: Math In Flash
Homework: Math In FlashHallo Patidu
 
Lession 14,15 : Math in flash
Lession 14,15 : Math in flashLession 14,15 : Math in flash
Lession 14,15 : Math in flashHallo Patidu
 
Workshop: Typing game
Workshop: Typing gameWorkshop: Typing game
Workshop: Typing gameHallo Patidu
 
Workshop game hứng bia
Workshop   game hứng biaWorkshop   game hứng bia
Workshop game hứng biaHallo Patidu
 
Lession : Sử dụng timer va get timer
Lession : Sử dụng timer va get timerLession : Sử dụng timer va get timer
Lession : Sử dụng timer va get timerHallo Patidu
 
Lesson 08 : AS3 Display Programming
Lesson 08 : AS3 Display ProgrammingLesson 08 : AS3 Display Programming
Lesson 08 : AS3 Display ProgrammingHallo Patidu
 
Lesson 07 : Your First Game
Lesson 07 : Your First GameLesson 07 : Your First Game
Lesson 07 : Your First GameHallo Patidu
 
Lesson 06 : OOP and Access modifier
Lesson 06 : OOP and Access modifierLesson 06 : OOP and Access modifier
Lesson 06 : OOP and Access modifierHallo Patidu
 
Lesson 05: Document Class, Events and FlashDevelop Tool
Lesson 05: Document Class, Events and  FlashDevelop ToolLesson 05: Document Class, Events and  FlashDevelop Tool
Lesson 05: Document Class, Events and FlashDevelop ToolHallo Patidu
 
Lesson 01 : Flash Platforms Overview
Lesson 01 : Flash Platforms OverviewLesson 01 : Flash Platforms Overview
Lesson 01 : Flash Platforms OverviewHallo Patidu
 
Lesson 03 : Timeline in Flash World
Lesson 03 : Timeline in Flash WorldLesson 03 : Timeline in Flash World
Lesson 03 : Timeline in Flash WorldHallo Patidu
 
Lesson 02 : Flash Authoring Environment
Lesson 02 : Flash Authoring EnvironmentLesson 02 : Flash Authoring Environment
Lesson 02 : Flash Authoring EnvironmentHallo Patidu
 
Pre: FOF Learning Guide
Pre: FOF Learning GuidePre: FOF Learning Guide
Pre: FOF Learning GuideHallo Patidu
 
Lesson 04 : Actionscript 3 Overview
Lesson 04 : Actionscript 3 OverviewLesson 04 : Actionscript 3 Overview
Lesson 04 : Actionscript 3 OverviewHallo Patidu
 

More from Hallo Patidu (20)

Lesson 21: Video
Lesson 21: VideoLesson 21: Video
Lesson 21: Video
 
Video - lesson21 - reference
Video - lesson21 - referenceVideo - lesson21 - reference
Video - lesson21 - reference
 
Lesson 20 : Sound
Lesson 20 : SoundLesson 20 : Sound
Lesson 20 : Sound
 
Lesson 19.xml
Lesson 19.xmlLesson 19.xml
Lesson 19.xml
 
Lesson 18: Tween Effect
Lesson 18: Tween EffectLesson 18: Tween Effect
Lesson 18: Tween Effect
 
Lession 13: Dynamic data access
Lession 13: Dynamic data accessLession 13: Dynamic data access
Lession 13: Dynamic data access
 
Homework: Math In Flash
Homework: Math In FlashHomework: Math In Flash
Homework: Math In Flash
 
Lession 14,15 : Math in flash
Lession 14,15 : Math in flashLession 14,15 : Math in flash
Lession 14,15 : Math in flash
 
Workshop: Typing game
Workshop: Typing gameWorkshop: Typing game
Workshop: Typing game
 
Workshop game hứng bia
Workshop   game hứng biaWorkshop   game hứng bia
Workshop game hứng bia
 
Lession : Sử dụng timer va get timer
Lession : Sử dụng timer va get timerLession : Sử dụng timer va get timer
Lession : Sử dụng timer va get timer
 
Lesson 08 : AS3 Display Programming
Lesson 08 : AS3 Display ProgrammingLesson 08 : AS3 Display Programming
Lesson 08 : AS3 Display Programming
 
Lesson 07 : Your First Game
Lesson 07 : Your First GameLesson 07 : Your First Game
Lesson 07 : Your First Game
 
Lesson 06 : OOP and Access modifier
Lesson 06 : OOP and Access modifierLesson 06 : OOP and Access modifier
Lesson 06 : OOP and Access modifier
 
Lesson 05: Document Class, Events and FlashDevelop Tool
Lesson 05: Document Class, Events and  FlashDevelop ToolLesson 05: Document Class, Events and  FlashDevelop Tool
Lesson 05: Document Class, Events and FlashDevelop Tool
 
Lesson 01 : Flash Platforms Overview
Lesson 01 : Flash Platforms OverviewLesson 01 : Flash Platforms Overview
Lesson 01 : Flash Platforms Overview
 
Lesson 03 : Timeline in Flash World
Lesson 03 : Timeline in Flash WorldLesson 03 : Timeline in Flash World
Lesson 03 : Timeline in Flash World
 
Lesson 02 : Flash Authoring Environment
Lesson 02 : Flash Authoring EnvironmentLesson 02 : Flash Authoring Environment
Lesson 02 : Flash Authoring Environment
 
Pre: FOF Learning Guide
Pre: FOF Learning GuidePre: FOF Learning Guide
Pre: FOF Learning Guide
 
Lesson 04 : Actionscript 3 Overview
Lesson 04 : Actionscript 3 OverviewLesson 04 : Actionscript 3 Overview
Lesson 04 : Actionscript 3 Overview
 

Lesson 22: Flash communicate

  • 1. Flash Communicate Giảng viên: Nguyễn Tuấn Anh
  • 2. Outline • Sử dụng Flashvar • Sử dụng ShareObject • Phối hợp với PHP • Nói chuyện với JS
  • 3. Flashvar • Là cách thức sử dụng trong mã nhúng html (thẻ object) để gửi biến và giá trị vào tập tin swf. • Các biến này có thể bao quát toàn bộ chương trình • Hữu ích khi bạn muốn làm việc với dữ liệu động được thông qua từ URL hoặc từ các thẻ đối tượng cho phép bạn rút ngắn thời gian truyền nhận vì có thể tạo đối tượng flash chỉ cần một lần
  • 4. ShareObject • SharedObject được sử dụng để đọc và lưu trữ dữ liệu trên máy tính của người dùng hoặc trên một máy chủ. • Đối tượng chia sẻ cung cấp chia sẻ dữ liệu thời gian thực giữa các tập tin SWF trên máy tính hoặc máy chủ từ xa. • Được coi như là “Flash cookies”
  • 5. Flash với Php • Flash client có thể sử dụng giao thức TCP/IP ( và mới đây là Peer-to-Peer ). Tuy nhiên thông dụng nhất vẫn là qua HTTP. • REQUEST var url:String = “http://hallopatidu.com/testxml.php” var request:URLRequest = new URLRequest(url); • POST / GET method
  • 6. Flash với javascript • From ActionScript: Gọi hàm Javascript. Gửi các đối số với tên của chúng. Gửi được một vài kiểu dữ liệu (Boolean, Number, String, and so on). Nhận và trả về giá trị lấy từ Javascript. function test(val){ alert(val); } • From JavaScript: Gọi được các hàm từ Actionscript Gửi các đối số theo chuẩn. Trả về như bình thường với một javascript function. – var call_java:uint; – call_java = ExternalInterface.call('test','666');
  • 7. Practice • Truy cập vào file php đặt trên máy chủ • Truy cập vào database thông qua php
  • 8. Homework • Tạo lưu điểm cho game • Hướng dẫn: - Gửi điểm lên host thông qua php - Xử lý php ghi vào cơ sở dữ liệu - Hiển thị điểm của người chơi có điểm cao nhất