A Combo of links

1 Star2 Stars3 Stars4 Stars5 Stars (5 votes, average: 4.60 out of 5)
Loading ... Loading ...

The Combo_silver component and the getURL() script command can be used together to provide a convenient and space effective way of presenting a list of links to other websites.

The example above uses the Combo_silver component (Components | Controls | Lists | Combo_silver).

The following modifications were made to the default parameters of the Combo_silver component:
Initial Value: 6
List Values: SWiSHzone.com;Blog;Forums;Support;Google;Wikipedia;Take me to…
Editable: false

When the component is initially loaded or when a different item is selected an Events function is called. This allows the user to define via script what actions are to occur in response to an event. Many components use an events function to signal that an event has occurred.

The name of the function is defined by the parameter Event Notification | Event Function. The default function name is “Events”.

The script that needs to be added to the main movie is shown below:

function Events(n,v) {
    switch(v) {
        case "SWiSHzone.com":
            getURL("http://www.swishzone.com", "_blank");
            break;
        case "Blog":
            getURL("http://blog.swishzone.com", "_blank");
            break;
        case "Forums":
            getURL("http://forums.swishzone.com", "_blank");
            break;
        case "Support":
            getURL("http://www.swishzone.com/index.php?area=support", "_blank");
            break;
        case "Google":
            getURL("http://www.google.com", "_blank");
            break;
        case "Wikipedia":
            getURL("http://www.wikipedia.org", "_blank");
            break;
    }
}

Script Description

For the Combo_silver component, the Events function has two parameters. The first parameter, n, is the name of the calling object. The second parameter, v, is the new value.

As the example movie only contains the one component, the value of n will always be “Combo_silver”. If the movie contained multiple components and those components were all configured to call the same events function, then the parameter n could be used to determine which object caused the event.

The parameter v contains one of the website names. It will be one of: “SWiSHzone.com”, “Blog”, “Forums”, “Support”, “Google”, “Wikipedia” or “Take me to…”

The Events function simply compares the current value of the combo box with the known names and when a match is found, it opens the associated website using the getURL() command. If the v parameter contains “Take me to…” no action is taken.

Note that I have used “_blank” as the target location for the new page. This will cause the page to open in a new browser window (or new tab if your browser supports tabs). “_self” could have been used instead causing this page to be replaced with the newly select page, but I wanted you to read to the end of the article ;). Note that when using “_self”, some security settings may restrict access to other web pages that are not in the same domain. If this occurs, it will appear as if “_blank” has been used even though “_self” was specified.

Well that’s about it. As you can see, there is not much to it. If you are interested the sample .swi can be found in the file  weblink.zip.

Tags: , ,

12 Responses to “A Combo of links”

  1. Angelo says:

    Great, thank you!

  2. good afternoon
    is there any possibility of make it a combo of mails?
    thanks for your anwser

    • Julio Proano says:

      Yes, all you need to do is use the mailto command:

      function Events(n,v) {
      switch(v) {
      case “SWiSHzone.com”:
      getURL(“mailto:ret@msn.com”);
      break;
      case “Blog”:
      getURL(“mailto:cplam@yahoo.com”);
      break;
      }}

  3. Simon says:

    Is there any way to make this more accessible? ie. navigate to the menu (and it’s options) using the keyboard?

    • jonh says:

      Hi,

      Keyboard navigation is possible, but it is currently not supported by the component. Such support would require significant modifications to the component.

      Regards,

      Jon

  4. randy says:

    can i add also the animation in a website? by using these software? i will wait for your reply.. thank you

  5. nomexs says:

    can you tell me how to create 1000px in width animation with hq and not a big size? thanks!

    • jonh says:

      Hi,

      I am sorry do not know the answer to your question. I can only really answer questions that relate specifically to the article. For general “how do I do it” type questions such as the one you have asked, please post a question in our forums at: http://forums.swishzone.com

      Regards,

      Jon

    • Koen says:

      You can create not so much slides or like an option not to use much images!
      Thanks!

  6. Christian MB says:

    Hi… please can you tell me if i can call a .swf in a sprite container from this combo box ???

    i.e.

    function Events(n,v) {
    switch(v) {
    case “Button 1″:
    container.loadMovie(“MyMovieInTheContainer.swf”);
    break;
    case “Button 2″:
    container.loadMovie(“MyMovie2InTheContainer.swf”);

    Thanks !!!
    Greetings from Santiago de Chile.

    • jonh says:

      Yes, that should work OK.
      If the main movie contains both the combobox and the container movie clip at the top level, and the events function exists in the main movie, then it should all work OK. Note that when testing in Max, you need to set Tools | Preferences | Player – Test / Load movie folder correctly if the preview button is going to work correctly.

      It is also probably a good idea to test that n in the events function is actually the name of the combo box component, incase some other objects are accidentally configured to to call the same function.

      Jon

    • jonh says:

      Yes, that should work OK.
      Note that if you want to communicate with the movie that is loaded within the container, you will need to wait until it is fully loaded.
      Jon


Switch to our mobile site