PDA

View Full Version : Function declaration on global level?


divarch
11-19-2003, 09:01 PM
Hi,
I have several clips which I am attaching to the _root, but of all the AS writing my hands hurt, 'cause I am adding their parameters individually.
I thought the following function should work:

function moveClipTo (clip, x, y, alpha) {
clip._x = x;
clip._y = y;
clip._alpha=alpha;
}


and then assign it to each clip, of course, instead of rewriting, like:
onClipEvent (enterFrame){
moveClipTo(clip1,120,150,70)
};

The problem is I get an output error message when declaring a function "Function declaration not permitted here"
I even tried assigning the declaration o a button, _root timeline, and clips, and still nothing.

How can I make global function declaration, which can be called from child clips also?

Thanks!

sho shinjo
11-21-2003, 04:52 PM
Originally posted by divarch
onClipEvent (enterFrame){
moveClipTo(clip1,120,150,70)
};


i have no idea what you wish to do with this because the function
is not telling it to do anything, you are just calling a function. and your variables do not match up. I did fix the code for you so you
will not get an error message here it is:


onClipEvent (enterFrame){
moveClipTo(clip1,120,150,70);
}


*cheers*


BUT I think you may want to try this:


function mclip () {
_root.clip._x = 120;
_root.clip._y = 150;
_root.clip._alpha=70;
}


*button*
on(press){
mclip();
}