On 16/12/2010 07:38, spyder spyders wrote:
Thank You Sooooooooooooooooooooo Much! :D I have been researching for over a
month!! I am guessing that the 'this' is pointing to the symbol or _mc I
attach the class to?
I ended up doing away with all of the "this" because I was receiving an error message saying
"gotoAndStop is not a function." Also I needed to declare the variable "buttonState"
Using "this" shouldn't cause you a problem in a class definition. If you
don't use it it generally means the same thing as "this."!
"gotoAndStop is not a function." I would associate with a class that did not
extend MovieClip.
Spend some time on some OO tutorials to try and get the main concepts
then you'll soon see how it all fits together.
Here it is!!! My first Class!
Excellent.
Thank you!
You're welcome.
###################################
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class ToggleButton extends MovieClip
{
//public var togglButton:MovieClip;
public var buttonState = MovieClip;
public function ToggleButton()
{
// constructor code
//event listeners
addEventListener(MouseEvent.MOUSE_OVER, rolloverToggle);
addEventListener(MouseEvent.MOUSE_OUT, rolloutToggle);
addEventListener(MouseEvent.CLICK, toggleClick);
buttonState = "off";
// Respond to mouse events
function rolloverToggle(event:MouseEvent)
{
gotoAndStop(buttonState+" over");
} //rollover f(x)
function rolloutToggle(event:MouseEvent)
{
gotoAndStop(buttonState);
} //rollout f(x)
function toggleClick(event:MouseEvent)
{
if (buttonState == "on")
{
buttonState = "off";
} //if
else
{
buttonState = "on";
} //else
gotoAndStop(buttonState+" over");
} //toggle click f(x)
} //constructor f(x)
} //class
} //package
#################################
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders