7 Replies Latest reply on Jul 17, 2018 12:00 AM by HansMM19

    Animating based on Data updates - best approach? (AS3/.swf)

    Christopher_AE-Networks Level 1

      I'm looking for the best approach to moving a looping animation from point to point based on incoming data being pulled from a JSON file via AS3.

       

      This is a quiz type scenario with 12 questions.  All 12 questions are on this JSON and have a start status, end status, and how many people got it right.  The idea is to move an object across the screen in a linear fashion based on which question is open... 12 way points, question 1 to the left, question 12 to the right (2-11 in the middle).  Animation starts hovering over the question 1 way point until it ends (displaying # of people who got it right), then moves to hover over question 2 way point... rinse and repeat till question 12. 

       

      Canvas size is 1080 (for broadcast television) and I'm looking to confine this to the lower third of the screen (conserving resources as much as possible).  I'm able to pull the data and get them into text objects on the canvas; now I need an approach to getting an object to move based on question status data.

       

      Any help or advice would be appreciated.

       

      Thank you for your time.

        • 1. Re: Animating based on Data updates - best approach? (AS3/.swf)
          ClayUUID Adobe Community Professional

          What exactly are you requiring help with? How to programmatically position an object? How to parse the data you're pulling in? Something else?

          • 2. Re: Animating based on Data updates - best approach? (AS3/.swf)
            Christopher_AE-Networks Level 1

            I'm able to parse the data from the JSON file.  It's just getting the status of the questions to drive the movement of the object in question.  Is it easier to stick to straight script when moving the object?  Is there an easier symbol / key frame / tween approach?

            • 3. Re: Animating based on Data updates - best approach? (AS3/.swf)
              ClayUUID Adobe Community Professional

              Okay, which variable represents the current question, and how? You need to translate that into a Y-coordinate.

              • 4. Re: Animating based on Data updates - best approach? (AS3/.swf)
                Christopher_AE-Networks Level 1

                Thank you for your reply.

                 

                The coordinates will be predetermined on the canvas.  The questions are part of the same array on the JSON file, but have start/stop values I should be able to key off of.  (ex - if question 3 stops AND question 4 starts, then move from current position to new #4 position).  Is it better to build each as separate movie clip animations and somehow have the script run these animations when these conditions are met, or is using script solely as the means of moving this object a better approach?

                 

                Thank you for your time.

                • 5. Re: Animating based on Data updates - best approach? (AS3/.swf)
                  ClayUUID Adobe Community Professional

                  Your question is impossible to answer because you're being so vague about what data you're pulling in. This is all I've been able to figure out from what you've said:

                   

                  1. JSON data pulled in

                  2. ???????

                  3. Move animation to new position

                   

                  We can't offer up any usable code without knowing what we have to work with. Do you at least have the ability to derive a numeric variable that represents the new current question?

                  • 6. Re: Animating based on Data updates - best approach? (AS3/.swf)
                    Christopher_AE-Networks Level 1

                    There are no explicit numeric values coming form the JSON file that will indicate the new current question unfortunately. I believe that will need to be derived from the status of the questions around it.

                     

                    Here is a sample of the JSON file (below). 

                     

                    The "active" value indicates if the question has been released to the players,  The "resultReleased" indicates if the correct answer to that question has been released. 

                     

                    Question inactive - "active":false / "resultReleased": false

                    Question active - "active":true / "resultReleased": false

                    Question completed - "active":false / "resultReleased": true

                     

                    The current question could be derived by a question that is active, followed by a question that is inactive, and preceded by a question that is completed. (ex: question #9 below)... The "remainingUsersCoun" only gets a value when a question is completed.

                     

                    The condition to move the animation over to the next question is when one question is completed and the following one goes active

                     

                    I hope this clears up some of the vagueness.

                     

                    "game": {

                    "id": "c93a2f1b49b74993ae94e08052090931",

                    "reward": 1000,

                    "active": true,

                    "complete": false,

                    "viewerCount": 21773,

                    "activeUserCount": 364,

                    "questions": [

                    {

                    "id": "37d87640757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 28457

                    },

                    {

                    "id": "37d87644757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 27318

                    },

                    {

                    "id": "37d87648757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 24586

                    },

                    {

                    "id": "37d8764c757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 17210

                    },

                    {

                    "id": "37d87650757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 10326

                    },

                    {

                    "id": "37d87654757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 5679

                    },

                    {

                    "id": "37d87658757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 2271

                    },

                    {

                    "id": "37d8765c757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 908

                    },

                    {

                    "id": "37d87660757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": true,

                    "remainingUsersCount": 364

                    },

                    {

                    "id": "37d87664757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": false,

                    "remainingUsersCount": null

                    },

                    {

                    "id": "37d87668757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": false,

                    "remainingUsersCount": null

                    },

                    {

                    "id": "37d8766c757011e88d1b4d5bdc8ac454",

                    "active": false,

                    "resultReleased": false,

                    "remainingUsersCount": null

                    }

                    ],

                    },

                    "success": true

                    }

                    • 7. Re: Animating based on Data updates - best approach? (AS3/.swf)
                      HansMM19 Level 1

                      You can use script as the means of move your object. One approach could be to create an enter_frame eventlistener. Every time you process a new JSON file (every second?) you determine where the object needs to be, and save that position into a global variable.

                      In the enter_frame eventlistener you compare these values with the actual position of the object and if they are not the same, you move the object a couple of pixels in the correct direction by adding to its y property.