So I've been having this problem for quite a while and it would really be nice to figure it out. I write a bunch of code for something and instead of copy and pasting the code each time I need it I'd like to turn it into a function. The problem is that I don't write the function on the same action layer that I call the function, to me that is useless. So I pasted the function onto the root timeline and am calling the function from a few mc's deep. Here's the function:
I'm pretty sure that it has something to do with all the "this" keywords I have. I'm curious, does the called function call all objects from where the actual function is located? In my case that would be _root. So would all paths need to originate from _root or where I call the function? To me it seems that they should originate from the called function, as I have it above. But I've tried it the other way too, and nothing. The only way this works is if I paste the above function on the same action layer I call the function, which, as I stated above is absolutely useless in what I'm building.Code:function slideOut(totBtns, xmouse, ymouse) { over.onRollOver = function() {}; for(var i=0; i<=totBtns; i++) { var btn = this.box["btn"+i]; btn.onRollOver = function() { this.gotoAndPlay("over"); } btn.onRollOut = function() { this.gotoAndPlay("overOut"); } } this.onEnterFrame = function() { if(_xmouse < 0 || _xmouse > xmouse || _ymouse < 0 || _ymouse > ymouse) { gotoAndPlay("overOut"); this.onEnterFrame = null; } } }
And here is the called function code:
I've heard that if a function resides on the root timeline then I have to put in the _root keyword before the function.Code:slideOut(3, 97, 99);
But that didn't work either...Code:_root.slideOut(3, 97, 99);
Anybody have any ideas?? I'm about 30 minutes away from throwing my computer out the window so it would really appreciate the help. Before it dies!
Jeff





Bookmarks