A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11303 Flash Movies | 7 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Nitin Tikhe
» Title: Cart
» Description: This Animation Tut is a fun and useful for kids below 15 years. Watch the Flag, Doors, Stick and Horse movements.
» More by Nitin Tikhe


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 6008 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: Banana Swimwear
» Description: This is a banana swim wear interactive catalog we designed and animated in Flash


Random Links | Add your own Flash Related Links
Flash Tutorials 1255 Tutorials 7 New Tutorials Added!
What's New | Top100

» Make flash video player for broadcasting live streaming video / TV on website
» How to convert the project file of Flash Demo Builder 2.0 into FLV file
» FLV to PSP for Mac - How to convert YouTube video to PSP on mac
» How to Convert FLV to MP4 for Playback on iPod
» how to download and convert youtube video to AVI with Leawo Free FLV converter
» Flash Multi-player Game Tutorial - TicTacToe
» How to make Flash elearning tutorials with screen recorder?
» Fader API:Slideshow with MovieClips on stage
» How to convert MS PPT file into an FLV File
» Unknown Tag: Title10
Random Tutorial | Add Site

Network Design Manager
The Computer Merchant, Ltd
US-VA-Hampton

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Backend

Categories Building Flash clients for Web Services with Soap and Flash MX
Author: Jeffrey F. Hill | Website: http://www.flash-db.com/services/ |

 
Page 5
«prev 1 2 3 4 5 6 7 next»

Sending the data from the Translation script

First we have to add some ActionScript to let the movie know what to do when someone clicks on the 'Translate Now' Push button component. This is shown as follows (remember the push button was given an instance name of 'submit'):

// Set the change Handler function for the push button named 'submit'
submit.setClickHandler("onClick");

Now that we have that set up - we add the 'onClick' function. This function will locate all of the necessary data in the movie and send it to the script which handles the translation.

// Function to handle what the movie does when some one selects a mode and clicks the push button.
function onClick(){
 // Grab some values from the ComboBox and the Input Text Field.
 sendMode 			= comboBox.getSelectedItem().data["mode"];
 sendText	    		= Input.text;
 // Load New vars.. (this is the Load Vars object that will send and receive the response from the server,
 //  ie - sends 2 variables to a PHP script - then returns an Object that has the translation.
 translate 			= new LoadVars();
 // Add Vars to translate Object.
 translate.Mode        		= sendMode;
 translate.sourceData  		= sendText;
 // This Tells the Flash movie What function to invoke when the Load Vars Is complete.
 translate.onLoad 		= addTranslation;
 // Find the Text File - Load it - after which the function addTranslation is invoked.
 translate.sendAndLoad("Translate.php", translate, "POST");
}

Ok what where doing here is getting the selected mode and the text entered by the user in the text field with instance name 'Input'. Then creating a new Load Vars object and sending it to the script which handles everything else. The important thing here is that we load up the Load Vars object with all of the variables we want to send to the script. In this case we are naming the new load Vars object 'translate' - so we add two variables to the Object in standard dot syntax ie (translate.Mode = sendMode). So now the Translate Object has 2 variables associated with it - Mode and sourceData. Mode is the language conversion we want to do, and sourceData is the user entered text to translate. We then use the sendAndLoad method to send these variables via "POST" to the receiving script. We also set an .onLoad function (addTranslation) to handle what's returned.

Recieving the data from the Translation script

So before we get to the Server side of this, we set up the function addTranslation.

function addTranslation() {
Output.htmlText = translate.soapOut;
}

The Text field with instance name 'Output' receives the results of the script (the translated text). The same Load Vars Object is referenced in this case (translate) - and it now contains the resulting data. Make sure to specify the output sent to the 'Output' text field as HTML text. This is done by using the property - .htmlText. So now the Output text field knows that it is receiving HTML text and will format it correctly.

So now the Flash Client is set up and ready to send and receive the data.

«prev 1 2 3 4 5 6 7 next»

» Level Advanced

Added: : 2002-08-19
Rating: 6.90 Votes: 10
Hits: 2101
» Author
Jeffrey Hill is a freelance web developer from Boulder, Colorado. He specializes in creating and developing dynamic database driven Flash content, applications, and content management systems. Specialty's include SQL, PHP, Perl, XML, web services, and Flash clients for web services.
» Download
Download the files used in this tutorial.
Download (251 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments