Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
use:
your_movieclip.gotoAndStop(whatever frame number or label);
Copy link to clipboard
Copied
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."
Copy link to clipboard
Copied
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
}
}
Copy link to clipboard
Copied
I applied you code but Im getting: "Type Error: Error #1006: value is not a function." in output when I try to use it.
Copy link to clipboard
Copied
if you fixed your slider so it has values that are valid frame numbers (eg, there's no frame 0 in as3), what line of code is causing that error message. (file>publish settings>swf>tick 'permit debugging')
Copy link to clipboard
Copied
well, this is an output error it kinda has the location of the error but I'm not sure how to decode it's exact spot, heres the full error:
TypeError: Error #1006: value is not a function.
at _5_24_01_fla::MainTimeline/frame3()[_5_24_01_fla.MainTimeline::frame3:93]
at flash.display::MovieClip/gotoAndStop()
at _5_24_01_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame()[_5_24_01_fla.MainTimeline::frame2:14]
its a gotoAndStop frame, but something I still don't get is the variable number still doesn't show up when using the slider, I think I may have missed something big in the earlier code... I mean here look:
The first slider has the new code, the second only has the code I originally posted. I don't get why they don't respond to the code...
Copy link to clipboard
Copied
what's line 93, frame 3?
and which slider has the code i suggested? what's the min and max values of that slider?
Copy link to clipboard
Copied
frame 3 has no line 93, it does however have multiple layers with code, as each slider has its own layer, and the code for that slider is on that layer. So it could be the combined lines of the layers with code. Female Vairations has the code you suggested, and the other has just the basic code.
Copy link to clipboard
Copied
Oh and the I changed the min to 1 and the max to 6 on Female Vairations.
Copy link to clipboard
Copied
put all the code in the same layer and retest so you can find the line of code. or you'll need to add the lines from the (usually) top-most layer with code until you find line 93.
Copy link to clipboard
Copied
Okay, tried that, and the line that seems to be the one matching the output error is as follows:
Slider1.addEventListener(SliderEvent.CHANGE, onSlider1Click);
In context its just from your code above. So I'm not are why its not working...
Copy link to clipboard
Copied
above that line of code use:
trace(Slider1)
Copy link to clipboard
Copied
Okay, output error now reads
"
Female Vairations: 1
TypeError: Error #1006: value is not a function.
at _5_24_01_fla::MainTimeline/frame3()[_5_24_01_fla.MainTimeline::frame3:94]
at flash.display::MovieClip/gotoAndStop()
at _5_24_01_fla::MainTimeline/fl_ClickToGoToAndStopAtFrame()[_5_24_01_fla.MainTimeline::frame2:14]
"
and its since I added "trace(Slider1)" above line 93, 93 is now 94, and the error still comes from that line... Is it possible that I have a bug or there is a glitch in the slider component? According to my Creative Cloud there are no updates for Animate. There is a pending update for my Mac but I don't think thats a big factor... (currently running High Sierra (10.13.4) )
I could also upload the raw file to a link.... I don't know not sure what else I can do to get this code running.... But I'd really like to get it going... I suppose I could just use tiny buttons instead but Its a bit of a let down... The sliders save so much space and add such a fun aspect with them...
Copy link to clipboard
Copied
you have strings, not slider references in your array:
var mySlider1Array = ["Female Vairations: 0", "Female Vairations: 1", "Female Vairations: 2", "Female Vairations: 3", "Female Vairations: 4", "Female Vairations: 5"];
Find more inspiration, events, and resources on the new Adobe Community
Explore Now