So here goes my stackoverflow debut... (And I tried searching and reading thru a lot of posts (php flash date) before asking this)
I would like to make an swf that will find out what date it is and do sometinhg correspondingly. Eg. go to a specific frame or load a movieClip.
I would also like to avoid the Actionscript "Date Class" because I need to feel fairly certain that my end user will see the swf of the day not of his/her local date-setting.
So I'm thinking to somehow bring in php with 'echo date' inside the swf and then have the result create a goto-(or load-)command.
To make matters worse I have to rely only on code within the swf using ActionScript2 (in CS开发者_如何转开发4 or 5). I am not able to publish any outside php (or any other code for that matter) so everything must be done internally. Only swf has to work regardless of server (I am expecting the server will work with php)
So I hope some gurus here will be able to tell me: 1. If this is possible 2. How I make the date thing happen in Flash 3. And how I somehow grab the date as a variable (?) and make that determine some action.
How do you like them apples?
To get the date from server, use loadVariablesNum. Let's say you have the date as string in the format you specified on date.php, "Y-m-d", you can do something like:
// split the string into of an array of day, month and year.
var dateString:String = "2011-05-08";
var parts:Array = dateString.split("-");
// now create the date as an Date instance. ( just to be more organized, but you can just save day, month and year into separate vars.
var date:Date = new Date(parts[0],parts[1]-1,parts[2]);
// If you have a frame for each day
gotoAndStop(mydate.getDate());
精彩评论