Flash
  Home arrow Flash arrow Page 2 - More on Nonpersistent Client-Side Remote S...
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

More on Nonpersistent Client-Side Remote Shared Objects
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 4
    2009-01-15

    Table of Contents:
  • More on Nonpersistent Client-Side Remote Shared Objects
  • Minimalist Project for Shared Function
  • A More Than Minimal Text Chat
  • A Better Chat Application

  • 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


    More on Nonpersistent Client-Side Remote Shared Objects - Minimalist Project for Shared Function


    (Page 2 of 4 )

    This next little minimalist project is very cool. It allows you to open a web page on someone else’s browser. You can open up a web page from any domain, not just your local one. Here are the classes and objects you’ll use:

    Classes
      
    NetConnection

       SharedObject

    Objects
      
    TextInput Component (1)

       Button Component (1)

    In setting up a link to another URL, ActionScript employs thegetURL(url)function. Because the function’s argument is the string with the URL, the argument will be the shared object. Figure 4-4 shows a chunk of code from the project that traces the changing of the shared object to the firing of the function. The three key elements are numbered from 1 to 3.

    In step 1, a function is defined that includes a shared object data attribute in the definition. In step 2, an unnamed function (webPageobject) assigns the shared object a new value when the user presses a button and fills in an InputText component. In step 3, the change in the shared object triggers theSharedObject.onSyncfunction that contains thegetURL(url)function. Thus, all connections open up the same web page. Use Figure 4-5 as a guide and use the following steps to create the full application:


    Figure 4-4.  Path of shared object events


    Figure 4-5.  Objects and instant names

    1. Open up a new Flash document and set up the following layers, from top to bottom: Actions, Text Input Component, Button, and Label.
    2. In the Text Input Component layer, add a TextInput component and provide it with the instance nameurl_ti.
    3. Add a button to the Button layer and give it the instance nameurl_button.
    4. Add the label Enter URL Name (without http://) using static text on the Label layer. Add a logo in the upper left corner. 
    5. Click the first frame of the Actions layer and add the following script:

        1  var rtmpNow:String;
       2  rtmpNow="rtmp:/zbasicSO"; 
       3  //rtmpNow = "rtmp://192.168.0.11/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  var webpg_so:SharedObject = SharedObject.getRemote("showWeb", nc.uri, false);
      11 webpg_so.onSync = function() {
      12     showURL(webpg_so.data.urlName); 13 };
      14 webpg_so.connect(nc);
      15 //Open URL
      16 var defaultURL:String = "
      www.sandlight.com";
      17 url_ti.text = defaultURL;
      18 url_button.label = "Show Web Page"; 19 showURL = function (urlNow) {
      20     if (urlNow) {
      21        getURL("
      http://"+webpg_so.data.urlName,"_blank"); 22     }
      23 };
      24 var webPage:Object = new Object(); 25 webPage.click = function() {
      26         webpg_so.data.urlName = url_ti.text;
      27         url_ti.text = "";
      28 };
      29 url_button.addEventListener("click",webPage);

    When you run the program on a single machine with two instances, you will get two of everything, but run with two or more computers, you will see a web page appear for all your connections.

    More Flash Articles
    More By O'Reilly Media


       · 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 1 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek