Author Topic: ActionScript3 - Multiple Boolean Conditional Statement  (Read 1453 times)

CaramelAppleClock

  • Professional Slacker
  • Official Clock
  • Posts: 1965
  • Participated in Pass the Gravy collar 2014 For having submitted at least 50 animations Clock Day 2011 Participant Clock Day 2010 Participant Clock Day 2009 Participant Clock Day 2008 Participant Clock Day 2007 Participant Clock Day 2006 Participant
    • View Profile
    • Awards
ActionScript3 - Multiple Boolean Conditional Statement
« on: December 09, 2014, 04:14:40 PM »
I need help with a few lines of code I'm working for a commission.

Basically I have 10 movie clips that are invisible at the start. After they are all visible I want to do a gotoAndStop command. My current code is

Code: [Select]
if (med.visible && epa.visible && elg.visible && lig.visible && gov.visible && cst.visible && smt.visible && shr.visible && construction.visible && loc_com.visible){
gotoAndStop(2);
}


I don't get any errors, but the gotoAndStop doesn't initiate when all movie clips are visible.

Any thoughts?

CaramelAppleClock

  • Professional Slacker
  • Official Clock
  • Posts: 1965
  • Participated in Pass the Gravy collar 2014 For having submitted at least 50 animations Clock Day 2011 Participant Clock Day 2010 Participant Clock Day 2009 Participant Clock Day 2008 Participant Clock Day 2007 Participant Clock Day 2006 Participant
    • View Profile
    • Awards
ActionScript3 - Multiple Boolean Conditional Statement
« Reply #1 on: December 09, 2014, 05:03:43 PM »
Ok so I found a fix, took me a while though. I hoped to avoid using them cause I am a total sock at ActionScript, but apparently it was necessary to use an Array to clump together all those movie clips.

If anyone will ever encounter a similar issue, like having to use a multiple conditional for visible/invisbile objects, the code below goes before what I posted previously.

Code: [Select]
var answers:Array = new Array (med, epa, elg, lig, gov, cst, smt, shr, construction, loc_com);    
this.addEventListener (Event.ENTER_FRAME, multipleif)

    function multipleif(e:Event):void {

PhantomCatClock

  • ✡ Official Jew ✡
  • Official Clock
  • Posts: 5462
  • Ghosts: 1
    • Newgrounds: PhantomCat
  • For participating in all 28 days of the Flash Flood For winning flash of the month Clock Day 2018 Participant Clock Day 2017 Participant Clock Day 2016 Participant Clock Day 2015 Participant For having submitted at least 50 animations Participated in Pass the Gravy collar 2014 Clock Day 2014 Participant Clock Day 2013 Participant Clock Day 2012 Participant Contributed to the Home Alone Hentai Collab Participated in the House of Haunted Clocks Collab Hulk Hogan Epic Clock Fest 2014: Rise of the Poop or How I Learned to Stop Worrying and Love Cocaine Award for participating in Hulk Hogan Epic Clock Fest 2014: Rise of the Poop or How I Learned to Stop Worrying and Love Cocaine Participation in Fifen This Movie
    • View Profile
    • Awards
ActionScript3 - Multiple Boolean Conditional Statement
« Reply #2 on: December 09, 2014, 10:05:46 PM »
If that's your entire code, it's only called once, the second the movie runs. So right now, what's happening (with the code in your first post, that is,) is

Frame one:
is all those niggas visible? Naw. Do nothing.

Frame two, three, four...:
nothing, man. I already did my script.



and you want ._visible, not .visible

CaramelAppleClock

  • Professional Slacker
  • Official Clock
  • Posts: 1965
  • Participated in Pass the Gravy collar 2014 For having submitted at least 50 animations Clock Day 2011 Participant Clock Day 2010 Participant Clock Day 2009 Participant Clock Day 2008 Participant Clock Day 2007 Participant Clock Day 2006 Participant
    • View Profile
    • Awards
ActionScript3 - Multiple Boolean Conditional Statement
« Reply #3 on: December 10, 2014, 08:14:31 AM »
I do have some event listeners for buttons that toggle those movie clips' visibility on and off. However, the whole timeline is only 2 frames long.

Btw what does ._visible offer in favor of .visible?

PhantomCatClock

  • ✡ Official Jew ✡
  • Official Clock
  • Posts: 5462
  • Ghosts: 1
    • Newgrounds: PhantomCat
  • For participating in all 28 days of the Flash Flood For winning flash of the month Clock Day 2018 Participant Clock Day 2017 Participant Clock Day 2016 Participant Clock Day 2015 Participant For having submitted at least 50 animations Participated in Pass the Gravy collar 2014 Clock Day 2014 Participant Clock Day 2013 Participant Clock Day 2012 Participant Contributed to the Home Alone Hentai Collab Participated in the House of Haunted Clocks Collab Hulk Hogan Epic Clock Fest 2014: Rise of the Poop or How I Learned to Stop Worrying and Love Cocaine Award for participating in Hulk Hogan Epic Clock Fest 2014: Rise of the Poop or How I Learned to Stop Worrying and Love Cocaine Participation in Fifen This Movie
    • View Profile
    • Awards
ActionScript3 - Multiple Boolean Conditional Statement
« Reply #4 on: December 10, 2014, 11:42:50 AM »
Oh, whoops, it's ._visible in AS2. Just .visible in AS3. Weird they'd change that, since it's still an instance variable


ANYWAY, yeah, that event handler just makes the whole thing loop every frame, which is good (the following is completely unnecessary, but you could add a line to remove that listener after the gotoAndStop




Your thing is right, right now, but just so it's easier to understand in the future, your timeline IS only two KEYframes long, but that script is being called every FRAME. Y'allknowhowitis.