dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Quick Yes/no Question!!!

  1. #1
    Flash Honkie
    Join Date
    Nov 2001
    Location
    Athens, Ga
    Posts
    212

    Quick Yes/no Question!!!

    I have 235 buttons, each button is within a movie clip. That movie clip is named 1 through 235.

    On each button, I have the same function. Is there a way to put that function on every button, whether through a for or while loop, without actually putting that code on each of the buttons.

    Any help is appreciated.

    - Jeremy
    "Creativity is a virtue; Happiness is a reward."

  2. #2
    Moderator
    The Minister of No Crap

    Join Date
    Nov 2000
    Location
    Philadelphia
    Posts
    2,685
    Yes.

    It will still require that you touch ever movieclip to specify that one function one the button.

    Scott

  3. #3
    Flash Honkie
    Join Date
    Nov 2001
    Location
    Athens, Ga
    Posts
    212

    hmm

    I may get the same answer to this...but I don't believe that's quite what I'm looking for.

    right now, every button calls the same function...but they call the functions with the on press, on rollover, on rolloff clip actions.

    I know you can specify a variable value for a movieclip not in the movie itself like this:

    _root.myMovieClip.id = 5;

    in much the same fashion, I'd like to put this line of code on the button, without actually putting it on the button.

    on (press){
    _root.myFunction(this._target, this);
    }

    and the path for the movieclip that the button resides in is _root.map.15

    - jeremy
    "Creativity is a virtue; Happiness is a reward."

  4. #4
    Flash Honkie
    Join Date
    Nov 2001
    Location
    Athens, Ga
    Posts
    212

    Clear things up a bit

    This may help clear things up, or give you an idea of why I'm asking.

    http://www.islandathens.com/home2.php

    the buttons are the buildings on the map and everything is dynamic but I'd like to reduce the amount of actual code I'm using.

    - Jeremy
    "Creativity is a virtue; Happiness is a reward."

  5. #5
    Member
    Join Date
    Jan 2002
    Location
    Outside space and time
    Posts
    50
    The short answer to your question is... yes. With Flash MX there is really no reason to use button anymore as movieclips support all the same events/methods. So, for example, if you have a movie clip myMovie and you want to execute a function everytime it is pressed, you can simply write:

    myMovie.onPress = someFunction
    or
    myMovie.onPress = function () { trace("some action") ; }

    While the details of how you should implement this idea in your code is up to you, I seriously recommend: Object-Oriented Programming with ActionScript published by New Riders. Hope that helps....

    Chad
    http://www.pear-mouse.com

  6. #6
    Flash Honkie
    Join Date
    Nov 2001
    Location
    Athens, Ga
    Posts
    212
    Hey, I saw your history tracking applet, nice site.

    I create an array of objects (no multi-dimensional array support) to get data out, but the actual functions on each button was what was giving me a hard time.

    hmm...so, in essence, I can just get rid of each of the function on the buttons. I have removed the on press, on rollover yada yada stuff with one line of

    #include "buttonFuntions.as"

    and since the function is the same for all the buttons, I just did that instead. I'm going to play with your suggestion though, see where it gets me. Thank you.

    - Jeremy
    "Creativity is a virtue; Happiness is a reward."

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