User Tag List

Results 1 to 10 of 10

Thread: Selecting something by its ID

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleSWF Export Module
    Game_Master's Avatar
    Join Date
    Jul 2007
    Location
    England
    Posts
    1,705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Selecting something by its ID

    Hi
    I have 12 Active Picture objects, each of them is a clone of the first one. They are all in a qualifier group called "Neutral" and they each have an alterable value named "ID". How would I get it so that I could select in a loop an object from the value of it's ID?

    Thanks,
    GM

  2. #2
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    You'd want to assign each one an ID in its alterable values instead of using its 'fixed value', since those are nondeterministic. After creating them all, for example at the start of the frame, you'd want to put a line:

    -Spread Value 0 in Active Picture

    This will assign a value to each active picture, starting with 0 and incrementing by 1 on each one (ie 0, 1, 2, 3, ... 11)


    In your loop code, to select one object, you'd simply add the condition:


    +Does Alterable Value of Active Picture == LoopIndex("Fast Loop Name")



    An alternative, and more robust way of 'selecting one object from a group in a loop' is using 2 flags to select objects. This same skeleton code can be used in any part of your code for any object, without having it be set up via spread values first:




    Code:
    +Upon Condition XXXXX
    =Set Flag 1 of "Object" OFF
    =Set Flag 2 of "Object" OFF
    =Start Fast Loop "Loop" for NumObjects("Object") number of times.
    
    +Upon Fast Loop "Loop"
    +"Object" Flag 1 is OFF
    +Pick an "Object" at random
    =Set Flag 1 of "Object" ON
    =Set Flag 2 of "Object" ON
    
    +Upon Fast Loop "Loop"
    +"Object" Flag 2 is ON
    =DO YOUR ACTIONS HERE
    
    +Upon Fast Loop "Loop"
    =Set Flag 2 of "Object" OFF
    This will select one object at a time from a group, run the events on it, and then pick another on the next iteration, never picking the same one twice. However, be warned that in large applications this uses O(N^2) time complexity for N objects, since there are N loops each with N comparisons to flags (each flag comparison has to iterate over N objects), so while this is suitable for 12 objects, it wouldn't be for 1200.

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleSWF Export Module
    Game_Master's Avatar
    Join Date
    Jul 2007
    Location
    England
    Posts
    1,705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    Thanks, I appreciate the reply, but since the objects are cloned, this doesn't work

  4. #4
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    You mean they are separate objects?
    You'd have to select each one individually, with one line of code per object, which is why its not a good idea to clone everything :S

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleSWF Export Module
    Game_Master's Avatar
    Join Date
    Jul 2007
    Location
    England
    Posts
    1,705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    The reason I cloned them is because they had to have seperate alterable values/strings (each one has an icon path, icon image, tooltip etc). Would the alterable values/strings be seperate of each other if the object was duplicated?

  6. #6
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    You could set all the cloned objects to have sequential alterable values from the start, i.e. picture 1 would have index 0, picture 2 would have index 1, etc. Then loop through them all using the qualifier.

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleSWF Export Module
    Game_Master's Avatar
    Join Date
    Jul 2007
    Location
    England
    Posts
    1,705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    I tried that to begin with, but sadly, that didn't work

    Thanks anyway though, guys

    I've just cloned them, and manually given them an ID, which works fine

  8. #8
    Clicker Multimedia Fusion 2 DeveloperiOS Export ModuleSWF Export Module
    Jaffob's Avatar
    Join Date
    May 2008
    Location
    USA
    Posts
    1,833
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    Quote Originally Posted by Game_Master
    I've just cloned them, and manually given them an ID, which works fine
    So it did work then? That's what I was suggesting.

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleMac Export ModuleSWF Export Module
    Game_Master's Avatar
    Join Date
    Jul 2007
    Location
    England
    Posts
    1,705
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    It did, but I didn't end up looping them, just copied the behaviours over

  10. #10
    Clicker Multimedia Fusion 2SWF Export Module

    Join Date
    Sep 2006
    Posts
    1,544
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Re: Selecting something by its ID

    different instances of the same active object class have their own alterable values and other variables, in the case of active picture including the picture they will use. If you know any C programming, an active object is effectively like a "Class"- its just a kind of object, and each instance of it is unique and holds its own variables.


    it is possible to loop through instances of objects with a qualifier, but you will only be able to execute generic active object events on them (ie anything an active object can do). You will not be able to do any of the Active Picture's special events, because you're referring to a qualifier.

Similar Threads

  1. Selecting Channel by Name bug
    By Asholay in forum Lacewing
    Replies: 0
    Last Post: 29th January 2009, 06:43 PM
  2. Selecting Objects by Value?
    By YAS in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 31st August 2007, 09:34 PM
  3. Help with selecting instances
    By Simion32 in forum File Archive
    Replies: 0
    Last Post: 14th April 2007, 07:44 PM
  4. selecting object
    By westray in forum Multimedia Fusion 2 - Technical Support
    Replies: 3
    Last Post: 15th July 2006, 01:23 PM

Posting Permissions

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