Using WebServices in FMS
This one is a quick beginner tutorial on using WebServices in Flash Media Server. Here you will learn how to retrieve web-service data from server side and pass it to all users connected to application. As an example I’m going to retrieve weather forecast.
- Let’s start from creating a new application(folder) on server and
call it “webservice-tutorial” or whatever you like. - Create main.asc file and copy the following code.
// Load WebService component. load("webservices/WebServices.asc"); application.onAppStart = function() { trace ("Application Started"); // Load WebService. this.loadWS(); } application.onConnect = function(client) { // Handle client functionality... application.acceptConnection(client); } application.loadWS = function() { // Define WebService. weatherService = new WebService("http://www.webservicex.net/WeatherForecast.asmx?WSDL"); weatherService.onLoad = function() { trace ("weatherService loaded..."); // Invoke getWeatherByName method and set interval // to invoke it every 10 seconds for example. application.getWeatherByName("New York"); setInterval(application.getWeatherByName, 10000, "New York"); } weatherService.onFault = function(fault) { // Handle error here. trace (fault.faultstring); } } application.getWeatherByName = function(location) { // Invoke web-service method passing it the location. weatherByName = weatherService.GetWeatherByPlaceName(location); weatherByName.onResult = function(result) { var newObj = new Array(); // Loop throught result and push needed fields to array. for ( var i = 0; i < result.Details.length; i++ ) { newObj.push({day:result.Details[i].Day, min:result.Details[i].MinTemperatureC, max:result.Details[i].MaxTemperatureC}); } var c = application.clients; if ( c.length ) { // Loop throught clients and pass weather data. for ( var j = 0; j < c.length; j++ ) { c[j].call("setWeather", null, newObj); } } } weatherByName.onFault = function(fault) { // Handle error here. trace(fault.faultstring); } }
Everything should be clear if you have Read more
AMFPHP Flex Guestbook
Would like to present you the first beta release of my Flex Guestbook. A week ago I’ve started to write a tutorial on creating a full featured paging, but ended up in a more complex example.
The application is tied with amfphp services which so far can return comments and insert them, the client part formats and displays posts, has a paging feature and of course a simple form to insert your data. At this point I stoped, to show the work in progress, so you could help me to define what other features I can add. Of course, there should be an admin part to moderate the content. But should it be an external app, or be right there in guestbook? Should there be multiple administators/moderators with different access level? Or maybe something is wrong or uncomfortable in existing version?
Would really like to hear any suggestions, meanwhile feel free to test the FGuestbook demo.
After getting some feedback, I’ll finish this project and open-source it.
As all my other projects it’s build on PureMVC framework, so it should be a good example for pmvc users or those who would like to learn it!
Mac Style Flash Menu
I always wanted to re-create Mac OS X menu in flash, so considering that it’s a bad practice to invent a bicycle, I started to look for some examples, to see what others might have done. As expected, I found a bunch of shitty ones, but there always is a light in the end of a tunnel. Finally I found a really nice one at http://jrgraphix.net/. Link to post and example is here. It’s an ActionScript2 class that looks really nice, so I took it as a base for my AS3 version. Click on the image below to see the example.

As you see, I refactored the class so it’s properties could be dynamicly changed. The example is build on PureMVC framework, so handling events like updating properties of menu or listening for it’s events is pretty simple.
There is actually a little bug, that I was too lazy to fix. It’s when mouse is over the menu, and then exits swf area, menu doesn’t return to it’s initial state. No big deal.
So feel free to download and examine the source. Maybe someone can create a cool application out of this. For any questions, bugs, or whatever else just contact me.