[quoted text, click to view] > thank you for the suggestion... but that doesnt trigger a
> button release...
That's right. The button symbol (which is an instance of the Button
class) raises its own event. It's not code, but the user who triggers a
button release -- by letting go of the button. ;)
Here's how it works. Everything in ActionScript is an object. Objects
are defined by classes, which are like blue prints or recipes for objects.
So your button symbol, even though you drew the artwork yourself, is a
Button instance. You give that instance an instance name via the Properties
inspector. Just click the button to select it, then supply an instance
name. If you like, call it myButton, but you can also call it
mozartSmellyPants, jellyBean, or whatever. The instance name you choose is
your "handle" to the object created by the Button class (this holds true for
any class instance, including text fields, movie clips, and so on).
Look up the "Button class" entry in the ActionScript Language Reference
(not the Components Language Reference, which features its own Button).
You'll see everything a button can do listed under Methods, all the
characteristics it has under Properties, and all the things it can react to
under Events. So in your code, just swap out the Button class name with the
instance name you chose. If it's myButton (that is, if the instance name
field in the Properties inspector says "myButton" while you select this
button) ...
myButton.onRelease = function() {
}
.... this assigns a function to that button's onRelease event. You'll see in
the Button class under Events that onRelease is one of your available
choices. The above script would go in a keyframe, *not* on the button.
Then whatever you put inside the curly braces, {}, of that function, will be
carried out when someone clicks, then lets go, of this particular Button
instance.
Your original sample code ...
[quoted text, click to view] >> I need to call a button release from a frame script...
>>
>> I tried this
>>
>> processText = function() {
>> myButton.release();
>> }
.... makes no sense, for a number of reasons. First, you're creating a
function called processText. Actually, you're creating a variable that
points to such a function. But you're not *calling* the function from
anywhere. Second, all this function does is invoke a release() method of a
Button instance. But if you check the Button class entry, you won't see a
method called release().
In order for a function to do something, it must be called -- must be
triggered. The Button.onRelease event *occurs* when the user clicks, then
releases, a button. This is called an event. When the event occurs, you're
telling a certain function to be triggered. In my sample code above, that's
what's going on. The user causes the event to occur, and the event triggers
a function.
David
stiller (at) quip (dot) net
"Luck is the residue of good design."