On 15/12/2010 23:53, spyder spyders wrote:
HELLO FlashCoders!
I am trying to write a ToggleButton Class. I can get it to work as a
document class and as as3 on timeline. But how to I use it as a symbol class?
Everywhere you have "toggleButton" replace it with "this" or remove it
altogether.
In the linkage for the MovieClip that represents the toggle, put this class.
Paul
Thx!
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class ToggleButton extends MovieClip
{
public var toggleButton:MovieClip;
public function ToggleButton()
{
// constructor code
//event listeners
toggleButton.addEventListener(MouseEvent.MOUSE_OVER,
rolloverToggle);
toggleButton.addEventListener(MouseEvent.MOUSE_OUT,
rolloutToggle);
toggleButton.addEventListener(MouseEvent.CLICK,
toggleClick);
toggleButton.buttonState = "off";
// Respond to mouse events
function rolloverToggle(event:MouseEvent)
{
toggleButton.gotoAndStop(toggleButton.buttonState+"
over");
} //rollover f(x)
function rolloutToggle(event:MouseEvent)
{
toggleButton.gotoAndStop(toggleButton.buttonState);
} //rollout f(x)
function toggleClick(event:MouseEvent)
{
if (toggleButton.buttonState == "on")
{
toggleButton.buttonState = "off";
} //if
else
{
toggleButton.buttonState = "on";
} //else
toggleButton.gotoAndStop(toggleButton.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