Basic ActionScript and PHP Cis 126. Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your.

Slides:



Advertisements
Similar presentations
JQuery MessageBoard. Lets use jQuery and AJAX in combination with a database to update and retrieve information without refreshing the page. Here we will.
Advertisements

PHP I.
Learning the Basics – Lesson 1
CHAPTER 3 MORE ON FORM HANDLING INCLUDING MULTIPLE FILES WRITING FUNCTIONS.
Introduction to PHP MIS 3501, Fall 2014 Jeremy Shafer
© 2010 Delmar, Cengage Learning Chapter 9: Using ActionScript.
The Web Warrior Guide to Web Design Technologies
Links and Comments.
Flash Workshop Flash Workshop :: Agenda  Introductions  Look at a few Flash Examples  Flash Web Sites  Flash Web Applications  Flash Games.
Kapi’olani Community College Art 258 Interface Programming II In-class Presentation Week 5A.
Macromedia Dreamweaver 4 Advanced Level Course. Add Rollovers Rollovers or mouseovers are possibly the most popular effects used in designing Web pages.
Python and Web Programming
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
MS3304: Week 4 PHP & HTML Forms. Overview HTML Forms elements refresher Sending data to a script via an HTML form –The post vs. get methods –Name value.
Advance Database Management Systems Lab no. 5 PHP Web Pages.
PHP : Hypertext Preprocessor
Week 4  Using PHP with HTML forms  Form Validation  Create your own Contact form Please Visit:
Reading Data in Web Pages tMyn1 Reading Data in Web Pages A very common application of PHP is to have an HTML form gather information from a website's.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Lab Assignment 7 | Web Forms and Manipulating Strings Interactive Features Added In this assignment you will continue the design and implementation of.
MIS 3200 – Unit 6.2 Learning Objectives How to move data between pages – Using Query Strings How to control errors on web pages – Using Try-catch.
1 CS 3870/CS 5870 Static and Dynamic Web Pages ASP.NET and IIS.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Project Four Forms Discuss form processing Describe the difference between client-side and server-side form processing Add a horizontal rule to a Web page.
XP Tutorial 5 Buttons, Behaviors, and Sounds. XP New Perspectives on Macromedia Flash MX Buttons Interactive means that the user has some level.
© Cheltenham Computer Training 2001 Macromedia Dreamweaver 4 - Slide No 1 Macromedia Dreamweaver 4 Advanced Level Course.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Dynamic Action with Macromedia Dreamweaver MX Barry Sosinsky Valda Hilley.
CNIT 133 Interactive Web Pags – JavaScript and AJAX JavaScript Environment.
Publishing a Macromedia Flash Movie – Lesson 131 Publishing a Macromedia Flash Movie Lesson 13.
2 1 Sending Data Using a Hyperlink CGI/Perl Programming By Diane Zak.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 7: Web Forms © 2007 Prosoft Learning Corporation All rights reserved ITD 110 Web Page Design.
Tutorial 8 Programming with ActionScript 3.0. XP Objectives Review the basics of ActionScript programming Compare ActionScript 2.0 and ActionScript 3.0.
Tutorial 7 Planning and Creating a Flash Web Site.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Forms and Server Side Includes. What are Forms? Forms are used to get user input We’ve all used them before. For example, ever had to sign up for courses.
CSC 2720 Building Web Applications Server-side Scripting with PHP.
Intro to PHP IST2101. Review: HTML & Tags 2IST210.
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
HTML Form Widgets. Review: HTML Forms HTML forms are used to create web pages that accept user input Forms allow the user to communicate information back.
1 Building FORMS In When a visitor enters information into a web form displayed in a web browser and clicks the submit button, the information is sent.
Introduction to JavaScript CS101 Introduction to Computing.
XP Tutorial 8 Adding Interactivity with ActionScript.
Producing a high-impact web experience by integrate Macromedia Flash and ASP By Katie Tuttle CS 330: Internet Architecture and Programming Project.
Using Flash with php Very quick introduction to Flash Homework: work on projects.
XP Tutorial 7 Creating a Flash Web Site. XP New Perspectives on Macromedia Flash 82 Objectives Plan and create a Flash Web site Create a Flash template.
+ FORMS HTML forms are used to pass data to a server. begins and ends a form Forms are made up of input elements Every input element has a name and value.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
Since you’ll need a place for the user to enter a search query. Every form must have these basic components: – The submission type defined with the method.
CIS 205—Web Design & Development Flash Chapter 3 Appendix on Using Buttons.
Open a new Flash File Action Script 2.0. Create a button like you did last lesson and name it Click to Play.
Debugging tools in Flash CIS 126. Debugging Flash provides several tools for testing ActionScript in your SWF files. –The Debugger, lets you find errors.
PHP Form Processing * referenced from
XP Tutorial 8 Adding Interactivity with ActionScript.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
JavaScript and Ajax (JavaScript Environment) Week 6 Web site:
INTERNET APPLICATIONS CPIT405 Forms, Internal links, meta tags, search engine friendly websites.
CDM105 Session 12 Macromedia FLASH MX 2004 Part 5 : Sounds, publishing your movies, and the ‘Get URL’ action.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
var variableName:datatype;
Creating a Flash Web Site
In this session, you will learn to:
Learning the Basics – Lesson 1
Using the HTML and CSS Validation Services
* Lecture # 7 Instructor: Rida Noor Department of Computer Science
Intro to PHP & Variables
Integrating JavaScript and HTML
Interface Programming 2 Week 1
Web Programming and Design
Presentation transcript:

Basic ActionScript and PHP Cis 126

Getting Started set up a basic folder structure so we can keep our files organized. Mirror this structure on your remote server

Setting Up for Publishing Next we're going to create a fla and set up the export options as we want them to be. So, open a fla, name it dogYears.fla save it in the flash folder you just created. within the flash file go to file -> publish settings and click on the first tab: formats.

Setting up for Publishing Make sure the flash and html boxes are ticked, then click on the folder to the right of the flash box. A popup window appears navigate to the swf folder you just created, as we want to save our swf as dogYears.swf in that swf folder. Now repeat the above process for html. All our html files are going to go directly in to the root folder Publish the movie ( file -> publish ) and check that the swf and html end up in the correct folders. They did?

In DreamWeaver Create the Basic PHP File <?PHP $calculation= $_POST['years']*7; echo $calculation; ?>

Creating the Flash File On the first frame of the main timeline create a small input textbox with an instance name of years. Now create a simple button and give it an instance name of myBtn.

The user will be able to enter their age in the input box and press the button. This sends our number to the PHP script, which will multiply it by seven. The result will be sent to an HTML page for testing

Setting Up a LoadVars object The first thing we want to do is set up a LoadVars object We'll also set up a variable called path - this has nothing to do with LoadVars. It only serves to make it easier for us to change our site folder structure in the future, if we should want to, with the minimum of hassle.

ActionScript // INITIALIZE path = "../nwjv/php/"; //declare path to php files lvOut = new LoadVars(); //create lv object

Button Code Load the following in the same frame: // BTN CODE myBtn.onRelease = function(){ //assign user-input value to lv property called years lvOut.years = years.text; //send to a blank window lvOut.send(path + "dogyears.php","_blank"); };

Explaination In the above code we specify an onRelease event for our button. When the button is released we create a new property called years, and we assign it the value of our user input box. Next we use the send method of our LoadVars object to send our object to whatever script we specify. The two arguments supplied are URL and TARGET. For the URL we use our path variable (which is set to equal "../nwjv/php/"), plus the name of our script (dogyears.php); and for the target we specify "_blank" which forces a new HTML browser window to open up. In the PHP script we created earlier. It uses a built in PHP function called "echo" - which does the same as "print" and prints out stuff to an HTML page. We've told it to multiply our number by 7 and then echo the result, so it should print the result of 7*year to the HTML page. Save your fla and lets try it.

Test it Once you can see the Flash interface enter a number - let's say 7 - into the input box and press the button. A new browser window should pop open, and that page should have the number 49 printed to it.

Passing Variables back to Flash Comment out the line echo $calculation; and replace it with the following: echo "&returnVal=$calculation";

Variables out of PHP Flash can receive data in name-value pairs (variables in the format of name=value). If there is more than one pair then each name-value pair is separated by an ampersand, and so a typical string of name-value pairs may look like this: &name1=Neil&location1=Bristol&name2=Justin&lo cation2=London& The final ampersand is optional.

Sending back to Flash If Flash is expecting a value to be returned then it will pick up this returned value and we can use it in our Flash movie. We still use the PHP language construct echo to output our value from PHP, –We echo it in "name-value pair" format so that Flash can understand it.

Create Container Create a dynamic textbox on stage, –make it multiline –wordwrap –give it the instance name of output.

Replace the code on frame 1 stop(); INIT path = "../nwjv/php/"; //declare path to php files lvOut = new LoadVars(); //create lv object lvIn = new LoadVars(); //create lv object lvIn.onLoad = function (success) { if(success){ //PHP variable value to textbox output.text = lvIn.returnVal; }else{ //...or notify of failure output.text = "fail"; } } // BTN myBtn.onRelease = function(){ //assign user-input value to lv property called years lvOut.years = years.text; //send to a blank window... // lvOut.send(path + "dogyears.php","_blank"); //get results returned to lvIn lvOut.sendAndLoad(path + "dogyears.php", lvIn, "POST"); }; Text Available on Class Web Page

Code explained First we store our path, as a string in a variable called path. Next we create two loadVars objects. One object will be sent from Flash to PHP, and the other object receives the value sent back from PHP to Flash. Next we use the onLoad method of our LoadVars object to tell Flash what to do if the load is successful but basically if the sendAndLoad is successful our returnVal variable will have been sent from PHP to FLASH, and will automatically be stored inside our loadVars object called lvIn

Send and Load Method When our button is released we take the value the user has inputted in the Flash input textbox, and add it to our [outgoing] LoadVars object as a new property. To make things easy for ourselves we decide to call the new property years lvOut.years = years.text; lvOut.sendAndLoad(path + "dogyears.php", lvIn, "POST"); We use the built in sendAndLoad() method of the loadVars object to send data and receive data. Let me explain in more detail:

Send and Load We use lvOut's sendAndLoad() method instead of its load() method. –This allows us to send variables and get them posted back to Flash. –To use sendAndLoad we need to send it three arguments; the path of our script, the LoadVars object to which we want our PHP data returned our method of sending, which is "POST". –At the beginning of the code we created an LoadVars object called loadIn, and we get out Flash data sent here because we specified it in the sendAndLoad() method.

We've set up lvIn's onLoad method, so it knows what to do when data is loaded in to it. – If you remember, in the PHP code we set it up to echo a name-value pair, which was basically: returnVal=$calculation; The name-value pair is returned to Flash – –the variable name becomes a property name of the lvIn instance (lvIn.returnVal), and the value gets stored in that property (so lvIn.returnVal will equal $calculation).

Test the file Generate the files and upload them to the server. Then open up dogYears.html Enter a number into the input box and press the button. The value of the calculation should now appear in the output textbox –you can see that the data has gone to PHP, been manipulated and then sent back and displayed in Flash!