PDA

View Full Version : mcs and its associated text to be displayed with no repetion and with time



nite21
June 4th, 2008, 01:23 PM
hi there all
i have 10 movieclips
2 mcs should be displayed each day(total 5 days for 10 mcs) on 10 am and 3 pm randomly
On the next day again new two mcs should be displayed and those mcs which has been already been displayed should not be repeated

i have the timer.zip (for time) and repeater.zip(for no repetion) files which are correct

pls chek someone to merge them together so that above thing can be achieved

here is the attached code



timer.zip
mytext.txt contains this content
&text1=test1
&text2=test2
&text3=test3
&text4=test4
&text5=test5
ActionScript Code:

textFile = new LoadVars()
textFile.onLoad = function(){
txt1 = this.text1;
txt2 = this.text2;
txt3 = this.text3;
txt4 = this.text4;
txt5 = this.text5;
};

textFile.load("myText.txt");

this.onEnterFrame=function() {
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
if(hours == 1){ // 1AM
mc1.gotoAndStop(2);
TextHolder.text = txt1;
mc5.gotoAndStop(1);
}
if(hours == 6){ // 2AM
mc2.gotoAndStop(2);
TextHolder.text = txt2;
mc1.gotoAndStop(1);
}
if(hours == 10){ // 3AM
mc3.gotoAndStop(2);
TextHolder.text = txt3;
mc2.gotoAndStop(1);
}
if(hours == 15){ // 4AM
mc4.gotoAndStop(2);
TextHolder.text = txt4;
mc3.gotoAndStop(1);
}
if(hours == 16){ // 5AM
mc5.gotoAndStop(2);
TextHolder.text = txt5;
mc4.gotoAndStop(1);
}
};




repeater.zip

ActionScript Code:

Array.prototype.shuffle=function(){
for(i=0;i<this.length;i++){
var tmp=this;
var randomNum=random(this.length);
this[i]=this[randomNum];
this[randomNum]=tmp;
}
}
var myInterval:Number;
var count:Number = 0;
var maxCount:Number = 4;
var examples:Array = new Array("text1.txt", "text2.txt", "text3.txt", "text4.txt", "text5.txt");
var mcs:Array = new Array("mc1","mc2","mc3","mc4","mc5");
var arr:Array = new Array(1,2,3,4,5);
arr.shuffle();
thisText = new LoadVars();
[I]//thisText.load("example1.txt");
thisText.onLoad = function(success)
{
if (success) {
TextHolder.text = thisText.counts;
}
};

function mytimer() {
eval("mc"+ran).gotoAndStop(1);
ran = arr[count];
count++;
if(count == 5){
clearInterval(myInterval);
}
thisText.load("text"+ran+".txt");
eval("mc"+ran).gotoAndStop(2);

}
if(myInterval != null) {
clearInterval(myInterval);
}

myInterval = setInterval(this, "mytimer", 2000, examples[count], mcs[count]);

nite21
June 4th, 2008, 01:36 PM
pls help me out some flash experts :(
or give some suggestions