3W14 – Script

9 04 2008

finally… it took me about 2 months to come up with the correct scripting for my web site and I must admit that I feel very proud. It took a lot of scripting research and some programing. All I can say is that it was a very hard for me since my scripting skills are just above zero.

Here is the hardest and the final script for randomize and reseting images. The software that I am using is swishmax2.

onFrame (1)
{
myPicsArr=new Array();
pics=_parent.picsmc

for(pic in pics){
img=variable(“pics.” + pic)
if(typeof(img)==”movieclip” and img!=pics){
img._xscale=60;
img._yscale=50;
img.onPress=function(){
this.startDragUnlocked();
this._xscale = 136;
this._yscale = 112;
}
img.onRelease=img.onReleaseOutside=function(){
this.stopDrag();
}
myPicsArr.push(img);
}
}

// Randomizing
for (i=0;i<myPicsArr.length;i++){
r=Math.randomInt(myPicsArr.length)
//Swaping two elements
temp=myPicsArr[i]; myPicsArr[i]=myPicsArr[r];  myPicsArr[r]=temp;
}
// re arranging
hs=img._width+5;vs=img._height+5;picPerRow=8;ypos=-32;
for (i=0;i<myPicsArr.length;i++){
xpos=(i)%picPerRow
if(xpos==0 && i!=0)ypos+=vs
myPicsArr[i]._x=xpos*hs-pics._x;
myPicsArr[i]._y=ypos;
}
pics._x=_parent._width/2+img._width/2-5;
stop();
}

Advertisements

Actions

Information

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




%d bloggers like this: