Skip to content

Commit c993ec2

Browse files
committed
Animation on sliders
1 parent e30e388 commit c993ec2

1 file changed

Lines changed: 42 additions & 14 deletions

File tree

sliderMenu/SliderManager.as

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ package sliderMenu
5959

6060
private static var manageMenusFrames:Boolean;
6161

62-
private static var moveItByStageRepositioning:Boolean;
62+
private static var onlyFrameAnimation:Boolean;
6363

6464
/////////////////////////////////// numerical variables↓
6565
/**this variable tells the number of the accepted pixel from the stage */
@@ -306,17 +306,23 @@ package sliderMenu
306306

307307

308308
var currentMenu:MovieClip = addGetSlider(currentDraggingPose,null,0,true);
309-
if(currentMenu!=null && //!currentMenu.hitTestPoint(myStage.mouseX,myStage.mouseY,true))
309+
if(
310+
currentMenu!=null
311+
/*&&
312+
onlyFrameAnimation==false */
313+
&& //!currentMenu.hitTestPoint(myStage.mouseX,myStage.mouseY,true))
310314
(
311-
currentDraggingPose == LEFT_MENU
312-
&&
313-
currentMenu.mouseX>0
314-
)
315-
||
316-
(
317-
currentDraggingPose == RIGHT_MENU
318-
&&
319-
currentMenu.mouseX<0
315+
(
316+
currentDraggingPose == LEFT_MENU
317+
&&
318+
currentMenu.mouseX>0
319+
)
320+
||
321+
(
322+
currentDraggingPose == RIGHT_MENU
323+
&&
324+
currentMenu.mouseX<0
325+
)
320326
)
321327
)
322328
{
@@ -485,17 +491,37 @@ package sliderMenu
485491
{
486492
cprecent = Math.min(obj.totalFrames,Math.ceil(Math.min(1,deltaPose.length/deltaW)*obj.totalFrames));
487493
}
488-
obj.gotoAndStop(cprecent);
494+
495+
496+
if(onlyFrameAnimation)
497+
{
498+
if(cprecent<obj.currentFrame)
499+
obj.prevFrame();
500+
else if(cprecent!=obj.currentFrame)
501+
obj.nextFrame();
502+
}
503+
else
504+
obj.gotoAndStop(cprecent);
489505
}
490506
else
491507
{
492-
obj.gotoAndStop(1);
508+
if(onlyFrameAnimation)
509+
{
510+
obj.prevFrame();
511+
obj.prevFrame();
512+
}
513+
else
514+
obj.gotoAndStop(1);
493515
}
494516
}
495517

496518
if(!moveStage)
497519
{
498520
var pose:Point = addGetSlider(allPose[i],null,0,false,true);
521+
if(onlyFrameAnimation)
522+
{
523+
deltaPose = new Point();
524+
}
499525
if(currentDraggingPose == allPose[i])
500526
{
501527
obj.x += ((pose.x+deltaPose.x)-obj.x)/animSpeed ;
@@ -572,11 +598,13 @@ package sliderMenu
572598
/**set up a slider menu for the stage on selected position and with yourMenu<br>
573599
* you have only one stage*/
574600
public static function setMenu(yourMenu:MovieClip,deltaSlide:Number,menuPosition:String = LEFT_MENU,
575-
manageFrames:Boolean=true,moveTheStage:Boolean=true,moveItByStageRepositioning:Boolean=true)
601+
manageFrames:Boolean=true,moveTheStage:Boolean=true,moveItByStageRepositioning:Boolean=true,onlyFrameAnimationVar:Boolean=false)
576602
{
577603
lock_flag = true ;
578604
moveStage = moveTheStage ;
579605
manageMenusFrames = manageFrames ;
606+
onlyFrameAnimation = onlyFrameAnimationVar ;
607+
manageFrames = manageFrames || onlyFrameAnimation ;
580608
if(moveItByStageRepositioning)
581609
{
582610
StageManager.eventDispatcher.addEventListener(StageManagerEvent.STAGE_RESIZED,moveMenuseAgain);

0 commit comments

Comments
 (0)