Results 1 to 3 of 3

Thread: Quick Flash

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default Quick Flash

    Just thought I would take the time and post little snippets you should be using in your Flash development. I have hundreds of them that I start off each of my projects with. I will post them here as I remember them.

    Please note I JUST started using Flash CS4 and have yet to publish a thing with it. As of this writing I am still in love with Flash 8 and AS2 (over Flash 9 and AS3, although I use both). These snippets may or may not be effective in CS4. As I test CS4 further I will update the posts to let you know.

    To start, we will do 2 posts. First we will remove the Tab Key highlight. Then we will alter the context (right-click) menu.

    Edit:
    Please note that unless I specifically state otherwise, or the obvious need demands it, I will posting my snippets in AS2 format. If you use CS3 or CS4 (Flash 9 or 10) you will want the AS3 method.
    For the most part the snippets I post will work in all versions, but you don't want to mix AS levels within the same Flash project.


    (thanks Medy for reminding me to mention this)
    Last edited by BLiZZaRD; 12-07-2008 at 04:48 PM.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Remove Tab Key Highlight (Flash versions 6 and Higher)

    When coding Flash menus, or a game with several interactive buttons, you will notice that the use of the keyboard can ruin your day. Specifically the Tab key. Flash will let you write many key codes for various keys on the keyboard. Flash reserves the use of some keys though, such as Enter and Tab.

    The idea behind the reservation of the Tab key is good in principle but wrecks aesthetics. When you have buttons, clickable MCs or the like, and a user presses the Tab key, a bright yellow box will surround the buttons on your movie. That's beautiful.

    No fear though, we can disable this yellow nightmare with a simple code snippet.

    Once your movie/game/most awesomest menu ever is complete, run through your button MCs and get instance names. (or if you're smart, remember them. That's all we need.

    There are two code snippets to choose from. The MC itself, or a Parent MC.

    Code:
    MC_Name.tabEnabled = false;
    If the MCs are inside a parent MC, you control them this way:

    Code:
    MC_Container_Name.tabChildren = false;
    To look at a live example, I have a Navigation menu with a top and bottom bar. These bars house all my links/buttons. So in my .as file the first thing I have is this:

    Code:
    /**** Yellow Border Tab Removal*****/
    menuBarBottom.tabChildren = false;
    menuBarTop.tabChildren = false;
    /**** End Removal*****/
    My menu bars are named menuBarBottom and menuBarTop.

    It's that easy.
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,486
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Controlling the Context Menu (All Versions 5 and higher)

    Ever see right-click (context) menus for Flash? They contain things like "Play" and "Rewind" and a whole bunch of other crap. Game design, Secret Codes for the Super Secret Chess Club Flash Site and others would be DOOMED! If not for the alteration of the Context Menu. It's a fairly simple process, so let's get rid of the boring same old same old and make a context menu people can use!


    First we are going to open the functions and declare 2 things right away. First a non-clickable entry, and a getURL entry. This way we can make the menu have things that people can NOT click on, and items that take them to sites or pages we want them to go to. I have named mine noCLick and getMySite. You can name yours whatever you want.

    Code:
    /**** My Context Menu*****/
    function noClick() {
    }
    function getMySite() {
    	getURL("http://frozencoyotelabs.com/", "_blank");
    }
    Great! So we have functions and they don't do a damn thing! Well, first let's tell Flash to turn off that old nasty context menu and start using ours!

    Code:
    var myMenu:ContextMenu = new ContextMenu();
    myMenu.hideBuiltInItems();
    Great, we turned off the old one by declaring a new one named "myMenu" (original I know) And we have made it blank, by turning off the built in items that come with a standard Flash CM. (that's Context Menu for you non-abbreviaters)

    *note, there are items in the CM you will NEVER be allowed to remove. I know. It sucks. Deal with it. Just for your information, those items (In Flash Player 9 and higher) are: Settings, and About Adobe. In Player 10 they added "Show redraw regions" as well. Suck it up.

    Next we need to declare some new menu items. Let's add a copyright with date, and a warning:

    Code:
    var copyrightNotice:ContextMenuItem = new ContextMenuItem(" 2005 - 2008 FrozenCoyote Labs", noClick);
    var copyProtect:ContextMenuItem = new ContextMenuItem("No reproduction without permission of FCL", noClick);
    Here I have a new variable (each it's own name, copyrightNotice for one and copyProtect for the other. We tell Flash these variables are a new CM item then we define them. first up, what it says in the menu itself. then, the function it will carry over. AS you can see, both are using the noClick function. It means they are there and they are to be seen, not clicked.

    So lets add some more cool things, a line separator and something to click on:

    Code:
    copyrightNotice.separatorBefore = true;
    var mySiteLink:ContextMenuItem = new ContextMenuItem("FrozenCoyote Labs Web Site", getMySite);
    So here we have added a separator before the copyrightNotice CM item, and we declared a new CM item "mySiteLink" This is using the other function we made earlier, "getMySite"

    So we are done then! Publish, test and.. oh dear god, nothing has changed! That because we have to "push" the new items through Flash to the Flash Player. We do that with the "push" command (again, original, I know)

    Code:
    myMenu.customItems.push(mySiteLink, copyrightNotice, copyProtect);
    _root.menu = myMenu;
    So as you can see, this is the ORDER that matters, not when we declare the variables, but in the PUSH command. this is the order we will see the CM items. Make sure they are all there, and you can move them around however you like.

    Now we are done. Save, publish upload, and you will have something like the one seen right here

    Here is the whole code in one snippet:

    Code:
    /**** My Context Menu*****/
    function noClick() {
    }
    function getMySite() {
    	getURL("http://frozencoyotelabs.com", "_blank");
    }
    var myMenu:ContextMenu = new ContextMenu();
    myMenu.hideBuiltInItems();
    var copyrightNotice:ContextMenuItem = new ContextMenuItem(" 2005 - 2008 FrozenCoyote Labs", noClick);
    var copyProtect:ContextMenuItem = new ContextMenuItem("No reproduction without permission of FCL", noClick);
    copyrightNotice.separatorBefore = true;
    var mySiteLink:ContextMenuItem = new ContextMenuItem("FrozenCoyote Labs Web Site", getMySite);
    myMenu.customItems.push(mySiteLink, copyrightNotice, copyProtect);
    _root.menu = myMenu;
    /*****End My Context Menu******/
    Enjoy!
    {CWoT - Riddle } {OSTU - Psycho} {Invasion - Team}
    Follow Me on Twitter: @Negative_Chaos
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

Bookmarks

Posting Permissions

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