Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

calling a function

New Here ,
Jan 04, 2009 Jan 04, 2009
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.

Summary: When btn is pressed go play function slide()
Thanks!
TOPICS
ActionScript
473
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2009 Jan 04, 2009
quote:

Originally posted by: huminuh83

When btn is pressed go play function slide()



Do you mean that you need to call method slide(); of an instance of the class or function slide() is a function that you wrote.

You need to post more code (not too much though :-)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2009 Jan 04, 2009
sorry,


Here is my code

import caurina.transitions.*;


function slide() {
Tweener.addTween(test, {x:89, y:170, time:2});

}

button2.addEventListener(MouseEvent.CLICK, slide)


I get an error "argument count mismatch...."
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2009 Jan 04, 2009
Event listener function always expect exactly one parameter - Event.

In your case it expects MouseEvent which you don't pass (hence the error that describes the syntax error)

function slide(event:MouseEvent) {
Tweener.addTween(test, {x:89, y:170, time:2});
}
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2009 Jan 04, 2009
Thanks!

That worked perfectly, I understand now.

Just one question...do you know why, when you rollover the button (actually a movie clip symbol) why it wouldn't show the hand? Is it because it's a mc symbol and not a btn symbol??

Thanks again for your help.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2009 Jan 04, 2009
You are welcome.

Try: movie.buttonMode = true;
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2009 Jan 04, 2009
LATEST
great, thanks!!!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines