AS2.0 Q
- Started
- Last post
- 10 Responses
- jysta
Basic stuff I guess but how would I apply this function to a button (btn_s_1) on frame 1?
this.activateItem = function(item) {
blah blah
}
- Mishga0
my_btn.onRelease = function() {
//do the funky thing
}
like that?
- maximillion_0
mybutton.onRelease = activateItem
- Mishga0
my_btn.onRelease = function() {
//do the funky thing
}
like that?
- fyoucher10
btn_s_1.onRelease = function():Void {
activateItem(itemArgumentValue);
};
- jysta0
yeah but i want the function do be called on that button without the onRelease
- e.g. it's selected by defaultjysta
- which "action" do you want to use?maximillion_
- onEnterFrame????jysta
- maximillion_0
you just want the function to execute without any user interaction???
- jysta0
at the mo all onRollOver, rollOut, onRelease etc is handled buy my active item function and for for loopage. I just want btn_s_1 to be active by default/
btn_s_1.onEnterFrame = function():Void {
blah blah
}
- maximillion_0
_global.activeButton = 1; // set the active button in a global var so you can change which but is active
btn_s_1.onEnterFrame = function():Void {
if (activeButton ==1 ) activateItem()
}
- fyoucher10
if the argument 'item' is supposed to be the button 'btn_s_1' then just activateItem(btn_s_1). You may have to target the func if you are nested within another mc and your code is in another timeline though (eg. _parent.activateItem(_parent.btn...
For your example, you may want to look at changing the logic around instead of using a function to determine which button is active. Maybe add a function call which checks which button is the currently active button. For example, create a function which checks a variable and then returns a boolean T or F if the button is the currently active button. Right now, it sounds like ur just adding code to a specific button at a specific time.
var activeButton:MovieClip;
isActiveButton = function(thisMovieClip:MovieClip... {
if(activeButton == thisMovieClip) return true;
}//Then in your button just call this function to check if it shoukld execute whatever code you want.
myButton.onRelease = function():Void {
if(isActiveButton(this)) doSomeCode;
}(I'm just woke up so I could totally be wrong).
- jysta0
Hey guys, thanks for the rapid response. I pasted my code here:
http://pastie.org/331951
See line:
// Set the initial state of Services button