• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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.

Views

335

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

New Here , Jul 17, 2018 Jul 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.

Votes

Translate

Translate
LEGEND ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 12, 2018 Jul 12, 2018

Copy link to clipboard

Copied

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": "c93a2f1b­49b7­4993­ae94­e08052090931",

"reward": 1000,

"active": true,

"complete": false,

"viewerCount": 21773,

"activeUserCount": 364,

"questions": [

{

"id": "37d87640­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 28457

},

{

"id": "37d87644­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 27318

},

{

"id": "37d87648­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 24586

},

{

"id": "37d8764c­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 17210

},

{

"id": "37d87650­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 10326

},

{

"id": "37d87654­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 5679

},

{

"id": "37d87658­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 2271

},

{

"id": "37d8765c­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 908

},

{

"id": "37d87660­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": true,

"remainingUsersCount": 364

},

{

"id": "37d87664­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": false,

"remainingUsersCount": null

},

{

"id": "37d87668­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": false,

"remainingUsersCount": null

},

{

"id": "37d8766c­7570­11e8­8d1b­4d5bdc8ac454",

"active": false,

"resultReleased": false,

"remainingUsersCount": null

}

],

},

"success": true

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 17, 2018 Jul 17, 2018

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines