Skip to main content
Participating Frequently
June 29, 2015
Answered

Using a Slider to Change Actionscript Value in a Movie Clip

  • June 29, 2015
  • 1 reply
  • 956 views

Hey everyone,

I'm trying to use a slider's position to control values in this code:

video.filters = [MatrixUtil.setBrightness(sliderAValue),

                     MatrixUtil.setContrast(sliderBValue),

                     MatrixUtil.setSaturation(sliderCValue)];

The code above resides within a Movie Clip, but I want the sliders in the main scene.  They don't have to be custom.  I'm fine using the sliders in Flash's library.  It seems OOP is the way to go, but I don't know much about it right now.  If anyone could explain this to me in detail, I would greatly appreciate it. 

Thanks.

This topic has been closed for replies.
Correct answer kglad

Ahh okay.  I was on the right track then.  I had that same code (with a different function name) but didn't realize I had to call it in the movie clip.  I have this code on the main timeline to get the value of one slider.


import flash.events.Event;

// Enter Frame Event

var sliderValue:uint = mySlider.sliderKnob.x;

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(event:Event):void {

  sliderValue = mySlider.sliderKnob.x;

  status_txt.text = "pos is" + sliderValue;

  MovieClip(parent).changeFilterF(sliderValue); //I JUST ADDED THIS

}

I haven't debugged yet, but I'll let you know how it goes.


that's not good coding because you're unnecessarily using system resources in an endless enterframe loop for something that can be done much more efficiently.

in addition, it won't work.

if you use a slider component you can use a change event.  if that's your custom slider you can probably use a mouseup event:

mySlider.sliderKnob.addEventListener(MouseEvent.MOUSE_UP,sliderchangeF);

function sliderchangeF(e:MouseEvent):void{

theinstancenameofyourfiltercontainingmovieclip.changeFilterF(mySlider.sliderKnob.x);

}

and change changeFilterF to

function changeFilterF(sliderValue):void{

video.filters = [MatrixUtil.setBrightness(sliderValue),

    MatrixUtil.setContrast(0),

    MatrixUtil.setSaturation(0)];

}

1 reply

kglad
Community Expert
Community Expert
June 29, 2015

does  the movieclip that contains that code lie on the main timeline?

if so, you can use parent.sliderAValue to reference sliderAValue on the main timeline.  likewise with the other values.

Participating Frequently
June 29, 2015

No.  All of the Movie Clip's code is contained within itself.  There is no Actionscript on the main timeline. 

kglad
Community Expert
Community Expert
June 29, 2015

is that movieclip on the main timeline?