Beenden
  • Globale Community
    • Sprache:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Slider to control timeline

Engagiert ,
May 31, 2018 May 31, 2018

Hi there,

I have checked a few posts about controlling the timeline with a slider but I am afraid they may be a bit too advanced for me.

Would anyone recommend a post or a resource which explains the simplest way to have a slider that controls the timeline.

Just the simplest case.

Thank you in advance

B

12.4K
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines

correct answers 1 richtige Antwort

Community Expert , Jun 01, 2018 Jun 01, 2018

// UPDATE (10/26/2018): improved version that takes into account responsive settings, drag offset and frame to position precision.

The download link is the same.

this.button.on("mousedown", function(e)

{

     e.target.offsetX = (e.stageX / stage.scaleX) - e.target.x;

}.bind(this));

this.button.on("pressmove", function(e)

{

     e.target.x = this.clamp((e.stageX / stage.scaleX) - e.target.offsetX, this.bar.x, this.bar.x + this.bar.nominalBounds.width);

     this.setProportion();

}.bind(this));

this.setPropo

...
Übersetzen
Entdecker ,
Apr 26, 2022 Apr 26, 2022

Thank you for this very nice slider example! It's works fine, straight out of the box.

I tried dropping it into an application I am building but I'm running into some issues getting the slider library components to get picked ip. I am getting the following error in the console:

Uncaught TypeError: lib.SliderMarker is not a constructor

 Any ideas where I might be going wrong? I appreciate your input. Thanks!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Apr 26, 2022 Apr 26, 2022

Actually - I figured it out. I was missing the SliderMarker linkage. 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Apr 26, 2022 Apr 26, 2022

Hi.

 

I'm glad you figured it out.

 

Please let us know if you need anything else.

 

Regards,

JC

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Apr 26, 2022 Apr 26, 2022

Hey! I'll be honest and say I'm not entirely sure that I understand the need for the linkage name? What is it's purpose?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Apr 26, 2022 Apr 26, 2022

You need linkage names to create instances of symbols at runtime.

 

It's similar to the approach used in AS3 documents. It's possible to access symbols in the Library without linkage names in HTML5 Canvas documents in a more hacky way, but I think there's no need for it.

 

Another reason for using a linkage name is when the symbol you want to create isn't being used anywhere in the stage but we have to tell Animate that we need to use it at runtime anyway. For example: particles, bullets, and so on.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Apr 27, 2022 Apr 27, 2022

Interesting. I'm using HTML Canvas / JS and I am trying to get a sense of the best way to refernence you slider from another layer that hosts another JS routine to process the slider data. If it's on the stage, I think I can just write something like: 

let variable_name = this.slider.value;

Is there any reason not to take this approach? I'm assuming it's accesible because it's on the 'stage' (I'm new to Animate but I've been coding for a while.

Thanks!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Apr 28, 2022 Apr 28, 2022

you can put code in different layers, but it's recommended you name your layers so it's easy to find the relevant code.

 

also, timing may be an issue, esp if you have code spread across different frames and/or different timelines.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Apr 28, 2022 Apr 28, 2022

I'm just using a single frame for the moment as I design stuff out. Timing is the issue I am running into. I want to recompute a function every time the slider is moved. Ideally, I'd like to replay my single frame when the slider is moved, if that makes sense? I'm guessing my options are somewhere between using setInterval() and requestAnimationFrame() that I'm reading about?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Apr 28, 2022 Apr 28, 2022

use the pressmove event for a slider.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Apr 28, 2022 Apr 28, 2022

Right, but what's the best practice for using a pressmove event to recall a specific function that exists in another layer? Seems to me that I would compare the last slider value against the current and then use requestAnimationFrame() to schedule the callback, yes? 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Apr 28, 2022 Apr 28, 2022

in the pressmove listener function save a reference to the current value.  check to see if that needs to be updated because the slider position has changed, and if it's changed, call whatever function to do whatever you want done.

 

layers are irrelevant in this discussion (so far).

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Nov 08, 2022 Nov 08, 2022

Any chance you can reupload this file? It'd be amazing. 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Nov 09, 2022 Nov 09, 2022
Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Nov 09, 2022 Nov 09, 2022

Legend. Thanks mate. 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Entdecker ,
Nov 03, 2018 Nov 03, 2018

Thank you. I wonder why there is no scripting reference in Adobe Animate for using javascript in Animate. I know there is a good online documentation on createJS but to use that in Animate is for a designer that now and then likes to ad some code not clear at all. A mousedrag functionality like this slider example shouldn't be that difficult to figure out even in to make it responsive in a hierarchy. Animate is generating javascript but I cant figure out how to deal with that proces within the code-editor of Animate. This code makes it clearer how to use JS in Animate. Thank again!

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Beitragender ,
Dec 04, 2020 Dec 04, 2020

This slider is built excellent - I have not found anything better. All my compliments.
I duplicated it, cause I needed two sliders in one frame and I got two numbers, generated by sliders (I removed % from text field). Given names are txt1 and txt2 ("txt" in the original script).
I'm stuck to use those numbers now to make some calculations using them. Can anyone give a hint?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Beitragender ,
Dec 04, 2020 Dec 04, 2020

OK ... I figured out it by myself, how to link those numbers to make calculations.

What  is still not solved is the Range of the sliders and numbers.
They are now percents. How to make them "from1 to30", for example?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Feb 15, 2021 Feb 15, 2021

Any ideas for how I could use this slider to make a more advanced master controller plugin for Animate which can frame pick and refer to instances on the timeline in graphic symbols? Say for example if I wanted to rig up a 360 head turn using drawn keyframes and morphed shapes that the slider could control on an xyz grid which selects the instances and frames within the symbol?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Nov 18, 2022 Nov 18, 2022

Maybe you should go to the help of the website to download the as Help manual

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Neu hier ,
Nov 18, 2022 Nov 18, 2022

What a useless response.

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Nov 18, 2022 Nov 18, 2022

@Richard23620971p1yo,

 

try to refrain from responding to trolls. it leads no where beneficial.

 

do you have a questions about your original or subsequent posts?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Jun 02, 2023 Jun 02, 2023

Dear all

Thank you for your time

Is there a way of turning the horizontal slider into a vertical slider? I have checked everywhere  but cant seem to find out how to do it. I loaded down files and try to change the x refences to y in various ways result either the button goes to the top left corner or in other cases it nothing at all. I have been working on this for a little while trying to learn what all the code means but cant figure out how I can acomplish what I need..

Best Regards All

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Jun 02, 2023 Jun 02, 2023

there's not going to be any significant different.  you just associate the slider's vertical position (ie, y property with your movieclip's timeline):

 

paramA = paramF(slider_y_min,slider_y_max,movieclip_frame_min,movieclip_frame_max);

 

function paramF(x1,x2,y1,y2){

var m=(y1-y2)/(x1-x2);

var b = y1-m*x1;

return [m,b];

}

}

 

then to find the desire movieclip frame use

 

interpolateF(your_movieclip,paramA,y);

 

function interpolate(mc,a,y){

mc.gotoAndStop(Math.round(a[0]*y+a[1]));

}

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community-Einsteiger ,
Jun 02, 2023 Jun 02, 2023

Dear kglad

Thank you for your reply, the code i am tring to change is below

this.button.on("mousedown", function(e)

{

     e.target.offsetX = (e.stageX / stage.scaleX) - e.target.x;

}.bind(this));

 

this.button.on("pressmove", function(e)

{

     e.target.x = this.clamp((e.stageX / stage.scaleX) - e.target.offsetX, this.bar.x, this.bar.x + this.bar.nominalBounds.width);

     this.setProportion();

}.bind(this));

When I change the functions "mouse down" to "y" and "press move" to "y"  when I try to move the button it goes straight to the top left hand corner and stays there, will not move.
I am not sure how I refer to the code you suggested to make the code work for the vertical direction. Sorry still struggling with Javascript in Adobe animate.
Best Regards Peter

 

 

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines
Community Expert ,
Jun 03, 2023 Jun 03, 2023

you posted to a forum about a slider controlling a movieclip and that's what i answered.  your code looks like code to (possibly) control a slider (not a movieclip).

 

so, just what are you trying to do?

Übersetzen
Melden
Community-Richtlinien
Seien Sie freundlich und respektvoll, geben Sie die ursprüngliche Quelle der Inhalte an und suchen Sie vor dem Absenden Ihres Beitrags nach Duplikaten. Weitere Informationen
community guidelines