I just meant that I set the code up to load the representative image based on the date...
So,
Code:
'images/img"+date_str+".jpg'
will load "images/img1.jpg", "images/img2.jpg", "images/img3.jpg", etc.
If you have a bunch of buttons (actual Button symbols), there is a much easier way to code ALL of them in one chunk of code, but you would have to convert them to movieclips. If they're already movieclips, let me know and I'll send you the code to use...
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
Cool...I try to avoid using buttons whenever possible (and just use movieclips for everything), but you can still do it this way...
I'm not sure why each day has a button and you still needed a way to tell each button to display the image based on the day, but this should help make the code centralized and easier to update.
First, make a copy of your file (in case you decide to go back to how you currently have it)
Remove all the scripts from your buttons, then, give each of your buttons an instance name, use sequential numbers, for instance, day1_btn, day2_btn, day3_btn, etc.
Put the following script in a frame (not on a button):
Code:
var today_date:Date = new Date();
var date_str:Number = today_date.getDate();
//replace the number below with however many buttons you have
var numBtns:Number = 30;
for (i=1; i<=numBtns; i++) {
daySelected = this["day"+i+"_btn"];
daySelected.i = i;
daySelected.onRelease = function() {
//put the code here to display an image based on the date
getURL("javascript:show('images/img"+date_str+".jpg','IMAGE CAPTION');");
//put the code here to do something based on the "number" of this button
trace("hit "+this.i);
};
}
Hope that helps!
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
I have tried your approach but dont seem to be getting anywhere I have followed your instruction but the weird thing is the action script doesnt have any effect on my fla.
I am not sure what i am doing wrong. Would it help if i posted an example of what I have done so far. Its completed except for the actionscript controlling which window on what day. At the moment all the doors open at the moment.
Hmm...well, a few things. If you're going to set this up to us one piece of code, you can't use sequential numbers and do "1st.jpg", "2nd.jpg", etc. since the final few characters are different. You can use whatever names you want if you set up an array with the names in there (like I did with the descriptions), or you can just use 1.jpg, 2.jpg, etc.
Not sure why the code I sent didn't work for you...works fine here...I attached your file with the code in there...
Also, still don't know where getting the current date comes into play??
Hope that helps!
Last edited by flashpipe1; 05-05-2011 at 10:24 AM.
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
I have looked at what you did and can make sense of it. I think i have not explained myself properly and do apologise for that - in a nutshell the end user should be able to click on whatever day it is in december at that moment in time, the window curls up and on press the product is displayed.
On the example you have sent across all the windows are still clickable but the window that should be the only one to open is window 3 as today is the 3rd November. Thats where getting the current date comes in.
flashpipe1 thank you so much we have lift off it works! Cant beleive it!
Last question I had an animation on there so that when you hover over the window peels open. How come you took it out? Can i put it back in or will it disrupt what we have come to now?
It all works now. There is only one glitch. When my image loads up the image description says undefined - this after uploading the swf/html file on the server, however when i test it in flash and put a trace statement in it displays the image description fine.
Thanks for your help flashpipe1 really appreciate it!
I am just getting started in flash and action script just findind the actionscript side of things a little tricky to grasp. In terms of learning shall i begin with as2 or start with as3?
The image description we have got it to work but it always displays the same image description no matter what window you select. I went back to the original file you uploaded to try and see where i have gone wrong but it seems to do the same thing as well. Any ideas?