A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: how to make slider control nested movieclips?

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    6

    how to make slider control nested movieclips?

    I'm using AS3, CS5.5, on Windows764bit.

    I created an animation with many different layers (and nested movieclips) on the stage, then wrote a short bit of As3 to add a slider control of the playback.

    The problem/mystery is that when I change the slider, the nested MCs act strangely/independently.

    Any advice on how to control everything at once?

    here is the current file:
    http://oregonstate.edu/instruct/dce/...349-Growth.swf

    here is the code I added:
    Actionscript Code:
    package {
    import flash.display.*;
    import fl.controls.*;
    import fl.events.*;
    import flash.text.*; //for TLF crap
       
     public class SliderClip extends MovieClip {
      var slider:Slider;
           
        public function SliderClip() {
        var tf:TextFormat = new TextFormat();
            tf.font = "Arial";
            tf.bold = true;
            txtBox2.defaultTextFormat = tf;
            slider = new Slider();
            slider.setSize(200,0);      //set size of slider
            slider.move(50,700);        //position slider
            slider.liveDragging = true;     // control if slider updates instantly or after mouse is released
            slider.maximum = totalFrames;
            addChild(slider);
                slider.addEventListener(SliderEvent.THUMB_DRAG, slideHandler);
                slider.addEventListener(SliderEvent.THUMB_RELEASE, slideRelease);
                addEventListener(Event.ENTER_FRAME, slideFrame);
            }
        private function slideHandler(event:SliderEvent) {
            gotoAndStop(event.target.value);
            }
        private function slideRelease(event:SliderEvent) {
            play();
            }
        private function slideFrame(event:Event) { //moves slider to match current frame
            slider.value = currentFrame;
            if (slider.value == totalFrames){stop();}
            txtBox2.text = String(slider.value);
            }
        }
    }

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You probably have the MCs in individual frames controlled by the slider. Am I correct? Once the slider has reached a frame with an MC, this MC will play.
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center