Groups | Blog | Home
all groups > flash actionscript > march 2005 >

flash actionscript : need help with scripting


savetuba
3/25/2005 11:02:42 PM
I am trying to make a date sensor that will play one of the symbol movies on
certain days

This is what I have:

ADate = new Date();
daynum = ADate.getDate()-1;
mm = ADate.getMonth();
file = "mm" + "daynum";
//can't find the (and) funtion so I put a + for now


switch (daynum) {
case 0: daynum = "1";
break;
case 1: daynum = "2";
break;
case 2: daynum = "3";
break;
case 3: daynum = "4";
break;
case 4: daynum = "5";
break;
case 5: daynum = "6";
break;
case 6: daynum = "7";
break;
case 7: daynum = "8";
break;
case 8: daynum = "9";
break;
case 9: daynum = "10";
break;
case 10: daynum = "11";
break;
case 11: daynum = "12";
break;
case 12: daynum = "13";
break;
case 13: daynum = "14";
break;
case 14: daynum = "15";
break;
case 15: daynum = "16";
break;
case 16: daynum = "17";
break;
case 17: daynum = "18";
break;
case 18: daynum = "19";
break;
case 19: daynum = "20";
break;
case 20: daynum = "21";
break;
case 21: daynum = "22";
break;
case 22: daynum = "23";
break;
case 23: daynum = "24";
break;
case 24: daynum = "25";
break;
case 25: daynum = "26";
break;
case 26: daynum = "27";
break;
case 27: daynum = "28";
break;
case 28: daynum = "29";
break;
case 29: daynum = "30";
break;
case 30: daynum = "31";
break;
}

switch (mm) {
case 0: mm = "1";
break;
case 1: mm = "2";
break;
case 2: mm = "3";
break;
case 3: mm = "4";
break;
case 4: mm = "5";
break;
case 5: mm = "6";
break;
case 6: mm = "7";
break;
case 7: mm = "8";
break;
case 8: mm = "9";
break;
case 9: mm = "10";
break;
case 10: mm = "11";
break;
case 11: mm = "12";
break;
}

this.createEmptyMovieClip("file", this.getNextHighestDepth());


I've tried loadmovie, get movie and many other combinations of the two.
Could someone give me a hand by showing what I am doing wrong and possibly
helping me with this code?

NSurveyor
3/26/2005 3:44:32 AM
You've got a wee bit too much code - all those switches are unnecessary (you
can simply use the String conversion function). And, you don't use quotes
around a variable, because then its just the string that you typed between the
quotes. Try something simple like this:

ADate = new Date();
daynum = ADate.getDate();
mm = ADate.getMonth()+1;
file = String(mm) + String(daynum);
this.createEmptyMovieClip(file, this.getNextHighestDepth());

However, I don't see why you are using createEmptyMovieClip. It will just make
an empty movieclip with a name like, 36.

BTW, some of the month-day combinations will be the same as other
combinations. For instance,
MM=12 Daynum=3, file=123,
MM=1 Daynum=23, file=123,

You might want to put an underscore between month and day, so its liike 12_3
and 1_23.
savetuba
3/31/2005 6:32:48 PM
Thanks for pointing out the same combinations, completly forgot about that.

To clarify;
The idea is to have flash determin what day it is then play that day's movie
clip. so if it is 12/3 then it would play movie file 1203 (or 12_3). Then it
would enter into the rest of the programming of the given movie clip.

So I'm assuming load movie clip would be a better command choice than create
empty movie clip.

Edit: Just tested the coding and the movie file (3_31 in the library) fails to
load. Could it be the command load movie is the wrong command or do I have to
have some place on the stage where the movie sits (scene 2, 3, 4, ect...)
My coding:

ADate = new Date();
daynum = ADate.getDate();
mm = ADate.getMonth()+1;
file = String(mm) + "_" + String(daynum);
loadMovie(file, this.getNextHighestDepth());

Library contains mov 3_31, 4_1, 4_2. 3 png files (one png to each mov file)
Each mov file contains 3 keyF of text, 1 png, and place holder for an outside
movie from a different program (like poser5)


For those who wonder, I havn't programed in over 6 years (not counting C++ or
html) so I'm rather "rusty"

Thanks again for the reply and if I have any more troubles I'll be posting
here again.

Thank you
Savetuba

savetuba
4/1/2005 10:01:40 PM
To rephrase my question:

ADate = new Date();
daynum = ADate.getDate();
mm = ADate.getMonth()+1;
file = String(mm) + "_" + String(daynum);
loadMovie(file, this.getNextHighestDepth());

does load movie load a mov file from the library or from outside the swf file?
And what command would load the file from the library and onto the current
stage?

Once I finish the entire coding I'll post it all here.
NSurveyor
4/7/2005 12:00:00 AM
loadMovie loads external JPG's and SWF's
AddThis Social Bookmark Button