Drag and Drop
Sliders
It's easy to create a slider on the stage. It needs to be a draggable movie symbol with very narrow constrains for one of the axes.
Let's make an example close to previous.
- Make a dynamic text and give it an instance name sldText
- Create a movie symbol mvPanel
- Inside mvPanel draw the horizontal line – the dragging path. This line not necessary to be a symbol and should not be a part of any symbol except mvPanel
- While editing mvPanel find it's anchor point (cross) and adjust the left end of horizontal line to this cross
- Inside it create a mvHead - symbol of what you are going to be dragging
- Inside mvHead create a button – btHead
- Type the following script for the button.
on(press) { startDrag(this,true,0,0,100,0); } on(release) { stopDrag(); _root.sldText.text=this._x; }As our draggable symbol is inside mvPanel – constrains are under the mvPanel internal coordinates. If your mvPanel anchor is not at the start of the slider's slot-line the head will be dragged not according the line.You may see on our example slider x coordinate displayed – it is an important technique – since you may use those coordinate in animation by using them to assign the properties of other instances.
You 've noticed that we changed the text not by changing variables but by referring directly to the text properties of the TextArea instance.