-
Calling a function
I have a very basic question. I have a custom class called caurina. I've imported the class and it works great. What i did is use that as a function called slide().
What I would like to do is make that function play when a button is pressed. I can't seem to find out how to do this anywhere. I am using as3 in CS4.
Summary: When btn is pressed go play function slide()
Thanks!
-
Flactionscrish
You need to add some event listeners. The button will call a function when it is clicked, then from there you can call the slide() function.
PHP Code:
button.addEventListener(MouseEvent.CLICK, buttonClicked)
function buttonClicked (e:MouseEvent):void {
slide();
}
ktu[k-two]
he who hesitates is lost; so i guess i'll wander intently
Are you sure this is real?
Life is Love, Love is Blind, Blind we go through Life.
Life isn't hard, dealing with your self is.
The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.
-
Thanks for your response.
This is what I tried, and got this error message.
Argument count mismatch on test2_fla::MainTimeline/slide(). Expected 0, got 1
Here is my code:
import caurina.transitions.*;
function slide() {
Tweener.addTween(test, {x:89, y:170, time:2});
}
button2.addEventListener(MouseEvent.CLICK, slide)
What's wrong with the addeventlistener im trying to use???
Thanks!
-
Flactionscrish
Whenever a function is called because of an event, the method being called (ie. slide() ) MUST have ONE argument, which must match the event type...
Change it to
PHP Code:
import caurina.transitions.*;
function slide(e:MouseEvent) { Tweener.addTween(test, {x:89, y:170, time:2} ); }
button2.addEventListener(MouseEvent.CLICK, slide)
ktu[k-two]
he who hesitates is lost; so i guess i'll wander intently
Are you sure this is real?
Life is Love, Love is Blind, Blind we go through Life.
Life isn't hard, dealing with your self is.
The concept of life in a human brain is weakening day after day. Live every day like its your last. Take the chances, and opportunities, and never let authority push you around for fun.
-
I got it working, thanks so much for you help!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|