Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : Please help! Simple question on Image Slider


newbee2004
3/27/2004 9:07:44 PM
In the library, I have a movie clip - DraggableButton that has OnPress with
StartDrag with parameters and OnRelase with StopDrag. I have a slider with this
Draggable button and a bar to slide the button on. I also have two movie clips
Clip1 and Clip2.
In my main movie I have two instances MC1 and MC2 of Clip1 an Clip2. I have an
instance of the Slider.
I want to set the _alpha property of MC1 and MC2 depending on the location of
the button on the slider.
I think I need to save the location (_x) of the button on the slider in a
variable in the OnRelease even of DraggableButton and use this variable in the
SetProperty method.
I need to know in which event and which object's event should I use the
SetProperty method. Or if what I am thinking is not correct what do I need to
do?
I know though this is hard for a newbee like me, it is not very hard for you
Gurus. Please help!
Thank you very much.

kglad
3/27/2004 10:54:57 PM
how many draggable things are on your slider? is there just one draggable and
you want to set the _alpha of mc1 and mc2 simultaneously? ie, they'll always
have the same _alpha. or is there a draggable button who's position will
determine which movieclip's _alpha (mc1 or mc2) your slider will control?
newbee2004
3/27/2004 11:14:41 PM
There is only one draggable object on my slider. When the user drags that
button, I want alpha values of both MC1 and MC2 to be reset to different
values. Basically I am trying to fade one away and make the other more visible
depending on the direction.
Thank you.
kglad
3/28/2004 1:36:56 AM
newbee2004
3/28/2004 4:27:05 AM
The slider is horizontal. When it is at left most position, MC1 has alpha 100
and MC2 0. At the right most position MC1 has 0 and MC2 has 100. With motion
tween one fades into another. Can you give me the answer already?
kglad
3/28/2004 3:22:38 PM
slidebar.DraggableButton.onPress = function() { //where slidebar is the name
of your movieclip that contains DraggableButton
if (firstTime == undefined) {
firstTime = 0;
startx = this._x;
starty = this._y;
}
this.startDrag(0, startx, starty, startx+slidebar._width-this._width, starty);
alphaI = setInterval(alphaF, 100, startx, startx+slidebar._width-this._width);
};
slidebar.DraggableButton.onRelease = slidebar.slider.onReleaseOutside=function
() {
this.stopDrag();
clearInterval(alphaI);
};
function alphaF(l, r, x) {
mc1._alpha = (slidebar.DraggableButton._x-l)*100/(r-l);
mc2._alpha = 100-mc1._alpha;
}
AddThis Social Bookmark Button