What am I doing wrong with this function?

I have a rollover function which works fine, but now I want to make it play a movieclip as well. Sounds simple, bu I just can’t make it work :*(

I think it’s something silly, but what??? I’ve tried it every which way, but haven’t stumbeled upon the answer yet - so wondered if anyone could help??

The following code works fine on a test button - just so you can see where things are…

on (rollOver) {
_level0.all.pulseMC.pulseMC1.play(“play”);
}

Here is the global function, the bits in red are my new additions:

_global.subControl = function(mc[COLOR=Red],mc2[/COLOR]){
mc.onRollOver = function() {
mc.colorTo (“0x00CC00”, 0.5, “easeOutExpo”);
[COLOR=Red]_level0.all.pulseMC.mc2.gotoAndPlay(“play”);[/COLOR]
};
mc.onRollOut = function() {
mc.colorTo (“0xCCCCCC”, 0.5, “easeOutExpo”);
}
};

Here is the call to action:
_level0.all.content.subMenu.btn2.onEnterframe =
function() {
subControl(this[COLOR=Red],pulseMC1[/COLOR])
};

mc2 represents the movieclip name - there are 3, unsurprisingly numbered 1-3. I am only testing with pulseMC1 at the moment.

I’ve written it in various ways (_root, _parent._parent, etc) but can’t get it to work. What am I doing wrong??? Can anyone help?? I’d be very grateful

Many thanks in advance!!!

if mc2 is a variable use:
_level0.all.pulseMC[mc2].gotoAndPlay(“play”);

if something is misspelled:
sorry - I’m drunk

Thanks for that! I tried playing around with brackets, +'s and the like - I’ll give this one a try :pleased:

_level0.all.pulseMC**[COLOR=Red].[/COLOR]**[mc2].gotoAndPlay(“play”);

  • I’ll try it with and extra ‘.’ in there… BTW wothca drinkin’ - think I should get some :wink:

that extra dot doesnt belong there

…so I discovered :h: Why is that then??? It didn’t work with or without the dot :frowning: Grrrr…what is it I’m missing?? The test rollover button works using that path, why not in the function??

Anyone got any other suggestions??

you may have more chance of a solution if you upload the fla

I tried to upload them, but the fla’s are too big. It’s probably just as well because they’re probably a bit complicated to disect and all these function happen in a small area, so it’s not always easy to see what’s going on. Just can’t understand why this isn’t working, it should be relatively simple…?

I added ‘trace(_level0.all.pulseMC.mc2);’ to the function, but it came back as ‘undefined’, even though it’s in there…

on the timeline of the movie you are trying to trace put
trace(this)

Did that, got this:

_level0.all.pulseMC.pulseMC1

I think I’ve got the path to it correct because my test rollover button works using:

on (rollOver) {
_level0.all.pulseMC.pulseMC1.play(“play”);
}

Even when I put “_level0.all.pulseMC.pulseMC1.play(“play”);” into the function it works. But I need to have pulseMC1 change to …2 and …3 - hence trying to add it as a variable. But it’s the variable that’s coming up as undefined, so I guess I must have done something wrong there??

This is what I have:

Function
_global.subControl = function(mc,mc2){
mc.onRollOver = function() {
mc.colorTo (“0x00CC00”, 0.5, “easeOutExpo”);
_root.all.pulseMC[mc2].play(“play”);
trace(_level0.all.pulseMC.mc2);
};

Call
_level0.all.content.subMenu.btn2.onEnterframe =
function() {
subControl(this,pulseMC1)
};

Much head scratching…

try
_global.subControl = function(mc, mc2) {

mc.onRollOver = function() {
	mc.colorTo("0x00CC00", 0.5, "easeOutExpo");
	_level0.all.pulseMC[mc2].gotoAndPlay("play");
};
mc.onRollOut = function() {
	mc.colorTo("0xCCCCCC", 0.5, "easeOutExpo");
};

};
_level0.all.content.subMenu.btn2.onEnterframe =
function() {
subControl(this,“pulseMC1”)
};

Grrr, blast and double poop!!!

Yours is exactly the same as mine, except for the “” and _root/_level0, which is what I had before and doesn’t make any difference anyway… That is SO annoying, I tried the code with quote marks ages ago, because one of my other functions works with them. But it didn’t work - I think that was before I’d got [] right… But as nobody suggested the variable should be in quotes, I figured I’d got it wrong and stopped trying it with them…that was a mistake…

I can’t believe I didn’t get that! I was so close :frowning: Anyway, it works now…thank you so much for your help. I’d have been going around in circles (as I was before). I don’t know if you recall or ever had a ‘trial & error’ period?? I’m still at that stage, but trying all the same…

Cheers!!

Thanks again!!!

you are welcome.

:slight_smile:

Don’t drink and script.