photomassimo
04-13-2007, 12:43 PM
Hi guys i am doing a page similar to this one
www.frostdesign.co.uk
and somebody gave a fla but i am having difficolties adjusting it to my needs.
I don't know much about as so maybe this project(for my photo portfolio) is a little bit out of my league.
This is the code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var w=800
var h=600
num = 5
function drawSquare(clip, depth, colour, x, y, w, h) {
var mc = clip.createEmptyMovieClip("clip"+depth, depth);
mc._x = x;
mc._y = y;
mc.lineStyle(0);
mc.beginFill(colour);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.endFill();
return mc;
}
function drawTriangle(clip, depth, colour, x, y, w, h) {
var mc = clip.createEmptyMovieClip("clip"+depth, depth);
mc._x = x;
mc._y = y;
mc.lineStyle(0);
mc.beginFill(colour);
mc.lineTo(w, 0);
mc.lineTo(w/2, h);
mc.endFill();
return mc;
}
cliparray = [];
current = 1;
currentv=0
this.createEmptyMovieClip("holder", 1);
holder._y =0
holder.startx = holder._x=-600
for (var i = 0; i<num; i++) {
var hh = holder.createEmptyMovieClip("h"+i, i);
hh.attachMovie("p"+i, "p", 1);
var t = hh.attachMovie("t"+i, "t", 2);
t._y = h;
//add more here but increae jvar by 1 for each + _y =2*h,_y =3*h increase each time
hh.jvar = 1
hh._x = i*w;
hh.starty = hh._y;
hh.ivar = i;
hh.up = false;
cliparray.push(hh);
hh.endy = h-hh._height;
}
holder.endx =w+600-holder._width;
function tweener(tx) {
var s = new Tween(holder, "_x", Elastic.easeOut, holder._x, tx, 2, true);
s.onMotionFinished = function() {
disableall(true);
};
}
function vertmove(ty,target,callback) {
onEnterFrame = function () {
target._y += (ty-target._y)/3;
if (Math.abs(ty-target._y)<2) {
target._y = ty;
delete this.onEnterFrame
callback()
}
};
}
function moveleft(){
if(w-current*w -600>holder.endx){
currentv = 0
current++;
tweener(w-current*w-600);
}
}
function moveright(){
if(w-current*w-600<holder.startx+600){
currentv = 0
current--;
tweener(w-current*w-600);
}
}
function leftF() {
vertmove(0,cliparray[current],moveleft)
}
function rightF() {
vertmove(0,cliparray[current],moveright)
}
function upF() {
if(currentv<cliparray[current].jvar){
currentv++
vertmove(-h*currentv,cliparray[current])
}
}
function downF() {
currentv=0
vertmove(-h*currentv,cliparray[current])
}
left.onPress = leftF;
right.onPress = rightF;
up.onPress = upF;
down.onPress = downF;
function disableall(t) {
left.enabled = t;
right.enabled = t;
up.enabled = t;
down.enabled = t;
}
up.swapDepths(10000)
down.swapDepths(10001)
left.swapDepths(10002)
right.swapDepths(10003)
/*to mask
var mask = this.createEmptyMovieClip("m",100)
drawSquare(mask, 1000, 0, 0, 100,w*3,h);
holder.setMask(mask)
*/
I have 4 buttons on the site that are on the stage and these are my questions so far:
1) how od i add more mc, i did the linkage and created more of them but how do i do it?
for (var i = 0; i<num; i++) {
var hh = holder.createEmptyMovieClip("h"+i, i);
hh.attachMovie("p"+i, "p", 1);
var t = hh.attachMovie("t"+i, "t", 2);
t._y = h;
//add more here but increae jvar by 1 for each + _y =2*h,_y =3*h increase each time
hh.jvar = 1
hh._x = i*w;
hh.starty = hh._y;
hh.ivar = i;
hh.up = false;
cliparray.push(hh);
hh.endy = h-hh._height;
where do i exactly change the number of mc into the script?
2)
I just want the first pic to move right and no left at the beg of the movie ho do i do that and also how do i disable the left button at the beginning of the movie and the right at the end(when it reaches both ends)?
3 the mask...my movie is 1200 by 600 and the mc are 800 by 600 and i wanna have an alpha effect on the mask
var mask = this.createEmptyMovieClip("m",100)
drawSquare(mask, 1000, 0, 0, 100,w*3,h);
holder.setMask(mask)
Thanks a lot guys
Massimo
www.frostdesign.co.uk
and somebody gave a fla but i am having difficolties adjusting it to my needs.
I don't know much about as so maybe this project(for my photo portfolio) is a little bit out of my league.
This is the code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var w=800
var h=600
num = 5
function drawSquare(clip, depth, colour, x, y, w, h) {
var mc = clip.createEmptyMovieClip("clip"+depth, depth);
mc._x = x;
mc._y = y;
mc.lineStyle(0);
mc.beginFill(colour);
mc.lineTo(w, 0);
mc.lineTo(w, h);
mc.lineTo(0, h);
mc.endFill();
return mc;
}
function drawTriangle(clip, depth, colour, x, y, w, h) {
var mc = clip.createEmptyMovieClip("clip"+depth, depth);
mc._x = x;
mc._y = y;
mc.lineStyle(0);
mc.beginFill(colour);
mc.lineTo(w, 0);
mc.lineTo(w/2, h);
mc.endFill();
return mc;
}
cliparray = [];
current = 1;
currentv=0
this.createEmptyMovieClip("holder", 1);
holder._y =0
holder.startx = holder._x=-600
for (var i = 0; i<num; i++) {
var hh = holder.createEmptyMovieClip("h"+i, i);
hh.attachMovie("p"+i, "p", 1);
var t = hh.attachMovie("t"+i, "t", 2);
t._y = h;
//add more here but increae jvar by 1 for each + _y =2*h,_y =3*h increase each time
hh.jvar = 1
hh._x = i*w;
hh.starty = hh._y;
hh.ivar = i;
hh.up = false;
cliparray.push(hh);
hh.endy = h-hh._height;
}
holder.endx =w+600-holder._width;
function tweener(tx) {
var s = new Tween(holder, "_x", Elastic.easeOut, holder._x, tx, 2, true);
s.onMotionFinished = function() {
disableall(true);
};
}
function vertmove(ty,target,callback) {
onEnterFrame = function () {
target._y += (ty-target._y)/3;
if (Math.abs(ty-target._y)<2) {
target._y = ty;
delete this.onEnterFrame
callback()
}
};
}
function moveleft(){
if(w-current*w -600>holder.endx){
currentv = 0
current++;
tweener(w-current*w-600);
}
}
function moveright(){
if(w-current*w-600<holder.startx+600){
currentv = 0
current--;
tweener(w-current*w-600);
}
}
function leftF() {
vertmove(0,cliparray[current],moveleft)
}
function rightF() {
vertmove(0,cliparray[current],moveright)
}
function upF() {
if(currentv<cliparray[current].jvar){
currentv++
vertmove(-h*currentv,cliparray[current])
}
}
function downF() {
currentv=0
vertmove(-h*currentv,cliparray[current])
}
left.onPress = leftF;
right.onPress = rightF;
up.onPress = upF;
down.onPress = downF;
function disableall(t) {
left.enabled = t;
right.enabled = t;
up.enabled = t;
down.enabled = t;
}
up.swapDepths(10000)
down.swapDepths(10001)
left.swapDepths(10002)
right.swapDepths(10003)
/*to mask
var mask = this.createEmptyMovieClip("m",100)
drawSquare(mask, 1000, 0, 0, 100,w*3,h);
holder.setMask(mask)
*/
I have 4 buttons on the site that are on the stage and these are my questions so far:
1) how od i add more mc, i did the linkage and created more of them but how do i do it?
for (var i = 0; i<num; i++) {
var hh = holder.createEmptyMovieClip("h"+i, i);
hh.attachMovie("p"+i, "p", 1);
var t = hh.attachMovie("t"+i, "t", 2);
t._y = h;
//add more here but increae jvar by 1 for each + _y =2*h,_y =3*h increase each time
hh.jvar = 1
hh._x = i*w;
hh.starty = hh._y;
hh.ivar = i;
hh.up = false;
cliparray.push(hh);
hh.endy = h-hh._height;
where do i exactly change the number of mc into the script?
2)
I just want the first pic to move right and no left at the beg of the movie ho do i do that and also how do i disable the left button at the beginning of the movie and the right at the end(when it reaches both ends)?
3 the mask...my movie is 1200 by 600 and the mc are 800 by 600 and i wanna have an alpha effect on the mask
var mask = this.createEmptyMovieClip("m",100)
drawSquare(mask, 1000, 0, 0, 100,w*3,h);
holder.setMask(mask)
Thanks a lot guys
Massimo