PDA

View Full Version : functions running at the same time


stephenfinn
06-21-2005, 12:38 PM
hello, i am new to running multiple functions and i am wondering whether it is actually possible to have two functions running at the same time. when i try to call one function and then another they only seem to execute the first one. any ideas appreciated.
thx

Billystyx
06-21-2005, 12:43 PM
What are the 2 functions and how are yu calling them?

Xeef
06-21-2005, 01:58 PM
it's NOT possible to have 2 (or more) functions runing at the same time

stephenfinn
06-21-2005, 01:59 PM
//.........................................functions

function move() {
valuex = arguments[0];
valuey = arguments[1];
onEnterFrame = function () {
var xdiv = (valuex-main_mc._x)/100;
var ydiv = (valuey-main_mc._y)/100;
_root.main_mc._x += xdiv;
_root.main_mc._y += ydiv;

if ((xdiv<1 && xdiv>-1) && (ydiv<1 && ydiv>-1)) {
this.onEnterFrame = null;
_root.nav_mc.gotoAndPlay("Lclose");
}
}
}

function menumove()
{
menux = arguments[0];
onEnterFrame = function()
{
_root.nav_mc._x+=menux;
trace(menux)
}
}


_root.menu_mc.option1_mc.onRelease = function() {

move(_root.target1_mc._x, _root.target1_mc._y,);
movemenu(10);
};




the problem is that when the functions are called via the onRelease on the button only the first function is executed. i have tried changing the order of the function calls but either way only the first is executed. i am not sure if is because both are using onEnterframe loops but all i want to be able to do is move the main_mc at the same time as the menu also moves to another part of the screen.
thx again

stephen

Billystyx
06-21-2005, 02:25 PM
movemenu(10);

this is how you call

menumove()


this is your function name

they are different...

billystyx

Xeef
06-21-2005, 02:33 PM
you can have just ONE onEnterFreame on each movie
you have both on _root so the second is overwriting the first

put the hole thing in ONE onEnterFrame if you can
or create dumy clips (createempty..) and put the onEnter.. on them


_root.createEmptyMovieClip("A", 1);
_root.createEmptyMovieClip("B", 2);
function a() {
A.onEnterFrame = function() {
trace("abc");
};
}
function b() {
B.onEnterFrame = function() {
trace("123");
};
}
a();
b();

stephenfinn
06-21-2005, 10:00 PM
thanks guys, i have created an empty movie clip and put the second onEnterFrame on that and it works fine now.
cheers!

stephen