Flash
  Home arrow Flash arrow Page 4 - Nonpersistent Client-Side Remote Shared Ob...
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
FLASH

Nonpersistent Client-Side Remote Shared Objects
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 2
    2009-01-08

    Table of Contents:
  • Nonpersistent Client-Side Remote Shared Objects
  • Instantiating Remote Shared Objects
  • Inspecting a Shared Object
  • Minimalist Project for Shared Movie Clip

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Nonpersistent Client-Side Remote Shared Objects - Minimalist Project for Shared Movie Clip


    (Page 4 of 4 )

    The first minimalist project uses a movie clip as a shared object. This one shows how to set up and move a pointer. In creating applications that have online slide shows that work something like a PowerPoint presentation, you need all of the viewers to see the pointer move to the location on the screen where you want the audience to focus. Using a hitchhiker thumb as a pointer, this application has numbers in each of the stage’s four corners. The four numbers are just positions on the stage so that you can see that when you move the pointer on the screen, it will go to the same positions on all of the screens connected to the application. You’ll use these classes and objects for the application:

    Classes
      
    NetConnection

       SharedObject

    Objects
      
    Movie Clip (1)

    The following steps will walk you through the project:

    1. Open a new Flash document and set up the following layers, from top to bottom: Actions, MC, and Background.
    2. In the Background layer, place a number from 1 to 4 using a 48 point font in each of the four corners of the state as shown in Figure4-2. Lock the layer.
    3. Select the MC layer and draw a pointer—this can be any shape you want. (The sample in Figure 4-2 shows a hitchhiker’s thumb, but you can use a big arrow or any other pointer shape you want.)
    4. Select the shape and press F8 to open the Convert to Symbol dialog box. Select Movie Clip and click OK. Select the movie clip on the stage and provide it with the instance namepointer_mcin the Properties panel. Lock the layer. 


      Figure 4-2.  Completed stage
    5. Click on the first frame of the Actions layer and type in the following script in the Actions Panel:

       1  //Connect
       2  var rtmpNow = "rtmp:/zbasicSO";  
       3  //var rtmpNow = "rtmp://domain.name.com/zbasicSO";
       4  var nc:NetConnection = new NetConnection();
       5  nc.onStatus = function(info) {
       6     trace(info.code);
       7  };
       8  nc.connect(rtmpNow);
       9  //Shared object
      10  pointer_so = SharedObject.getRemote("point", nc.uri, false);
      11  pointer_so.onSync = function() {
      12     pointer_mc._x = pointer_so.data.x;
      13     pointer_mc._y = pointer_so.data.y;
      14  };
      15  pointer_so.connect(nc); 16  //Control Shared Object
      17  pointer_mc.onPress=function () {
      18     this.onMouseMove = function() {
      19        pointer_so.data.x = this._x=_level0._xmouse;
      20        pointer_so.data.y = this._y=_level0._ymouse;
      21     };
      22     pointer_mc.onRelease = pointer_mc.onReleaseOutside=function () {
      23        delete this.onMouseMove; 24     };
      25  };
    6. If it does not exist already from the previous example, in the server-side FMS2 root, create a new folder and name it zbasicSO.
    7. Once you have completed the application, publish it (File > Publish). When you test it, you have to open a second window with the same application so that you can see two instances running at the same time. You will see that when you move the pointer on one screen, it also moves on the other.

    Note: If you are connecting to an FMS2 server via the Internet, it’s best to upload the files to a web server to avoid running into security issues while testing.

    In looking at the code, you will see that the value of the shared object is based on changes in the position of the mouse pointer. Whenever the mouse moves, both the _x and _y values of the mouse position are passed to the shared object data attributes as well as the pointer. Whenever the shared object values change, they trigger theonSyncevent handler that updates the shared object values on all of the connected clients.

    Please check back next week for the conclusion to this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This article is an excerpt from the book "Learning Flash Media Server 2, an O'Reilly...
     

    FLASH ARTICLES

    - Critical Flash Vulnerability Heats Up the Web
    - More on Nonpersistent Client-Side Remote Sha...
    - Nonpersistent Client-Side Remote Shared Obje...
    - Using the Decorator Pattern for a Real Web S...
    - Using Concrete Decorator Classes
    - Delving More Deeply into the Decorator Patte...
    - The Decorator Pattern in Action
    - A Simple Decorator Pattern Example
    - Decorator Pattern
    - Organizing Frames and Layers for Flash Anima...
    - Organizing Frames and Layers
    - Using XML and ActionScript with Flex Applica...
    - Interfaces and Events with ActionScript and ...
    - Manipulating Data with ActionScript in Flex ...
    - ActionScript Syntax for Flex Applications







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek