Skip to main content
Manic-Mars
Known Participant
May 30, 2018
Question

Use Slider value to go to frame label?

  • May 30, 2018
  • 1 reply
  • 1101 views

Hello! here is my final problem with my paper doll game, I have added sliders for a space saving selection of many changeable options. I now need to connect the options in the slider with the frames on the changeable movie clip. I looked over it and I just can't do it given that the dynamic text does not want to update properly.... Here is the code for one of my 4 sliders, (each has it's own frame)

import fl.events.SliderEvent;

femvarry.text = "Female Vairations:" + slide1.value

slide1.value = 0;

slide1.maximum = 5;

slide1.minimum = 0;

slide1.addEventListener (SliderEvent.CHANGE, Slide1event)

function Slide1event (event:SliderEvent):void{

  femvarry.text = "Female Vairations: " + event.target.value;

}

The easy thing is the frames in the movie clip I want to link have all been labeled, "Female Vairations: 0, 1, 2 ect" So I just need to find a way to get the code to go to each label. The only way I know is a if femvarry.text = # gotoAndStop # in the movie clip I need. (of corse not that exactly....) So that and find out why the dynamic text, femvarry isn't working...

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
May 30, 2018

use:

your_movieclip.gotoAndStop(whatever frame number or label);

Manic-Mars
Known Participant
May 30, 2018

Yes I essentially said that. What I don't know is how to structure the code around it... A var function? or just a function? or add it to the existing function?  ... I did make something that probably totally off, but it uses code I'm familiar with....

var mySlider1Array = ["Female Vairations: 0", "Female Vairations: 1", "Female Vairations: 2", "Female Vairations: 3", "Female Vairations: 4", "Female Vairations: 5"];

for each (var Slider1 in mySlider1Array) {

  Slider1.addEventListener(SliderEvent.CHANGE, onSlider1Click);

}

function onSlider1Click (event:SliderEvent):void {

  aut1.gotoAndStop(event.target.name);

}

I added this to the existing code and got an output type error, "value is not a function."

kglad
Community Expert
Community Expert
May 31, 2018

var mySlider1Array = ["Female Vairations: 0", "Female Vairations: 1", "Female Vairations: 2", "Female Vairations: 3", "Female Vairations: 4", "Female Vairations: 5"];

for each (var Slider1 in mySlider1Array) {

  Slider1.addEventListener(SliderEvent.CHANGE, onSlider1Click);

}

function onSlider1Click (event:SliderEvent):void {

switch (mySlider1Array.indexOf(event.currentTarget.name)){

case 0:

  aut1.gotoAndStop(event.target.value);

break;

case 1:

someothermovieclip.gotoAndStop(event.target.value);

break;

etc

}

}