Asigning functions to an array

hi
could some one please explane how i would make this code work.
I have a array of MC that are placed on the stage to make up a logo
what i would like is to fade through the clips. I thought i could creat an array and atach a fade function to it but it dosn’t seem to work.

here is my code

function init(){
//create an array for my movie clips
euro = new Array ( b1,b2,b3,b4,b5,b6,b7,b8,e1,e2,e3,e4,e5,e6,e7,e8
,e9,e10,e11,e12,e13,e14,e15,e16,e17,e18,e19,e20
,e21,e22,e23,e24,e25,e26,e27,e28,e29,e30,e31,e32
,e33,e34,e35);
// create a loop through the array
for(var i =0 ; i<= euro.length ; i++){
euro*._alpha.fade(euro*);

}
}
// activate init()
init();
trace(b1._alpha);
// a function to fade the clips
function fade (theClip){
theClip._alpha = 0;
theclip.onEnterFrame = function(){
if(this._alpha <= 50){
this._alpha ++;
}
}

please help thank you

this -
function fade (theClip){

should be this -
function = fade(theClip) {

and this -
theclip.onEnterFrame = function(){

should be this -
theClip.onEnterFrame = function(){

I think…

I’m at work, so I can’t try it. :confused:

hi thanks for your help but this wont work i cheked in moocks book and when asigning a function the syntax is function function_name not function = Name the on enterframe bit i not sure what your getting as far as i can tell there is no syntax problem

cheers for your help though

You had several errors there. Here’s the correct code.


function init() {
	euro = new Array(b1, b2, b3, b4, b5, b6, b7, b8, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35);
	for (var i = 0; i<euro.length; i++) {
		fade(euro*);
	}
}
function fade(theClip) {
	theClip._alpha = 0;
	theClip.onEnterFrame = function() {
		if (this._alpha<=50) {
			this._alpha++;
		} else {
			delete this.onEnterFrame
		}
	};
}
init();

thank you i 'v just tried it works just two more question is there any way i can speed it up i tried increasing the frame rate but it doesn’t work and secondly is there a way of looping through the array so it does the movie clips indavidually.eg one fades up then the next and so on

cheers

Like this:


fadespeed = 9;
function init() {
	euro = new Array(b1, b2, b3, b4, b5, b6, b7, b8, e1, e2, e3, e4, e5, e6, e7, e8, e9, e10, e11, e12, e13, e14, e15, e16, e17, e18, e19, e20, e21, e22, e23, e24, e25, e26, e27, e28, e29, e30, e31, e32, e33, e34, e35);
	for (var i = 0; i<euro.length; i++) {
		euro*.id = i;
	}
	euro[0].fade();
}
MovieClip.prototype.fade = function() {
	this.go = true;
	this.onEnterFrame = function() {
		this._alpha += fadespeed;
		if (this.go) {
			if (this._alpha>50) {
				this.go = false;
				euro[this.id+1].fade();
			}
		}
		if (this._alpha>=100) {
			delete this.onEnterFrame;
		}
	};
};
init();

I wasn’t too sure about the function one, but there was a type in the onenterframe bit. you used ‘theclip’ where you should have used ‘theClip’

sorry, I should have been clearer.

still, looks like you’re all sorted now.

Hi I just tried this carn’t get it to work though it was just a cas of cutting and pasting it wasn’t it

thanks for your help

Worked here, can you send me your fla ?

See attached zip file for fla thank you

Your movieclips are already at alpha 100, it can’t increase anymore. Your movieclips should start at alpha 0. The last if statement says >=50, that should be >=100.

thank you very much i just tried it and it works great, just have to examine it to understand it know

cheers
Fugzi

Anytime :slight_smile: