A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Which MC is visible?

  1. #1
    Junior Member
    Join Date
    Mar 2001
    Posts
    1
    In Flash 4,

    I have 5 mc's on the stage, with each one's alpha set to 0. I have five corresponding nav buttons. Say button 2 is clicked. Its corresponding movie clip's (mc2) alpha is then set to 100. If Button 3 is clicked, mc2 alpha gets set to 0 and now mc3 alpha gets set to 100, and so on with all the other buttons and mc's.

    Pretty simple, but I've had write code to account for all possiblities on each button click, i.e. on button3's release set the other 4 mc's alphas to 0 and set mc3's alpha to 100... times 5 buttons. Still not too bad, but what if I had say 80 or 100 mc's!

    Is there a way to have Flash "know" which one of the five (or 80) mc's alpha is set to 100, so that at at any point in time, a button's code is only dealing with the two mc's in question - the current visible mc that will be set to 0 and the newly chosen mc which will be set to 100? Can a variable(s) be set and then "check" for the 100% alpha somehow?

    Thanks,
    RK

  2. #2
    Member
    Join Date
    Mar 2001
    Location
    Venice, CA
    Posts
    88
    There are a few ways you could do this. You could set a variable in each MC called, say "myAlpha", and whenever you change the alpha, set the variable accordingly. That way you could check what a movie's alpha is and proceed from there.

    As for setting multiple movies at once, you're right, doing each one gets really tiresome! If you can name them sequentially (mc1,mc2, etc) then you can loop through and change whatever it is you want about them, like so:

    Code:
          Comment: ==================
          Comment: identify which movie # to
          Comment: single out
          Comment: ==================
          Set Variable: "n" = "4"
          Comment: ==================
          Comment: set the # of movies you
          Comment: have in total
          Comment: ==================
          Set Variable: "numberOfMCs" = "6"
          Comment: ==================
          Comment: loop through and set all but
          Comment: the one you want to change
          Comment: ==================
          Set Variable: "looper" = "0"
          Loop While (looper < numberOfMCs)
                Set Variable: "looper" = looper + 1
                If (looper <> n)
                      Comment: ==================
                      Comment: hide all except movie #n
                      Comment: ==================
                      Set Property ("/mc"&looper, Alpha) = "0"
                Else
                      Comment: ==================
                      Comment: show movie #n
                      Comment: ==================
                      Set Property ("/mc"&looper, Alpha) = "100"
                End If
          End Loop
    For a Flash example where you can set n in the example above:

    http://www.greenbug.com/tutorials/fl...pha_loop4.html

    And the .fla:

    http://www.greenbug.com/tutorials/fl...lpha_loop4.zip


    Hope that helps!

    Kate

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    303

    just use getproperty

    I think setting so many flags can get bad...so all you can do is check for the value of the alpha property using the getproperty method within an if statement and it will work like a breeze.
    It is short and simple.
    Cheers
    gary

  4. #4
    Member
    Join Date
    Mar 2001
    Location
    Venice, CA
    Posts
    88

    d'oh!

    Complete brain freeze, I spaced on Get Property for Alpha for a few mintues there.

    Either way though, if you have 10 or 80 clips, you're not going to want to check the property/variable/whatever on each one individually unless you absolutely have to, so the loop above applies. Actually I left out any individual checking (aside from "what number mc am I?) for that reason...but I did definitely forget about Get Property (idiot!) so disregard the first bit about the variables!

    Kate

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