A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: movie clips as buttons

  1. #1
    Hey

    Im having trouble.

    I have an XML file that basically stores two types of items, a URL and a name for that URL. Im putting the XML through a function and putting the urls into one array and the names into another.

    heres where it all falls down. i now need to take those two arrays and make them movieclips that you can click on to take you to that link.

    Can anybody help? I have no idea how to do this.

    Lee

  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    Well, part of your problem is that you cant directly take an action off of clicking on a movie clip, because you cant click on it in the sense you can with button. You can embed a button inside of your MC though, and just have it set off the MC's actions when it gets pressed. Now, you can put a dynamic text box inside of that movie clip, say right above the button, and set it equal to one of the names in your array.

    Then you can set a variable equal to the actual url in the other array and have it set up so that when you click on the button inside of the MC then it takes you there... Say

    array[1]="http://www.flashkit.com"

    set a variable like temp=array[1] ,then you can use

    getURL(_root.temp,_blank)

    and check the expression box for the URL and it will evaluate the contents of temp as the URL.

    Does that help you at all?

  3. #3

    buttons ctd

    it would help im sure if i could get the gist of what you are trying to say. I just cant seem to comprehend it...

    bear with me... im a slow learner...

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    Okay, well, lets try this again, ill write more out and assume you know very little about actionscripting...

    Okay, first off, create a new empty MC, use ctrl-F8. Name it something, say actionclip. Now place an instance of that new, empty MC on stage and name it something, say clip1. Now, Im going to make an assumption that you have already gotten the XML brought into your MC and parsed and such so that you have array1[] with the name and array2[] with the URL.

    Now open your library, and double click on actionclip so that your inside of the symbol editor.

    First, select the text tool and place a dynamic text box on the stage, and give it a name, say location. Make it the size you want and format the text it will show.

    In the timeline of your MC, write

    location=_root.array1["i"];
    address=_root.array2["i"];

    //i is some number you alter depending on which one of the
    //array memebers you want to use. I also wrote this as
    //_root.array1[] but you need to change that path based on
    //where you keep the arrays stored at. Also, dont use quotes
    //around i, I just had to do that to keep flashkit from
    //italicizing everything


    Now you need a buttton. Either create one or take one from the shared libraries. Now, you should have the on option available. Select it, and select the release option. Heres the script:

    on(release){
    getURL(this.address,_blank);
    //make sure to check expression next to both fields, that
    //way it evaluates this.location as a variable and doesnt
    //think that is the actual URL.
    }

    Does that explain it better?

  5. #5

    buttons ctd

    yes indeed it does. thats fantastic! its not that i know very little about actionscripting, as i can do a lot of things quite easily. i just get very confused sometimes, especially when reading a description of how to do something.

    but you are a legend

    thanks heaps!

  6. #6
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    Well, im glad i could help
    whats this legend stuff ?

  7. #7

    Lightbulb legend

    he he,

    its just a generic "what a star you are for helping me" word.

    i didnt mean that you steal from the rich and give to the poor.

    although you might well do...

  8. #8
    Senior Member
    Join Date
    Apr 2001
    Posts
    116
    Naw, Im more of the poor being stolen for type.

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