Link to home
Start Free TrialLog in
Avatar of roscoeh23
roscoeh23

asked on

calling a class

Hi

I have created a basic class that says hello when the runs but I want to know how to call the sayGoodBye() function with a mouse click on a button or movieclip.
package {
import flash.display.*;
import flash.events.*;
import fl.transitions.*;
import flash.display.MovieClip;
 
 
public class Greetings extends MovieClip
 
{
 
 
 
public function Greetings()
{
trace('hello');
 
 
}
 
 
 
 
public function sayGoodBye()
{
trace('see ya');
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of najh
najh
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of roscoeh23
roscoeh23

ASKER

sweet!
Avatar of Rob
Not sure if you just didnt' post all of your code but you're missing a coupld of end parenthesis }  but assuming you have these then the following should do what ytou want:
 
package {
import flash.display.*;
import flash.events.*;
import fl.transitions.*;
import flash.display.MovieClip;
 
 
public class Greetings extends MovieClip
 
{
 
public function Greetings()
{
trace('hello');
}
 
public function sayGoodBye()
{
trace('see ya');
}
 
}
 
}
 
// have a symbol in the library that references the greetings class
 
import Greetings;
 
// this creates an instance of the Greeting class and you should see 'hello' in the output panel
this.attachMovie("greeting", "gt1", this.getNextHighestDepth());
 
// assume you have another button called 'btn'
// when someone clicks this button you should see 'see ya' in the output panel
this.btn.onRelease = function() {
    _root.gt1.sayGoodBye();
}

Open in new window

sorry still had the question open :)