# What am I doing wrong with this function?

**URL:** https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738
**Category:** Uncategorized
**Created:** [July 29, 2004, 9:10pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738 "2004-07-29T21:10:47Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 29, 2004, 9:10pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/1 "2004-07-29T21:10:47Z")

</div>

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!!!

---

<div class="post-metadata">

### Author: ![McGiver](https://avatars.discourse-cdn.com/v4/letter/m/6de8d8/32.png) [@McGiver](https://forum.kirupa.com/u/McGiver)
#### Post date: [July 30, 2004, 1:26am UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/2 "2004-07-30T01:26:30Z")

</div>

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

if something is misspelled:  
sorry - I’m drunk

---

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 30, 2004, 11:31am UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/3 "2004-07-30T11:31:05Z")

</div>

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 😉

---

<div class="post-metadata">

### Author: ![senocular](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/senocular/32/7217_2.png) [@senocular](https://forum.kirupa.com/u/senocular)
#### Post date: [July 30, 2004, 11:41am UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/4 "2004-07-30T11:41:13Z")

</div>

that extra dot doesnt belong there

---

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 30, 2004, 6:43pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/5 "2004-07-30T18:43:46Z")

</div>

> [@senocular](#):
>
> that extra dot doesnt belong there

…so I discovered :h: Why is that then??? It didn’t work with or without the dot ☹ 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??

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [July 30, 2004, 6:46pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/6 "2004-07-30T18:46:26Z")

</div>

> [@justme](#):
>
> …so I discovered :h: Why is that then??? It didn’t work with or without the dot ☹ 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

---

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 30, 2004, 7:48pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/7 "2004-07-30T19:48:44Z")

</div>

> [@stringy](#):
>
> 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…

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [July 30, 2004, 7:51pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/8 "2004-07-30T19:51:31Z")

</div>

> [@justme](#):
>
> 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)

---

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 30, 2004, 8:05pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/9 "2004-07-30T20:05:25Z")

</div>

> [@stringy](#):
>
> 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…

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [July 30, 2004, 8:52pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/10 "2004-07-30T20:52:00Z")

</div>

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”)  
};

---

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 30, 2004, 10:10pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/11 "2004-07-30T22:10:45Z")

</div>

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 ☹ 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!!!

---

<div class="post-metadata">

### Author: ![stringy](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@stringy](https://forum.kirupa.com/u/stringy)
#### Post date: [July 30, 2004, 10:19pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/12 "2004-07-30T22:19:09Z")

</div>

> [@justme](#):
>
> 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 ☹ 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.

---

<div class="post-metadata">

### Author: ![justme](https://avatars.discourse-cdn.com/v4/letter/j/f0a364/32.png) [@justme](https://forum.kirupa.com/u/justme)
#### Post date: [July 30, 2004, 10:29pm UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/13 "2004-07-30T22:29:18Z")

</div>

🙂

---

<div class="post-metadata">

### Author: ![attuned](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/attuned/32/648_2.png) [@attuned](https://forum.kirupa.com/u/attuned)
#### Post date: [July 31, 2004, 6:51am UTC](https://forum.kirupa.com/t/what-am-i-doing-wrong-with-this-function/117738/14 "2004-07-31T06:51:48Z")

</div>

> [@McGiver](#):
>
> if mc2 is a variable use:  
> \_level0.all.pulseMC[mc2].gotoAndPlay(“play”);
> 
> if something is misspelled:  
> sorry - I’m drunk

Don’t drink and script.
