This is an easy tutorial, but it can be very useful for those that need to pass variables into flash. I use this for many different purposes. It can be everything from passing the name of a table in a database to just passing the name of a video file to your custom made flash video player. All you do is pass the variable just like you would in a url. For example, my.swf?video=sweetvideo. You just append the variable name, video, with the value you want to pass, sweetvideo. These variable/value pairs are read into flash by the following code:
var passed:String = video == undefined ? "Nothing Passed" : video;
inner_txt.text = passed;
This code will display the value you pass into the movie assuming that you have created a dynamic text field named inner_txt. If you fail to pass a variable, it will display Nothing Passed.
For all of those non "Computer Science" people out there. The var passed:String = video == undefined ? "Nothing Passed" : video; is the shorthand version of doing the following:
if (video == undefined){
var passed:String = "Nothing Passed";
}
else {
var passed:String = video;
}
This can be very useful for creating one flash video and using it in many different locations. All you need to do is check the variable that is passed. However you should be careful not to give away too much with this variable, because someone could hack your swf and pass bogus information to it.
SUPPORT THIS SITE If this tutorial helped you, show your support and send me something from my wish list. Click on an item below and then choose Adam Hayes (Gift Registry Address) for the Ship to Address. It is that easy!