User Tag List

Results 1 to 10 of 10

Thread: Order of Events for Loops

  1. #1
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Ethan's Avatar
    Join Date
    Apr 2010
    Location
    Fort Worth, TX
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb Order of Events for Loops

    I asked about the order in which events will occur for fastloops and ForEach loops for MMF2, and nobody would give me an answer besides, "Test it". So I'm making this post, after a long time without posting, to show you the answer to my question, so you don't have to test it yourself. To start with, here's the .mfa file I used to test it with: Testing loops.mfa and for those of you that can't open it for whatever reason, here are some screenshots of the setup for the test.



















































    Here are the results of this test. Where the longer numbers are the fixed values of each of the objects being listed on each event, and the numbers are the number of which event is being run in the fastloop.

    Hopefully this has helped some of you in some way, if you have had a problem dealing with this but were unable to understand my explanation, feel free to PM me.
    Images attachées Images attachées

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleUnicode Add-onInstall Creator

    Join Date
    Jul 2006
    Posts
    1,018
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your effort!

  3. #3
    Clicker Fusion 2.5 MacFusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleXNA Export Module
    Fusion 2.5 (Steam)Fusion 2.5 Developer (Steam)Android Export Module (Steam)HTML5 Export Module (Steam)iOS Export Module (Steam)Universal Windows Platform Export Module (Steam)
    gkinfinity's Avatar
    Join Date
    May 2011
    Location
    USA
    Posts
    284
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That's interesting, thanks. I wouldn't have expected the for each loop to work that way exactly, although it does make sense

    (I've never used a for-each loop so I have no experience with them at all)

  4. #4
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    OldSchool80s's Avatar
    Join Date
    Dec 2012
    Location
    USA
    Posts
    91
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for taking the time to share this.

  5. #5
    Clicker Fusion 2.5 DeveloperFusion 2.5+ DLCSWF Export Module
    Alonso's Avatar
    Join Date
    Jul 2006
    Posts
    681
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It would seem like the foreach runs 1 event x loops before it moves to the next event, but take a look at the modification I made. The issue is that the object's iteration is not being considered. Personally, I've avoided using foreach because of its lack of support for qualifiers (it's the only extension I've found that doesn't support them, which beats its purpose completely).

    Testing loops.mfa

  6. #6
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    Alonso: The ForEach extension has supported qualifiers for ages now - you probably just need to update your copy.

    Anyway...
    I'm not sure why you're having problems with this - it's pretty straightforward.

    Line 1 - MMF2 starts the ForEach loop.
    MMF2 picks the first object (the order, like everything else in MMF2, is based on the order in which the objects were created, or for objects created at edittime, on their display order).
    MMF2 scans through the complete event list from top to bottom, processing every event with a "on ForEach loop" condition, in the order in which they appear in the event list.
    Once MMF2 reaches the end of the event list, that is one iteration done.
    MMF2 then moves onto the next object and starts again.

    It's just the same as with fastloops.

  7. #7
    Clicker Fusion 2.5 DeveloperHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    Ethan's Avatar
    Join Date
    Apr 2010
    Location
    Fort Worth, TX
    Posts
    173
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something else I'd like to point out is that the ForEach loop is using the same object each time, but since it's a different instance of the object it has a different fixed value. So it loops through the first object for each event and then loops through the second object for each event. And therefore the ForEach Loop does indeed work the same as the fastloop, even though the picture might not show that very well. The ForEach loop did this: Event 1 object 1, event 2 object 1, event 1 object 2, event 2 object 2, and the Fastloop did this: Event 1, event 2, event 1, event 2, as you can see the event order is the same, the only thing that changes is which objects are being selected.

  8. #8
    Clicker Fusion 2.5 Developer

    Join Date
    Jul 2008
    Location
    UK
    Posts
    1,393
    Mentioned
    16 Post(s)
    Tagged
    0 Thread(s)
    "Immediate" conditions (the ones written in red), are all handled in exactly the same way, and really loops aren't anything special - they're just actions that trigger an immediate condition, that's all.

    The main use of the fixed value in ForEach loops, is for creating nested loops.
    For example, one way to make each of multiple player objects look towards their nearest enemy, would be by using nested ForEach loops like this:

    + Always
    -> Player: Set StoredDist to 99999999

    + Always
    -> ForEach: Start ForEach loop "PlayerLoop" for Player

    + On ForEach loop "PlayerLoop" for Player
    -> ForEach: Start ForEach loop "EnemyLoop" for Enemy

    + On ForEach loop "EnemyLoop" for Enemy
    + Player: Fixed value = LoopFV( "ForEach", "PlayerLoop")
    + Player: StoredDist > distance from Player to Enemy
    -> Player: Set StoredDist to distance from Player to Enemy
    -> Player: Look in the direction of Enemy

    Similarly, it's possible to nest fastloops inside ForEach loops, and vice versa.

  9. #9
    Clickteam Clickteam
    Fernando's Avatar
    Join Date
    Dec 2006
    Posts
    6,784
    Mentioned
    298 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by MuddyMole View Post
    Alonso: The ForEach extension has supported qualifiers for ages now - you probably just need to update your copy.

    Anyway...
    I'm not sure why you're having problems with this - it's pretty straightforward.

    Line 1 - MMF2 starts the ForEach loop.
    MMF2 picks the first object (the order, like everything else in MMF2, is based on the order in which the objects were created, or for objects created at edittime, on their display order).
    MMF2 scans through the complete event list from top to bottom, processing every event with a "on ForEach loop" condition, in the order in which they appear in the event list.
    Once MMF2 reaches the end of the event list, that is one iteration done.
    MMF2 then moves onto the next object and starts again.

    It's just the same as with fastloops.
    Hi MuddyMole,

    Do you know if the foreach is working with qualifiers in flash?
    Regards,


    Fernando Vivolo

    ... new things are coming ...

  10. #10
    Clickteam Clickteam
    Danny's Avatar
    Join Date
    Aug 2007
    Location
    United Kingdom
    Posts
    3,016
    Mentioned
    21 Post(s)
    Tagged
    2 Thread(s)
    I can confirm it does and it doesn't. It's a trick one to narrow down using 'ForEach Group' but my results were very inconsistent, I have been meaning to get something together for Ross to take a look at. My final answer on what I have seen/done would be no, best to just iterate through each object as opposed to a qualifying group (for now anyway)

Similar Threads

  1. Groups > Activated - Deactivated and order of execution of events
    By bupaje in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 8th April 2012, 05:55 PM
  2. Fastloops/Threading/Order of Events
    By netninja in forum Lacewing
    Replies: 11
    Last Post: 22nd January 2012, 11:42 PM
  3. In what order are events handeled?
    By King_Cool in forum Multimedia Fusion 2 - Technical Support
    Replies: 12
    Last Post: 5th December 2011, 02:41 PM
  4. events don't run in the expected order
    By keokeo in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 24th November 2011, 07:30 PM
  5. Events Handled Outside of Event Order (Bugs)
    By Raphael in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 26th September 2006, 09:20 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •