View comments | RSS feed

MovieClip.onPress

Availability

Flash Player 6.

Usage

my_mc.onPress = function() {
   // your statements here
}

Parameters

None.

Returns

Nothing.

Description

Event handler; invoked when the user clicks the mouse while the pointer is over a movie clip. You must define a function that executes when the event handler is invoked. You can define the function on the Timeline or in a class file that extends the MovieClip class or is linked to a symbol in the library. For more information, see "Assigning a class to a movie clip symbol" in Using ActionScript in Flash.

Example

The following example defines a function for the onPress method that sends a trace() action to the Output panel:

my_mc.onPress = function () {
   trace ("onPress called");
};

Comments


wl gardner said on May 7, 2005 at 11:14 AM :
This works fine for me when i dynamically create a movieClip whose contentPath is http://www.someserver.com/something.JPG but when the contentPath is a SWF file, it doesn't make the movieClip clickable! grrr. I call the onPress event dynamically within the onLoadComplete event handler... I'm going nuts?!
GraphicDesignerMI said on May 12, 2005 at 12:35 PM :
Nope. I have the same issue, and I'm wondering if I'm doing something wrong.
If I am, there's no real documentation that says so.
johnfmorton said on Aug 2, 2005 at 5:49 PM :
How do you remove an onPress event without removing the movieclip
from the stage?
Antonio Estevez said on Sep 16, 2005 at 8:34 AM :
How do you remove an onPress event without removing the movieclip
from the stage?


ANS: just write a new onPress event thats blank.
Antonio Estevez said on Sep 16, 2005 at 8:37 AM :
How do you write a dynamic onPress event ? I hjave 8 movie clips that
all need the same eventHandlers. Can i write a loop that will create an
event handler for each MC?
bobpf said on Sep 16, 2005 at 2:30 PM :
Take a look at using the Delegate class. This is not tested but I would try something like:

onPress = Delegate.create(MyHandlerClass,MyHandlerClassFunction);
or
onPress = Delegate.create(root,rootFunctionHere);

Sorry I dont have time to test.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001538.html