7 Replies - 1484 Views - Last Post: 19 December 2016 - 12:39 PM

#1 GaussianFracture   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-December 16

Play the frame number from script

Posted 17 December 2016 - 12:06 PM

Hello.

I have a MovieClip with 100 frames and I'm trying to get it to play the specific frames based on its acceleration values.

Here's an image explaining what I'm aiming for. The MC with 100 frames should go and stay at the 50th frame. Depending on its movement from left or right, it should play the movieclip frames inside forward or backward.

I'm a total noob so any help is appreciated.

Attached image(s)

  • Attached Image

Is This A Good Question/Topic? 0
  • +

Replies To: Play the frame number from script

#2 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2426
  • View blog
  • Posts: 7,421
  • Joined: 15-January 14

Re: Play the frame number from script

Posted 19 December 2016 - 11:13 AM

I'm not quite sure what that image is supposed to show, but you can keep a variable for the last and current frame (you'll need your own variable for the current frame instead of the one provided by Flash), so that on each frame you can tell which direction it is going.
Was This Post Helpful? 0
  • +
  • -

#3 GaussianFracture   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-December 16

Re: Play the frame number from script

Posted 19 December 2016 - 11:31 AM

View PostArtificialSoldier, on 19 December 2016 - 11:13 AM, said:

I'm not quite sure what that image is supposed to show, but you can keep a variable for the last and current frame (you'll need your own variable for the current frame instead of the one provided by Flash), so that on each frame you can tell which direction it is going.


I need the MC to read which frame to play by an objects _x position, so;

onClipEvent (enterFrame) {
var fNum:Number = 50;
gotoAndStop(fNum);
}

Normally the code above works if you manually enter any number bigger than 0 without fractions but I need it to read it from the position value of another object.

So it should look like ;

onClipEvent (enterFrame) {
var fNum:Number = _root.Target._x;
gotoAndStop(fNum);
}

but for some reason it doesn't work.
Was This Post Helpful? 0
  • +
  • -

#4 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2426
  • View blog
  • Posts: 7,421
  • Joined: 15-January 14

Re: Play the frame number from script

Posted 19 December 2016 - 11:46 AM

Make sure you're casting that as an integer or rounding up or down, or however you want to it. It may expect an integer for that instead of a float.
Was This Post Helpful? 0
  • +
  • -

#5 GaussianFracture   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-December 16

Re: Play the frame number from script

Posted 19 December 2016 - 11:50 AM

View PostArtificialSoldier, on 19 December 2016 - 11:46 AM, said:

Make sure you're casting that as an integer or rounding up or down, or however you want to it. It may expect an integer for that instead of a float.


The fractions in the float value is probably messing things up. it works fine when I use 1, 1.0, 99999 but breaks when I use -5, 0, 4,3 and stuff.

Could you help me to set it as an integer ? I'm just an animator, I almost have no working knowledge of scripting.
Was This Post Helpful? 0
  • +
  • -

#6 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2426
  • View blog
  • Posts: 7,421
  • Joined: 15-January 14

Re: Play the frame number from script

Posted 19 December 2016 - 12:00 PM

You can use Math.round, or int:

https://helpx.adobe....aces-flash.html
Was This Post Helpful? 0
  • +
  • -

#7 GaussianFracture   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 17-December 16

Re: Play the frame number from script

Posted 19 December 2016 - 12:33 PM

View PostArtificialSoldier, on 19 December 2016 - 12:00 PM, said:

You can use Math.round, or int:

https://helpx.adobe....aces-flash.html


Well that worked like a charm :) Thanks for that.
Now how would I find the position difference of an object in relation to the previous frame ?
Was This Post Helpful? 0
  • +
  • -

#8 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2426
  • View blog
  • Posts: 7,421
  • Joined: 15-January 14

Re: Play the frame number from script

Posted 19 December 2016 - 12:39 PM

You need to save the position in a variable, so that on the next frame you can get the current position and compare it with that variable to get the difference. So at the end of your code for each frame you need to save the current position in that variable so that it's available on the next frame.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1