Skip to main content
Participant
July 12, 2018
Answered

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

  • July 12, 2018
  • 2 replies
  • 504 views

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.

This topic has been closed for replies.
Correct answer HansMM19

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.

2 replies

HansMM19Correct answer
Participant
July 17, 2018

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.

Legend
July 12, 2018

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

Participant
July 12, 2018

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?

Legend
July 12, 2018

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