PDA

View Full Version : Overriding an assigned onPress function (getting back "default-mode" for onPress)


corinne@flash
06-29-2005, 02:31 PM
Hi!

I have a movieclip that is assigned a function for the onPress event, as follows:

mc.onPress = function ()
{
//do this when mc is pressed
};

Now, the movieclip is a textfield (actually a text object created with a textObject Class) and therefore it can contain links that are supposed to be clickable. The problem is that I want to use the same textfield instance/textobject in two so called "modes".

First the movieclip needs to respond to the above onPress function, and then just as a normal textfield would. But, it seems that once I have assigned this function to the mc's onPress event I can't get rid of it, or rather get back the "default" onPress response (which in my case would be to respond to a link and open a new browser window).

How do I "default" the onPress event or override it?
Lots of thanks

acolyte
06-29-2005, 02:44 PM
onClipEvent(load){
if(_global.readHypertext eq"1"){
}else{
mc.onPress = function ()
{
//do this when mc is pressed
};
}
}

so if the _global variable "readHypertext" is 0 the onPress is disengaged

of cource you got to set _global.readHypertext = _global.readHypertext ; and you need to change this value

why not setting up a test file where hyperlinks are includet and parsing this testfile in your textframe would be much easier to test :)

corinne@flash
06-30-2005, 06:58 AM
Thanks acolyte,
unfortunately this won't work for me. I assume "readHypertext" is a variable that I have to define and set in the movie?

The thing is that I'm using the text object in two modes:
In Mode 1 the movieclip that holds the textfield is supposed to respond to the defined onPress event (my function).
In Mode 2 the same movieclip/textfield is supposed to respond the default onPress event, that is, if there is a link (which I don't know, since its user input) open a browser window.
I have to be able to shift mode at any time, thus invoking the default onPress or my defined onPress function.

For example, after having invoked the mc.onPress = function (){//do this} I can set the mc.onPress to null, or delete mc.onPress. The problem is that then the mc won't respond to _any_ onPress event, not even a link in the textfield that resides in the clip.

Anyone has a solution?
Thanks