[ Team LiB ] |
28.4 Making the Scheduler Application Available OnlineThe scheduler application that you have created thus far retains a user's schedule only when it is run consistently from the same computer. This is because the schedule data is stored in a local shared object. However, with just a few small changes, you can adapt this application so it can be accessed online from any computer. In the next two sections, you can choose from three different alternatives for how to do this. 28.4.1 Using Remote Shared ObjectsThe easiest way to convert the scheduler application to make it available online is to store the data in a remote shared object instead of a local shared object. However, this option is available only if you have access to a FlashCom server. To modify the application to use a remote shared object, complete the following steps:
28.4.2 Using Flash RemotingThe second option for saving the scheduler data on a server is to use Flash Remoting. Obviously, this option works only if you have access to a Flash Remoting server. However, you can use this method without Flash Remoting by using the FauxSharedObject class from Chapter 27. You need to have the FauxSharedObject class ready to include in your Flash document and to also have the ColdFusion Component on the server, as per the instructions from Chapter 27. Once you have that code in place, you can quickly modify your schedule application by changing a small amount of code in the schedule component. The following shows the relevant code with the changes in bold: #initclip // Include the FauxSharedObject class from Chapter 27. #include "FauxSharedObject.as" function Schedule ( ) { this.items = new Object( ); this.notifiers = new Object( ); // Use a FauxSharedObject in place of the local shared object. Set the load handler // to the new setValues( ) method and load the data. this.so = new FauxSharedObject("mySchedule", "http://localhost:8500/flashservices/gateway"); this.so.setLoadHandler("setValues", this); this.so.load( ); this.runNotify( ); this.interval = setInterval(this, "runNotify", 600000); this.saveInterval = setInterval(this, "save", 5000); } Schedule.prototype = new MovieClip( ); // The code in setValues( ) was previously included in the constructor. Schedule.prototype.setValues = function ( ) { if (this.so.data.schedules != undefined) { for (var i in this.so.data.schedules) { var dt = this.so.data.schedules[i].siDate; this.addItem(dt); this.items[dt].setValues(this.so.data.schedules[i]); } this.notifiers = this.so.data.notifiers; } } // The remainder of the code does not change. |
[ Team LiB ] |