A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Variable/Targeting Troubles

  1. #1
    Senior Member
    Join Date
    Jun 2007

    Variable/Targeting Troubles

    I have three buttons on the stage (buttonOne, buttonTwo and buttonThree), three animations (animationOne, animationTwo and AnimationThree) and the following code in frame 1 of the main timeline:

    var activeButton:MovieClip = null; ///
    buttonOne.addEventListener (MouseEvent.MOUSE_OVER, overHandler);
    buttonOne.addEventListener (MouseEvent.CLICK, clickHandler);
    buttonTwo.addEventListener (MouseEvent.MOUSE_OVER, overHandler);
    buttonTwo.addEventListener (MouseEvent.CLICK, clickHandler);
    buttonThree.addEventListener (MouseEvent.MOUSE_OVER, overHandler);
    buttonThree.addEventListener (MouseEvent.CLICK, clickHandler);
    function overHandler(event:MouseEvent) {
    	var target:String = event.currentTarget.name.substr (6);
    	var targetAnimation:MovieClip = MovieClip (getChildByName("animation" + target));
    	targetAnimation.gotoAndPlay ("fadeIn");
    function clickHandler(event:MouseEvent) {
    	if (activeButton != null) {
    		activeButton.mouseEnabled = true; ///
    	var target:String = event.currentTarget.name.substr (6);
    	var targetAnimation:MovieClip = MovieClip (getChildByName("animation" + target));
    	targetAnimation.gotoAndStop ("active");
    	var targetButton:Object = Object (getChildByName("button" + target));
    	targetButton.mouseEnabled = false;
    	activeButton = targetButton;///
    I'm having issues with changing the info held by the variable activeButton. The code utilizing the variable has been marked by "///". Trying to make the jump to AS3 so any input on all aspects of the code would be appreciated.

    I think my issue is in the output provided by event.currentTarget and being used to AS2 to easily compile information held by a variable...but I was probably sliding on non-perfect code...because is I delete ":MovieClip" after where the variable "activeButton" is initiated the code works, but I read it's bad practice to do this.
    Last edited by moose-o; 05-03-2008 at 07:16 PM.

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    press the picture...
    What is activebutton supposed to be?
    - The right of the People to create Flash movies shall not be infringed. -
    | www.Flashscript.biz | Flashscript Biz Classes/Components |

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center