Skip to main content
Inspiring
November 16, 2012
Question

slider to control the loaded swf

  • November 16, 2012
  • 1 reply
  • 939 views

Hi,

I have created the slider manually,i am not using the component, once the swf loaded (animation swf), the slider start moving, when i drag and drop the slider the loded swf should go and stop to the particular keyframe.can any tell me where i am going wrong,and loaded swf animations are inside the movieclip(home_mc)

this is my code,

var lmt_rect:Rectangle = new Rectangle(-56,-30,122,0);

menubutton.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,startdrag);

menubutton.slider_mc.addEventListener(MouseEvent.MOUSE_UP,stopdrag);

menubutton.slider_mc.addEventListener(Event.ENTER_FRAME,startmove);

function startmove(e:Event)

{

    menubutton.slider_mc.x=((currentSWF.currentFrame/currentSWF.totalFrames)*100)-47;

}

function startdrag(e:Event)

{

    menubutton.slider_mc.startDrag(true,lmt_rect);

    menubutton.slider_mc.removeEventListener(Event.ENTER_FRAME,startmove);

}

function stopdrag(e:Event)

{

    menubutton.slider_mc.stopDrag();

    menubutton.slider_mc.addEventListener(Event.ENTER_FRAME,startmove);

  currentSWF.gotoAndPlay(currentSWF.currentFrame);

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
November 16, 2012

:

paramF(currentSWF,lmt_rect.x,1,lmt_rect.x+lmt_rect.width,currentSWF.totalFrames);

function stopdrag(e:Event){

    menubutton.slider_mc.stopDrag();

    menubutton.slider_mc.addEventListener(Event.ENTER_FRAME,startmove);

currentSWF.gotoAndPlay(frameF(menubutton.slider_mc.x));

}

function frameF(x:Number):int{

return Math.round(x*currentSWF.m+currentSWF.b);

}

function paramF(mc:MovieClip,x1:number,y1:Number,x2:Number,y2:Number):void{

mc.m=(y1-y2)/(x1-x2);

mc.b=y1-mc.m*x1;

}

Inspiring
November 16, 2012

when i drag and drop that slider the (animation is playing from starting) the swf is loding from begining,can you tell me why it is happening

kglad
Community Expert
Community Expert
November 16, 2012

you have to wait until loading is complete before using the slider and you have to execute the following when loading is complete.

paramF(currentSWF,lmt_rect.x,1,lmt_rect.x+lmt_rect.width,currentSWF.to talFrames);