Flash meets Drupal

2,530 views

Published on

You like Drupal? Or you like the Adobe Flash platform?

It's just a super CMS + a super multimedia tool = how wonderfull will be the result then?

This presentation helps you with the first steps illustrated by some simple examples!


Created by:
www.mistercreosoto.com
twitter.com/svyaene

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,530
On SlideShare
0
From Embeds
0
Number of Embeds
29
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Flash meets Drupal

  1. 1. Flash meets Drupal Sebastian Vyaene www.mistercreosoto.com twitter.com/svyaene
  2. 2. What is Drupal? Drupal is an free software package that allows an individual, a community of uses, or an enterprise to easily publish, manage and organize a wide variety of content on a website. Hundreds of thousands of people and organizations are using Drupal to power an endless variety of web sites including community web-portals, discussion sites, corporate web sites, intranet applications, personal websites or blogs, aficionado sites, e-commerce applications, resource directories, social networking sites... The build-in functionality, combined with thousands of freely available add-on modules, enables features such as electronic commerce, blogs, forums, peer-to-peer networking, newsletters, podcasting, picture galleries and much more.
  3. 3. What is Flash/ Flex? - A framework for the Adobe platform - IDE: Flash pro or FlashBuilder - Object Oriented - A declarative language: MXML (XML based) + ActionScript - Flex is a compiled language, not interpreted like HTML/CSS/JS/PHP - Runs on the Flash-/ AIR-player
  4. 4. Ingredients? - Drupal - Flash IDE required modules - Service module - AMFPHP module - AMFPHP optional - SWFaddress - SWFobject
  5. 5. Communication between Flash and Drupal? Remote Function Calls (RPC) - Uses XML to call a remote function - AMF (ActionScript Messages Format)
  6. 6. Connecting to Drupal and Session handling Flash must establish a connection with Drupal. Drupal manages the Flash connection using session IDs. 1 Flash calls system.connect 2 Drupal returns a valid session ID to Flash 3 Flash stores the session ID, then uses it for all other calls to Drupal
  7. 7. The Flash side 1 Use NetConnection to connect to Flash var drupal:NetConnection = new NetConnection(); drupal.objectEncoding = flash.net.objectEncoding.AMF3; drupal.connect("http://localhost/drupal6/services/amfphp"); 2 Create Responder to handle callbacks var responder:Responder = new Responder(onReturn, onError); 3 Make the Service call drupal.call("system.connect", responder);
  8. 8. Drupals response is handled using callback functions var responder:Responder = new Responder(onReturn, onError); Register for event drupal.call("system.connect", responder); Make the call var sessionId:String = ""; private function onReturn(result:Object) { sessionId = result.sessid An event. Let's do something! trace(sessionId); } private function onError(error:Object) { trace(error); }
  9. 9. Demo
  10. 10. The DrupalService class Only use one connection in the entire project.
  11. 11. The connection private function connect():void { baseURL = "http://labs.mistercreosoto.com/drupal/"; gateway = baseURL + "/services/amfphp"; apiKey = "a6d08083d7500c13d9a7859a91664884"; nodeId = 5; sessionId = ""; // var drupal:DrupalService = new DrupalService(gateway, apiKey); drupal.connectToDrupal(onConnect); } private function onConnect(result:Object) { sessionId = result.sessid; }
  12. 12. Get a node 1 Make a connection 2 When connection is succesfull, call a function 'loadNode' private function onConnect(result:Object) { sessionId = result.sessid; // loadNode(nodeId); } 3 Get the node private function loadNode(nid:Number):void { drupal.serviceCall("node.get", onNodeLoad, null, nid); } private function onNodeLoad(node:Object):void { currentNode = node; // content = new ContentMC(); content.titleField.text = node.title; // this.addChild(content); }
  13. 13. Demo
  14. 14. Edit a node 1 ... private function onNodeLoad(result:Object) { content.editor.submit.addEventListener(MouseEvent.CLICK, onNodeSubmit); } 2 ... private function onNodeSubmit(e:MouseEvent):void { var titleText:String = content.editor.titleField.text; // titleText = titleText.replace(/[tnrf]/,""); ... // var newNode:Object = new Object(); newNode.nid = currentNode.nid; newNode.type = "project"; newNode.title = titleText; ... drupal.serviceCall("node.save", onNodeCreate, onNodeError, newNode); } private function onNodeCreate(result:Object):void { drupal.serviceCall("node.get", onNodeLoad, null, nodeId); }
  15. 15. Demo
  16. 16. Thanks! Questions? www.slideshare.net/svyaene/flash-meets-drupal

×