Skip navigation

Monthly Archives: July 2009

  • @rjacquez It's like Darth Vader saying, "You do not know the power of Flash Widgets." #
  • Checking out Captivate 4: Fix for small text in Short Answer question http://bit.ly/10tpJy Thx @rjacquez! #

Powered by Twitter Tools.

I made my first AMFPHP application with Flash CS4. (Inspired by Lee Brimelow’s AMFPHP tutorial.) It is basically a countdown timer by retrieving the current time from the server. (I made this in preparation for a conference at church, and figured that since we have visits from all over the world, getting the server time via the server [which was in Eastern Time] was the best approach instead of getting the date and time via the Actionscript date class which is client side.)

I found a PHP script by Louai Munajim to retrieve the time left in days; hours; and minutes. And inserted it in the “amfphp/services” folder on my server.

[cc lang=”php” tabs=”2″ lines=”40″]


[/cc]

Then, in my .fla I placed a TextField on the stage with an instance name of: “countdown_txt”, and inserted this code in Flash in the Actions panel:

[cc lang=”actionscript3″ lines=40]

function onResult(response:Object):void {
trace(“response > ” + response);

var time_left_array:Array = [];
time_left_array = response.split(“;”);

if (time_left_array[0] == “0”) {
countdown_txt.text = “Today!n” + ((time_left_array[1] == “0”) ? “Right Now!n” : (time_left_array[1] + ” hoursn”));
} else {
countdown_txt.text = time_left_array[0] + ” Days : ” + time_left_array[1] + ” Hrs : ” + time_left_array[2] + ” Min”;
}

}

gw = new NetConnection();
res = new Responder(onResult, onFault);

gw.connect(“http://yourserver/amfphp/gateway.php”);
gw.call(“CountDown.targetDate”, res, 2009, 10, 4, 10, 0 ); // Oct 4 2009, 10 am, 0 minutes

[/cc]

Files:

The only issue that I had was that I was getting Flash Errors which prevented me from accessing the CountDown.php function. I found out that it was an internal server error (500) and found at the gotoandlearn forums that the .htaccess file was hindering access to the PHP method in question. Once deleting this file in the “amfphp” directory, amfphp worked fine.

[kml_flashembed publishmethod=”static” fversion=”10.0.0″ useexpressinstall=”true” movie=”http://www.geminilearning.com/swf/countdown.swf” width=”160″ height=”100″ targetclass=”flashmovie”]Get Adobe Flash player

[/kml_flashembed]

DJ

I had taken some video tutorials at Flash Extensions.com way back, and I always liked Robert Taylor’s appoach in using the trace command in Actionscript. I would represent this via the “tr” method in each of my classes so that when I am previewing the program, I can know in which class I can find the origin of my trace statements. AS3 is not much different since you can use multiple arguments in your function parameters.

The AS2 version used an undocumented arguments array in the parameters of a function like this:

[cc=”actionscript” tab_size=”2″ lines=”40″]
// This method in a class called MyClass

private function tr(arguments):Void {

if (arguments.length == 0) {
trace(“”);
} else {
trace(“[MyClass] … ” + arguments.join(” : “));
}

}
[/cc]

In AS3,

[cc=”actionscript3″ tab_size=”2″ lines=”40″]
// This method in a class called MyClass

private function tr(… args:Array):void {

if (args.length == 0) {
trace(“”);
} else {
trace(“[MyClass] … ” + args.join(” : “));
}

}
[/cc]

  • Watching "Intro to Captivate for new users." #
  • @peterelst Tour de Flex #

Powered by Twitter Tools.

  • @lordalex I know that Adobe has Tech Wednesday sessions. Is there a general link for that? #

Powered by Twitter Tools.

Powered by Twitter Tools.