A Flash Developer Resource Site

Page 1 of 3 123 LastLast
Results 1 to 20 of 47

Thread: Drop Down Menu Coding

  1. #1
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60

    Drop Down Menu Coding

    Ok Im just a little confused on what to do. In my menu I have 2 drop downs. each one is a separate Movie Clip and inside that Movie Clip they have other buttons that are separate Movie Clip. I have a class set to the buttons for a rollover action but it isn't working. How do I set actions to Movie Clips that are in other Movie Clip? Like how would I add links to them?

    Here is a copy of my AS3 Class and a copy of the drop down.

    Actionscript Code:
    package {
      import flash.events.MouseEvent;
      import flash.display.MovieClip;

      public class DropClass extends MovieClip {
        public function DropClass() {
           addEventListener(MouseEvent.MOUSE_OVER, over);
           addEventListener(MouseEvent.MOUSE_OUT, out);
        }

        private function over(event:MouseEvent):void {
            gotoAndPlay(2);
        }
       
        private function out(event:MouseEvent):void {
            gotoAndPlay(7);
        }
      }
    }

    Thanks Chris
    Attached Files Attached Files

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    TheFlashMaster
    Join Date
    Aug 2009
    Posts
    28
    here is the code

    Code:
    package
    {
    	import flash.events.MouseEvent;
    	import flash.display.MovieClip;
    	import flash.text.TextField;
    	public class MouseExample extends MovieClip
    	{
    		public function MouseExample()
    		{
    			this.parent.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
    			this.parent.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    		}
    		private function mouseDownHandler(event:MouseEvent):void
    		{
    			trace("Stage mousedown");
    			var newBut:MyButton = new MyButton (mouseX, mouseY);
    			this.addChild (newBut);
    			var myText:TextField = new TextField();
    			myText.text = "Press the button.";
    			this.addChild(myText);
    		}
    		private function mouseUpHandler(event:String):void
    		{
    			trace("Stage mouseup");
    		}
    	}
    }

  4. #4
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Could you please explain how it works too. I would like to know for future references.

    Thankyou
    Chris

  5. #5
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Could someone explain how this coding works?

  6. #6
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    PHP Code:
    package
    {
        
    import flash.events.MouseEvent;
        
    import flash.display.MovieClip;
        
    import flash.text.TextField;
        public class 
    MouseExample extends MovieClip
        
    {
            public function 
    MouseExample()
            {
                
    this.parent.addEventListener(MouseEvent.MOUSE_DOWNmouseDownHandler);
                
    this.parent.addEventListener(MouseEvent.MOUSE_UPmouseUpHandler);
    //this is saying when you click on stage run mouseDownHandler function
            
    }
            private function 
    mouseDownHandler(event:MouseEvent):void
            
    {
                
    trace("Stage mousedown");
                
    //this says create  a button  at mouse positionX and mouse positionY
                                               
    var newBut:MyButton = new MyButton (mouseXmouseY);
                                               
                
    this.addChild (newBut);
                                              
    //add button to display list.
                
    var myText:TextField = new TextField();
                                              
    //create a  new text field
                
    myText.text "Press the button.";
                                              
    //write the text to the text field
                
    this.addChild(myText);
                                              
    //add textfield to display list
            
    }
            private function 
    mouseUpHandler(event:String):void
            
    {
                
    trace("Stage mouseup");
            }
        }

    ~calmchess~

  7. #7
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    How can I get this to work with roll over and linking it to a web page? I figured out how to add text to it through coding I just don't know how to add the roll over and link.

  8. #8
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    probably MOUSE_OVER,MOUSE_OUT,GETURL/urlLoader........do you have the as3 livedocs saved to your computer?
    ~calmchess~

  9. #9
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    I don't need to make a button though. I have a button I need it to play.

  10. #10
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    MOUSE_OVER,MOUSE_OUT will work for moviclips too i'd make movie clips with the alpha set to 0 and when moused over I'd have other movie clips either tweening or moving on Y axis to create drop down effect
    ~calmchess~

  11. #11
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    I used this code

    Actionscript Code:
    package
    {
        import flash.events.MouseEvent;
        import flash.display.MovieClip;
        public class DropClass extends MovieClip
        {
            public function DropClass()
            {
                this.parent.addEventListener(MouseEvent.MOUSE_OVER, overHandler);
                this.parent.addEventListener(MouseEvent.MOUSE_OUT, outHandler);
            }
            private function overHandler(event:MouseEvent):void
            {
                gotoAndPlay(2);
            }
            private function outHandler(event:MouseEvent):void
            {
                gotoAndPlay(7);
            }
        }
    }

    and I got this error

    TypeError: Error #2007: Parameter child must be non-null.
    at flash.display:: DisplayObjectContainer/setChildIndex()
    at menu_a_fla::MainTimeline/childOver()
    Last edited by Ultrakd; 05-29-2010 at 11:18 AM.

  12. #12
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    you need a button refrence from the doucument class something like

    btn_Or_Clip_InstanceName.addEventListener(MouseEve nt.MOUSE_OVER, overHandler);
    ~calmchess~

  13. #13
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    If I add an instance name it says "1120: Access of undefined property ". And if I add the instance name of a button how can I get it to work for all the occurrences of that movie clip?

  14. #14
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    are you in your main document class the one that connects to the .fla?
    ~calmchess~

  15. #15
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    I have 4 classes...One for each of the ends, one for the other buttons, and one for the drop down buttons. Here is my entire flash file, I really appreciate all your help...
    Attached Files Attached Files

  16. #16
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    you will have to save the .fla in cs3 formatte
    ~calmchess~

  17. #17
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Here you go.....
    Attached Files Attached Files

  18. #18
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    i still couldn't open it i'm going to create my own which .as file is your document class?
    ~calmchess~

  19. #19
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    The classes are only for the button rollovers. The Action Scripting is in the flash file. It should work now..
    Attached Files Attached Files

  20. #20
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    still didn't work just post the actionscript for the .fla
    ~calmchess~

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