This document provides an overview of a Flash + ActionScript workshop that will cover drawing basic shapes and curves in Flash, creating animations using the timeline and actionscript, and learning basic ActionScript syntax and object-oriented programming concepts. The workshop is divided into three parts - the first covers drawing squares, rectangles, and curves using the drawing tools; the second demonstrates how to create a simple animation using the timeline that moves and image and includes actions like stopping and jumping to frames; the third introduces ActionScript classes, variables, functions and events through a simple example of creating a class for a square object that can be resized when clicked.
This is a handout from a Flash workshop I recently conducted at the National University of Singapore. It contains step by step instructions covering Flash basics, ActionScript and also Flash-PHP communication. Feel free to contact me if you find any bugs! :)
Graphics Experts Ltd is the right solution for all of your graphic design needs. We offer affordable, professional services that encompass everything from image masking, shadow creation, web image optimization, and clipping path to image manipulation, image retouching, color adjustments, photo editing, vehicle enhancement, and even illustration.
This is a handout from a Flash workshop I recently conducted at the National University of Singapore. It contains step by step instructions covering Flash basics, ActionScript and also Flash-PHP communication. Feel free to contact me if you find any bugs! :)
Graphics Experts Ltd is the right solution for all of your graphic design needs. We offer affordable, professional services that encompass everything from image masking, shadow creation, web image optimization, and clipping path to image manipulation, image retouching, color adjustments, photo editing, vehicle enhancement, and even illustration.
Learning Illustrator CS6 with 100 practical exercisesMCB Press
Â
Illustrator CS6, vector drawing application from Adobe, is an excellent tool for computer-aided design. Thanks to its amazing and powerful features, you can create original artwork using drawings and images for it. Do not hesitate to make the 100 exercises in this book to discover the thousand and one possibilities hidden in this great program, as advocated by professionals.
With this book:
Meet the new applications of pattern creation tool enhanced.
Discover also improved image tracing tool that now provides clean lines and perfect fit.
Apply gradients on strokes to get interesting and striking results.
Leverage the revamped interface with optimized panels and other new features that make it more intuitive, efficient and flexible.
Enjoy improvements to some effects, such as Gaussian blur, glare and shadows, which are applied much faster now.
PowerPointLabs (http://www.comp.nus.edu.sg/~pptlabs/) is an add-in for PowerPoint to help less-experience user to make professional-look presentation slides. This presentation is a brief tutorial about the PowerPointLabs.
Putting together a slide show.
Using slide animation effects.
Controlling a slide show using the Presenter Console.
Quick printing.
Emailing a presentation.
Learning Illustrator CS6 with 100 practical exercisesMCB Press
Â
Illustrator CS6, vector drawing application from Adobe, is an excellent tool for computer-aided design. Thanks to its amazing and powerful features, you can create original artwork using drawings and images for it. Do not hesitate to make the 100 exercises in this book to discover the thousand and one possibilities hidden in this great program, as advocated by professionals.
With this book:
Meet the new applications of pattern creation tool enhanced.
Discover also improved image tracing tool that now provides clean lines and perfect fit.
Apply gradients on strokes to get interesting and striking results.
Leverage the revamped interface with optimized panels and other new features that make it more intuitive, efficient and flexible.
Enjoy improvements to some effects, such as Gaussian blur, glare and shadows, which are applied much faster now.
PowerPointLabs (http://www.comp.nus.edu.sg/~pptlabs/) is an add-in for PowerPoint to help less-experience user to make professional-look presentation slides. This presentation is a brief tutorial about the PowerPointLabs.
Putting together a slide show.
Using slide animation effects.
Controlling a slide show using the Presenter Console.
Quick printing.
Emailing a presentation.
This is a short tutorial for my students at USC, teaching them how to use Adobe's Edge Animate application to create an animated infographic. I go through some simple steps, using the Rectangle, Text and Clipping tools to show how to create a simple bar graph, and then using the Timeline, to make the bars bounce up into view.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
Â
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
⢠The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
⢠Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
⢠Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
⢠Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
DevOps and Testing slides at DASA ConnectKari Kakkonen
Â
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Â
Clients donât know what they donât know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clientsâ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Â
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Dev Dives: Train smarter, not harder â active learning and UiPath LLMs for do...UiPathCommunity
Â
đĽ Speed, accuracy, and scaling â discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Miningâ˘:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing â with little to no training required
Get an exclusive demo of the new family of UiPath LLMs â GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
đ¨âđŤ Andras Palfi, Senior Product Manager, UiPath
đŠâđŤ Lenka Dulovicova, Product Program Manager, UiPath
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
Â
As AI technology is pushing into IT I was wondering myself, as an âinfrastructure container kubernetes guyâ, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefitâs both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Â
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Â
Are you looking to streamline your workflows and boost your projectsâ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, youâre in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part âEssentials of Automationâ series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Hereâs what youâll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
Weâll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Donât miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Â
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overviewâ
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
JMeter webinar - integration with InfluxDB and Grafana
Â
Flash
1. Flash + Actionscript Workshop
7 February 2009
By CHIN Su Yuen (suyuen@gmail.com)
âŠ
Getting Started
Hi! In this workshop we will be going through the basics of Flash, Actionscript
and also Flash + PHP communication.
Part 1: Drawing basic shapes & curves
In this section we will go through how to draw basic shapes and curves using
the vector tools provided.
A square
1. Before we begin, let us perform some basic setups. Create a new
Flash Actionscript 3.0 document.
2. In the properties panel, you will be able to see the details of your stage.
The size should be 550 x 400px. If it is not so, click on the âEditâ button
beside the size and change its values.
3. In your timeline panel, you can see that âLayer 1â has already been
added for you. To create new layers, you can click on the âNew Layerâ
icon ( ) located on the bottom left of the timeline panel. You can
also drag and drop layers to switch their positions. An object in an
upper layer will appear on top of an object in the lower layer. Now
double click on âLayer 1â and rename it âSquareâ.
2. 4. Select the âRectangle Toolâ icon ( ) from the tools panel. Note that
if you click on the âRectangle Toolâ again, you will see a list of other
possible shapes like ovals and circles. After youâve selected the
âRectangle Toolâ, the properties panel will change to show the
properties of the rectangle you are about to draw.
5. Under âFill And Strokeâ, you should be able to see this:
The left, white-coloured box represents the outline colour (also known
as stroke colour) of the rectangle. The box on the right represents the
fill colour of the rectangle. Double click on the stroke colour box and
change it to black.
6. Click and drag the cursor on the stage to draw your box. You should be
able to see a rectangle of the colours you picked. Notice that the
stroke/outline of the rectangle is a bit thin. Lets make it thicker.
7. Select the âSelection Toolâ icon ( ) from the Tools panel. Bring
your cursor close to the rectangle until you see a curved line close to
your cursor. Click on the line. You will see that only one side of the
rectangleâs outline has been selected. (Note that you can use the
âSelection Toolâ to remove / move parts of the rectangle away from the
main shape).
Double click on the line and all 4 lines of the rectangle will be selected.
In the properties panel, you can move the âStrokeâ slider to alter the
thickness of the outline. Lets bring it to 2.
Curves
1. Ok, now let us move to something more fun (hopefully)âŚ. Drawing
curves using the pen tool. Clear your stage by deleting the rectangle.
Click on the âPen toolâ icon ( ) from your tools panel.
2. Draw one dot anywhere on the stage. For your second dot, click
anywhere but this time, hold down the left mouse button and drag your
3. cursor. You should be able to see a curve forming according to the
tangent line as below.
Continue doing this for the 3rd, 4th and XXXXth dots to create as many
curves as you want.
3. What if you donât like a curve you have created? No worries. It is
adjustable. Select the Subselection Tool ( ) from the tools panel
and click on the curve. You will be able to see small hollow squares
representing the points you drew. Click on any one point and the
tangent like before will appear at the selected point. Click and drag any
of the ends of the tangent point and you will see the curve change.
There you have it, the basics of shape and curve drawings in Flash!
Part 2: Animations
Now we are going to learn how animations work in Flash by creating a simple
animation.
1. Assuming we are all lazy people and have images we already want to
use, let us import the images we will be using into our Flash library. To
do this, click File > Import > Import To Library.
Note: If you import a file to a library, in the future when you want to use
multiple instances of the file, all you have to do is drag and drop from
the library onto the stage. This saves a lot of memory usage as Flash
will only load the object once from the library instead of multiple times.
4. 2. After importing, click on the Library Panel tab (located beside the
Properties panel tab). You should be able to see your imported image
there. Click and drag it onto the stage. You should know see your
image on the stage.
3. Right click on your image and select âConvert to Symbolâ. Name your
symbol anything you want. In this case, I picked âImage1â and for Type,
select âGraphicâ. You should be able to see your newly created symbol
in the Library panel as well.
4. In the timeline, right click on the first keyframe of the layer where your
symbol is placed. (There should be only one layer unless you created
new layers). Select âCreate Motion Tweenâ and you should see the
timeline filled with blue frames.
5. Left click on Frame 10. Move your image onto any other location of
your choice. Left click on Frame 25. Move the image to another
location. If you move the red slider in the timeline back and forth, you
will be able to see your image playing. To see the actual .swf playing,
click Control > Test Movie.
6. Feel that your animation is playing too fast? Move close to the end of
the last keyframe and you should see your cursor convert into a double
arrow. Drag it to Frame 50. Try playing the animation now.
7. If you notice, it is repeating non-stop. Lets make it stop at the last
keyframe. Create a new layer and name it âActionsâ. This will be the
layer where we will put all our keyframe actions. Right click on Frame
50 and select âInsert Keyframeâ. We are inserting a keyframe here
because we want it to stop at only frame 50.
8. Right click on the keyframe youâve just added and select âActionsâ. You
should see an âActionsâ box pop up. Type in âstop()â which is the action
script for stopping a movie.
9. Once youâre done, save your file and try playing the animation again.
Your animation should now stop at the end ď
10. Now lets try creating an animation that will jump to another frame and
play from there. In the âActionsâ layer, insert a keyframe into frame
number 40. Right click on it and select âActionsâ. In the âActionsâ box
pop up, type in âgotoAndPlay(20)â. Now retry your animation. Notice
that everytime it reaches frame 20 it will jump to frame 20 and play
from there.
There you have it, your simple animation in Flash! Now let us try toying
around with some other effects.
5. In-class Exercise
1. Create an animation containing an object fading in and fading out.
(Hint: Try fiddling with the alpha value of an object)
âŠ
Part 3: ActionScript Basics
ActionScript is an Object Oriented Programming language (I assume all of
you know what OOP is). Here we will go through some very simple basics of
ActionScript and its syntaxes.
1. Create a new Flash ActionScript 3.0 document. This is the Flash file
where we will be seeing the output of our work. Save it as any name
you want.
2. On the Stage, draw a blue square. Once youâve drawn the blue square,
right click on it and select âConvert to Symbolâ. Enter âblueSquareâ as
the name of the symbol (very important for ActionScript file later).
Under Type, select âMovieClipâ.
Why did I select âMovieClipâ? The answer will be revealed later.
Ok now before you go ahead and click âOKâ, click on the âAdvancedâ
button located towards the lower right corner of the window.
More options should appear. Under the âLinkageâ section, check
âExport for ActionScriptâ and the Class and Base Class text fields
should have automatically been filled for you. If it isnât, enter the
following:
Class: blueSquare
Base class: flash.display.MovieClip
Ok! Now you can press âOKâ.
Note: If a message box pops up saying âA definition for this class could
not be found in the classpathâ just press OK. (Donât worry, it will not
cause us any harm in the future).
3. Double click on the blueSquare. You should see the following image on
the upper left part of the Stage.
6. This shows that you are in the âblueSquare Movie Clipâ editing mode.
Any animations you create here will not show up in the original stage
(Scene 1) timeline. In other words, it means that the blueSquare
animation will run independent of what happens in Scene 1.
4. Ok now create a simple animation of the blue square going left and
right. (By now you should be able to do it on your own right?). Once
yourâe done, click âScene 1â on the top left corner of the stage and
5. Test the movie. You should see the blue square animation playing.
6. Ok! Now we shall start with some âactionscriptingâ. First we shall create
a new actionscript file. Select File > New. In the pop up box, select
âActionScript Fileâ.
7. You will see a blank document. This is like your typical text editor
where you will be typing in codes for your classes. Save it as
âblueSquare.asâ in the same location as your earlier .fla file. Note: See
why we named the symbol âblueSquaresâ earlier now? ď
8. Copy and paste the following code into âblueSquare.asâ.
package
{
import flash.events.*;
import flash.display.*;
public class blueSquare extends MovieClip
{
public function blueSquare()
{
this.addEventListener(MouseEvent.CLICK,onClickEvent);
}
function onClickEvent(event:Event)
{
this.width = this.width / 2;
this.height = this.height / 2;
}
}
}
9. Test the movie and try clicking on the square. You should see it
decreasing in size everytime you click on it. v
Explanation of code:
Now we will go through the code line by line while explaining some basic
syntaxes of ActionScript.
7. As you can see, we started the code with the word âpackageâ. This is the
package of your object that contains the class definition and functions.
import flash.events.*;
import flash.display.*;
The 2 lines above are importing libraries from Flash to be used in your
ActionScript file. Here we are importing the display and events library.
public class blueSquare extends MovieClip
This is the class definition. You might be wondering where MovieClip is
coming from. As earlier weâve imported the flash.display library, we used a .*
at the end. This means that we have imported all the components in that
library and hence can use it without typing the full flash.display.MovieClip.
public function blueSquare()
This is the constructor of your class.
this.addEventListener(MouseEvent.CLICK,onClickEvent);
This adds an event listener to your blueSquare object. In thise case, it is a
mouse click event. The syntax is this.addEventListener(eventType,
functionToCall). In this case, I named my function that will be called when a
mouse is clicked on the box âonClickEventâ.
function onClickEvent(event:Event)
{
this.width = this.width / 2;
this.height = this.height / 2;
}
To define a function in ActionScript, you start with the word âfunctionâ. The
syntaxes are: function nameofFunction(typeOfInput). In this case, as it is a
mouse event, it is of the Event type. Hence, the event:Event. The âthisâ in the
function refers to the blueSquare object. Here, I am halving the blueSquareâs
size by half everytime it is clicked on.
In-Class Exercise
1. Create an object which users can drag around the stage.
(Hint: Use the startDrag() and stopDrag() functions)
2. Create an object and remove it from the stage when it is clicked.
(Hint: Use the removeChild() function. Note that you have to call
the parent to remove the child)
âŠ
Note that there are many types of events predefined in ActionScript and also
mouseEvents which you can experiment with.
8. Refer to http://labs.adobe.com/wiki/index.php/ActionScript_3 which contains
an official documentation of AS3 from Adobe.
Ok, what about defining variables and setting their values?
Now lets create something simple to understand how variables work in
ActionScript.
1. Create a new Flash file and name it anything you want. Save it.
2. Create a new ActionScript File and name it ObjectName. Copy and
paste the following code into it:
package
{
private var ObjectName2;
public function setName(tempName:String):void
{
ObjectName2 = tempName;
}
public function getName():String
{
return ObjectName2;
}
}
The code above declares a variable ObjectName. Notice that the first word
âprivateâ is the accessor. âvarâ tells Actionscript that we are defining a
variable.
Notice that in the SetName function definition we have some new syntaxes.
âtempName:Stringâ says that the function takes in a variable of type String. In
this case, we named the variable âtempNameâ. The â:voidâ says that the
function does not return any value.
In the getName function definition, we put â:Stringâ as the function returns a
value of type String.
Ok so we have defined these in the ActionScript file. What next? We have to
call these functions or else we will not be able to see them in action. Lets use
the Flash file we created earlier.
3. In the Flash file youâve created earlier, right click on the first keyframe
and select âActionsâ. Enter the following code:
var name1:ObjectName = new ObjectName();
name1.setName(âFacebookâ);
trace(name1.getName());
9. In the first line, we declared creating a variable. The syntax is:
var variableName:typeName. In this case, the variable name is âname1â and
the type is âObjectNameâ which we defined earlier. We then used the
constructor in ânew ObjectName()â to create a new object.
In the second line, we are setting the objectâs name to âFacebookâ using the
setName() function we defined earlier.
Lastly, we use a âtraceâ command which in Flash, will return you results in the
âOutputâ panel shown below. You can use this method from time to time to
trace values being passed around in between your functions when testing
movies :D
4. Run the program. You should see an âOutputâ panel where the
âTimelineâ panel used to be. In there, you should see the text
âFacebookâ.
Playing around with textboxes
Now we will play around with the idea of creating a textbox that users can
input values into and have the value displayed in the output. In this tutorial, we
will be showing you how to add actionscript to Flash files instead of an
external ActionScript file.
1. Create a new Flash document. Click on the Text icon ( ) from the
Tools panel.
2. In the âPropertiesâ panel, select âInput Textâ from the drop down menu
in the upper section of the panel.
10. 3. Draw a textbox on the stage.
4. Look at the âPropertiesâ panel now. You should see a new field appear
at the upper section of the panel with the values â<Instance Name>â in
it.
5. You can name the text box anything you want. This will be the name
you will use to refer to the textbox in your action script code later. For
ease of memory, lets name it âtextBoxâ.
6. Test the movie. If you notice, the textbox canât be seen in your movie
as it does not have a border. Create a new layer and draw the
rectangle in the textbox area so that users can see where they are
supposed to enter text. (Note: Make sure that this new layer is below
the textBox layer so that it does not overlap the textBox.)
7. Test the movie again. Now you will be able to see the textbox and type
things into it.
8. Ok! Now let us play around with some actionscript. In the layer
containing the textBox, right click on the first keyframe containing the
timeline and select Actions. Enter this code:
textBox.text = "Enter your name here and press OK";
This code will set the default values that will appear in the box.
9. We need a trigger for users to click on that will display the values
entered in the Output. To do this, create a box. Right click on the box
and convert it into a button symbol and give it the name okButton.
10. Look in the âPropertiesâ panel and type in the instance name
âokButtonâ. This is the name we will be using to refer to this button in
the actions panel.
11. Open the actions panel where your textBox actions was and Add an
event listener to it and the trigger function with the following code:
okButton.addEventListener(MouseEvent.MOUSE_DOWN, trace_name);
I believe that this code needs no explanation.
11. Test your movie now and you should see the name typed in by the user
appear in the output everytime the button is clicked.
In-class Exercise
1. Try manipulating the value obtained from the textbox (E.g:
Adding words to the back of it). Hint: Make use of
variables.
function trace_name(event:Event)
{
trace(textBox.value);
Flash talking to PHP
}
âŠ
Now we will learn to how to make Flash communicate with PHP.
1. Lets start by creating a PHP file. Copy and paste the following code
into it and upload it onto your server. Name it test.php.
<?php
$x = "Testing PHP communication!";
print "$x";
?>
The code above will return the value of variable $x to our Flash file. In
this case, it contains a string with the value âTesting PHP
communication!â.
2. Create a new flash file and create a text box on the stage. Make sure
that it is a dynamic text box. Give it the Instance Name âtextBoxâ.
Remember, this is the name you will need to call when you want to
change the value of the textbox later.
3. Convert it to a âMovieClipâ symbol and give it any name you want.
4. Double click on it to enter the symbolâs editing mode. In the first
keyframe, right click and select âActionsâ. Paste the following code:
var myLoader:URLLoader = new URLLoader();
myLoader.load(new
URLRequest("http://cs3216.comp.nus.edu.sg/suyuen/test.php"));
myLoader.addEventListener(Event.COMPLETE, onLoad);
function onLoad(ev:Event)
{
this.textBox.text = myLoader.data;
}
12. Note: Change the website address in the code above to the location of
your âtest.phpâ file.
5. Test the movie and you should see the text âTesting PHP
Communication!â in your text box. :D
Explanation of code:
var myLoader:URLLoader = new URLLoader();
URLLoader is a variable type required to perform URLRequest functions.
Here, we are declaring the variable âmyLoaderâ as the type URLLoader.
myLoader.load(new
URLRequest("http://cs3216.comp.nus.edu.sg/suyuen/test.php"));
Here, we are loading the values returned by the âtest.phpâ file into the
myLoader variable.
myLoader.addEventListener(Event.COMPLETE, onLoad);
We only want to show data in the textbox after all the data from the âtest.phpâ
file has been loaded into the myLoader variable. Hence, we add an event
listener to only trigger the function when the process is complete.
function onLoad(event:Event)
{
this.textBox.text = myLoader.data;
stop();
}
The function triggered to display text in the textbox.
So now we have seen how to obtain a value from a PHP file. What about
sending a value over? In the current Flash file, open up the Actions panel and
replace the code with the following.
var myRequest:URLRequest = new
URLRequest("http://cs3216.comp.nus.edu.sg/suyuen/test2.php");
var myLoader:URLLoader = new URLLoader();
var myVariables:URLVariables = new URLVariables();
myVariables.name1 = "Su Yuen";
myRequest.method = URLRequestMethod.GET;
myRequest.data = myVariables;
function onLoaded(event:Event):void {
this.textBox.text = myLoader.data;
}
myLoader.addEventListener(Event.COMPLETE, onLoaded);
myLoader.load(myRequest);
13. Next, create a new PHP file called âtest2.phpâ and copy and paste this code
into it.
<?php
$first_name = $_GET['name1'];
echo $first_name." is happy!";
?>
Explanation of code:
var myVariables:URLVariables = new URLVariables();
URLVariables is a class type that is needed for variables that will be sending
values to a URL. This is because it will ensure that the values are URL
Encoded before they are sent to your PHP file.
myVariables.name1 = "Su Yuen";
Here we are defining a property (name1) of myVariables and assigning a
value to it. Note that this is required as URLVariables abstracts the
name/value pairs you want to send to the server.
myRequest.method = URLRequestMethod.GET;
myRequest.data = myVariables;
Here we set the request method to GET and assign the value of the variable
to myRequestâs data property.
Ok! So now you know how Flash can communicate with PHP. What about
Facebook? It is the exact same principle. However, in your PHP file when
embedding the SWF, take note to add this line of code to it:
<fb:swf swfsrc='http://cs3216.comp.nus.edu.sg/flash/test.swf'
width='600' height='600' >
The web address is the location of your .swf file. Take note that this URL
MUST be the absolute URL else it will not work.
Get your PHP file to echo any values you retrieve and it will appear in the
Flash file just as shown above. ď
âŠ
In-class Exercise
1. Now that you have learnt the basics of sending and requesting
data between Flash and PHP, try loading an image into Flash
based on a website address of the online image location
returned by PHP. (Hint: GOOGLE has tutorials) âŠ
AND WE ARE DONE!
14. References you might want to check out!
1. Kirupa Flash & Actionscript Tutorials
http://www.kirupa.com/developer/flash/index.htm
2. Detailed explanation about Flash + PHP Communication functions
http://www.peterelst.com/blog/2007/11/28/actionscript-30-wheres-my-
loadvars/
3. Alternativa Platform (Open source, 3D flash engine)
http://alternativaplatform.com/en/
4. Swift 3D (Program for 3D Flash Object modeling)
http://www.erain.com/
5. Integrating your Flash game into Facebook
http://www.emanueleferonato.com/2008/05/30/integrate-your-flash-
game-on-facebook/
6. Actionscript 3 Overview by Adobe
http://labs.adobe.com/wiki/index.php/ActionScript_3
7. Lots of tutorials on how to do cool Flash CS4 stuff
http://www.flashandmath.com/