Calling an onRelease function WITHOUT pressing the mouse button

Long time reader, first time poster. I love Kirupa… it has been so helpful to me in the past.

Here is my question. Can I call an onRelease function without actually pressing the mouse button?

I have built an onRelease prototype function for one of my movieclips, for use when a user clicks on that movieclip. All of that works fine, BUT I would like to call the first one after the movie loads. Can I just do this:

[AS]subm0_0.onRelease();[/AS]

I did it in frame 2 of my movie (after the preloader does its thing), but it doesnt seem to be working. “subm0_0” is the name of the movie clip that has the prototype function. Again, when I click on the movieclip it works.

Thanks in advance!

I’m neither expert no guru but I’m pretty sure that the words “onRelease” refer specifically to the mouse button . . . Could you perhaps come up with a different kind of trigger to call the prototype function?

p.s. welcome, officially, to the forums!

That definitely makes sense. I could make my onRelease prototype call another function called “showText” (or whatever). Then whenever I need that showText function I can call it directly.

TANX! I will give it a rip and see how it goes.

If anyone forsees a problem with that, please feel free to let me know.

:thumb:

It should work using subm0_0.onRelease().

A dynamic onRelease handler is just like any other function, except that it is executed when Flash’s internal ASBroadcaster broadcasts the onRelease event.

Because it is also a function, it can be executed like any other function. You also said you had an onRelease handler in the prototype object of the MovieClip class - that will set every movieclip’s onRelease handler to that function by default.

I’ve provided an example file for you that demonstrates executing the onRelease handler manually. It also demonstrates the prototype method setting the default onRelease handler for every movieclip.

See, I TOLD you I was no guru!!

Thanks Master MODERATOR Voets! :stuck_out_tongue: Cheers! :beer:

Anytime :beam:

Muchos Gracias. (I apologize for any incorrect spanish).

I THOUGHT that I could call the function like any other. Obviously there is some other error in my code.

The prototype I created was not a prototype of the MovieClip class, but it is a prototype of a custom class I created which has the MovieClip as a prototype for it. I do not imagine that would matter?

[AS]
#initclip
// CONSTRUCTOR
// - - - - - - - - - - - - -
function nav() {
this.openm = false;
this.accent._visible = false;
}
nav.prototype = new MovieClip();
// METHODS
// - - - - - - - - -
//mousedown
nav.prototype.onRelease = function() {
blah, blah, blah, etc
};
Object.registerClass(“navMC”, nav);
#endinitclip
[/AS]

Thank you so much for taking the time to put together a file for me.

Well, it would be easier if you would give me your FLA file so I could have a look at it. It seems that you are initialising a custom component and class, so it would be handy if I could have a look at that component’s movieclip :slight_smile:

It is actually working now. I called the onRelease function as you mentioned I could… BUT that wasnt the problem. I was using LoadVars to dynamically load some text information, and I tried to call my onRelease before it was complete.

I moved the onRelease call into the onLoad handler… and POW! success.

Again, I thank you Voetsjoeba (and lunatic) for your help.

Glad you got it working :slight_smile:

Yep, usually when someone who knows what they are doing sees that I’ve tried to help someone who doesn’t then they come running and bail out the poor poster who was getting my attention. So I’m glad I could call Voets for you. :beam:

j/k