A Flash Developer Resource Site

Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 47

Thread: Drop Down Menu Coding

  1. #21
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Here you go....Does everything else work for you?

    Actionscript Code:
    mcHome.mcText1.mcText.text = "Home";
    mcAbout.mcText1.mcText.text = "About";
    mcGallery.mcText1.mcText.text = "Gallery";
    mcAvailable.mcText1.mcText.text = "Available";
        mcDrop1.mcLeos.mcText1.mcText.text = "Leopard Gecko";
        mcDrop1.mcBalls.mcText1.mcText.text = "Ball Pythons";
    mcOther.mcText1.mcText.text = "Other Stuff";
        mcDrop2.mcComments.mcText1.mcText.text = "Testimonials";
        mcDrop2.mcNews.mcText1.mcText.text = "News & Updates";
        mcDrop2.mcWebDesign.mcText1.mcText.text = "Web Design";
    mcContact.mcText1.mcText.text = "Contact Us";
    mcTerms.mcText1.mcText.text = "Terms";
    mcLinks.mcText1.mcText.text = "Links";
    /**/

    mcDrop1.addEventListener(MouseEvent.MOUSE_OVER, aOver);
    mcDrop1.addEventListener(MouseEvent.MOUSE_OUT, aOut);

    function aOver(event:MouseEvent):void{
        mcDrop1.gotoAndPlay (2);
    }
    function aOut(event:MouseEvent):void{
        mcDrop1.gotoAndPlay (7);
    }

    mcDrop2.addEventListener(MouseEvent.MOUSE_OVER, sOver);
    mcDrop2.addEventListener(MouseEvent.MOUSE_OUT, sOut);

    function sOver(event:MouseEvent):void{
        mcDrop2.gotoAndPlay (2);
    }
    function sOut(event:MouseEvent):void{
        mcDrop2.gotoAndPlay (7);
    }

    /**/
    mcHome.addEventListener(MouseEvent.CLICK, hClick);

    function hClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com"), "_parent");
    }
    mcAbout.addEventListener(MouseEvent.CLICK, aClick);

    function aClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/about.html"), "_parent");
    }
    mcGallery.addEventListener(MouseEvent.CLICK, gClick);

    function gClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/gallery.html"), "_parent");
    }
    mcAvailable.addEventListener(MouseEvent.CLICK, avClick);

    function avClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/gallery.html"), "_parent");
    }
    mcOther.addEventListener(MouseEvent.CLICK, oClick);

    function oClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/gallery.html"), "_parent");
    }

    mcContact.addEventListener(MouseEvent.CLICK, cClick);

    function cClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/contact.html"), "_parent");
    }
    mcTerms.addEventListener(MouseEvent.CLICK, tClick);

    function tClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/terms.html"), "_parent");
    }
    mcLinks.addEventListener(MouseEvent.CLICK, lClick);

    function lClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/links.html"), "_parent");
    }

  2. #22
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    first off have you ever successfully used an external AS class? because you don't have a document class and i can't find any place where you are importing a class and calling it..............do i need to go over the basic structure of an OOP program?
    ~calmchess~

  3. #23
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    This is my first time using a AS Class. In my library I had the classes linked to the different movie clips. I a pretty new to flash and Ive been trying to learn AS3 but I haven't done many things in flash. Going over the basics might be helpful.

    Again thank you for you patience and help.

  4. #24
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    here is structure .....*.fla>>>>>>>main/doucmentclass main.as>>>>>>>>>other as files are always called from main.as this gives us a central point to manipulate stage objects and connect classes togeather here we can send variables to other classes,call classes set properties to objects on stage tell the stage that methoss from the classes have used addChild and need to be added to the stage do numerous other things(main)........our fla file has zero code in it and its just used for stage Objects such as background buttons and images it may even be void of all objects and code if you choose to build objects using actionscript only.............I'll build you a main class to get you started after that its up to you.
    ~calmchess~

  5. #25
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    here is the demo file it needs stuff added to stage and refences to objects specified in the extrenal as files just remember when you want to access something on stage use main1.instance_name such as main1.btn0.addEventListener(ButtonEvent.CLICK,butt onhandler,false,0,true);
    Attached Files Attached Files
    ~calmchess~

  6. #26
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Im still so confused..........

  7. #27
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    well you will have to study the files i sent untill you understand
    ~calmchess~

  8. #28
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Im meaning, what was wrong with what I had? (Im not saying anything wasn't) It was working and I had the classes linked to the Movie Clips in the library. I just wasn't sure how to get the movie clips in the drop downs to play when rolled over.

  9. #29
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    i have only 2 words for it dirty and non flexable
    ~calmchess~

  10. #30
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    I didn't need it to be flexible, it was only for this menu bar.

  11. #31
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    what i mean by dirty/non-flexible is a coder using bad coding practices and creating a coding environment that will have horrible future problems. Code the way i showed you and you will have a robust application with far less limitations for your imagination
    ~calmchess~

  12. #32
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    What was I doing that was bad coding practices? I'm not trying to be stupid I'm just trying to learn from my mistakes. Why do I need to have my main AS in a as file if I can put it in the first frame? Why do I nee to import the other classes for when I have them linked to the buttons using the class? Are you saying I should have all my AS in classes? What are the class variables for in main.as? Your notes in the as files just confuse me even more. I know you probably think I'm really dumb but Ive never learned well by reading I'm a person that learns faster by watching.

  13. #33
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    the main.as file is known as the document class everything on the stage is available from this class and you can pass variables/instance names between the classes and classes can have access to the stage by tying it to the buttons you only have 1 instance available instead of the entire stage......the class variables in main.as make refrences to your classes avaiable in all functions in the main.as/document class.....if you want to call a function that resides in a class from another class you put classvariablename.thefunc(); and it will call it from main.....or you can call it from a class other than main with
    main1.classvariablename.thefunc(); I hope this demonstrates the flexibility that main class creates.
    ~calmchess~

  14. #34
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    So how would I get all the buttons to use the same class and roll over function? The AS in main.as, do I put that in the flash file? Importing it to main.as makes it available for the rest of the stage correct... Could you explain more of what the comments you put in the AS means? If coding this way is better I have to have more explanations, I dont understand any of it, yet at least. I want to learn how to code AS right the first time so I wont have to go back and fix my mistakes. I just am confused......

  15. #35
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    all buttons are available to main.as if you want to access a button from a class file you have to have refrence to main.as hence you pass "this" to the class.
    ask another question i'll give you bits and pieaces.
    ~calmchess~

  16. #36
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    The AS in main.as, do I put that in the flash file? Importing other classes to the main.as makes it available for the rest of the stage correct...

  17. #37
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    you are starting to understand.....but main.as is external from .fla it is connected to the fla by the document class setting and yes by importing other classes into main.as makes it available to the stage its a two way connection the stage can access stuff in the class but for the class to access stuff on the stage you need a refrence to the stage which is where
    PHP Code:
    this and main0 variable comes into play 
    you have a handle on your thinking though we are getting there.
    ~calmchess~

  18. #38
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    Why does main.as have to be in a separate document? Why not put it into the fla file?

  19. #39
    Senior Member calmchess's Avatar
    Join Date
    Sep 2006
    Location
    Earth
    Posts
    2,588
    you can't have any code in the fla if you use a document class......the reason it is like this is a question for the adboe developers the best i can do is say thats how it is......I mean we are talking OOP programming here.
    ~calmchess~

  20. #40
    Member
    Join Date
    Sep 2009
    Location
    Florida
    Posts
    60
    I mean you put all this

    Actionscript Code:
    mcHome.mcText1.mcText.text = "Home";
    mcAbout.mcText1.mcText.text = "About";
    mcGallery.mcText1.mcText.text = "Gallery";
    mcAvailable.mcText1.mcText.text = "Available";
        mcDrop1.mcLeos.mcText1.mcText.text = "Leopard Gecko";
        mcDrop1.mcBalls.mcText1.mcText.text = "Ball Pythons";
    mcOther.mcText1.mcText.text = "Other Stuff";
        mcDrop2.mcComments.mcText1.mcText.text = "Testimonials";
        mcDrop2.mcNews.mcText1.mcText.text = "News & Updates";
        mcDrop2.mcWebDesign.mcText1.mcText.text = "Web Design";
    mcContact.mcText1.mcText.text = "Contact Us";
    mcTerms.mcText1.mcText.text = "Terms";
    mcLinks.mcText1.mcText.text = "Links";
    /**/

    mcDrop1.addEventListener(MouseEvent.MOUSE_OVER, aOver);
    mcDrop1.addEventListener(MouseEvent.MOUSE_OUT, aOut);

    function aOver(event:MouseEvent):void{
        mcDrop1.gotoAndPlay (2);
    }
    function aOut(event:MouseEvent):void{
        mcDrop1.gotoAndPlay (7);
    }

    mcDrop2.addEventListener(MouseEvent.MOUSE_OVER, sOver);
    mcDrop2.addEventListener(MouseEvent.MOUSE_OUT, sOut);

    function sOver(event:MouseEvent):void{
        mcDrop2.gotoAndPlay (2);
    }
    function sOut(event:MouseEvent):void{
        mcDrop2.gotoAndPlay (7);
    }

    /**/
    mcHome.addEventListener(MouseEvent.CLICK, hClick);

    function hClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com"), "_parent");
    }
    mcAbout.addEventListener(MouseEvent.CLICK, aClick);

    function aClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/about.html"), "_parent");
    }
    mcGallery.addEventListener(MouseEvent.CLICK, gClick);

    function gClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/gallery.html"), "_parent");
    }
    mcAvailable.addEventListener(MouseEvent.CLICK, avClick);

    function avClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/gallery.html"), "_parent");
    }
    mcOther.addEventListener(MouseEvent.CLICK, oClick);

    function oClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/gallery.html"), "_parent");
    }

    mcContact.addEventListener(MouseEvent.CLICK, cClick);

    function cClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/contact.html"), "_parent");
    }
    mcTerms.addEventListener(MouseEvent.CLICK, tClick);

    function tClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/terms.html"), "_parent");
    }
    mcLinks.addEventListener(MouseEvent.CLICK, lClick);

    function lClick(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://www.geckos.crackedmarble.com/HTML/links.html"), "_parent");
    }

    in the document class...Why cant I leave that in the fla file?

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