A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


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

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


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

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Trading Customer Accounting (IL)
Next Step Systems
US-IL-Chicago

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
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs