# Is this Possible?

**URL:** <https://forum.kirupa.com/t/is-this-possible/327376>\
**Category:** Uncategorized\
**Created:** [February 25, 2012, 2:22pm UTC](https://forum.kirupa.com/t/is-this-possible/327376 "2012-02-25T14:22:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeponkz](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@jeponkz](https://forum.kirupa.com/u/jeponkz)\
**Post date:** [February 25, 2012, 2:22pm UTC](https://forum.kirupa.com/t/is-this-possible/327376/1 "2012-02-25T14:22:42Z")

</div>

```auto

map:PathMap = new PathMap();

btnShowPath.addEventListener(MouseEvent.CLICK, onClick)

function onClick (e:MouseEvent)
{
    switch (btnShowPath.label) {
           case "Path One":
                    map.showPath(tlPath1) //pass the value into the PathMap class so that the TimelineMax tlPath1 will play
                       break;

                case "Path Two":
                    map.showPath(tlPath2) // pass the value into the PathMap class so that the TimelineMax tlPath2 will play
                       break;

             default:
             break;
        }
}

```

```auto
package {
    import flash.display.MovieClip;
    import com.greensock.*;
    import flash.display.Shape;
    import fl.transitions.TransitionManager;
    import flash.events.MouseEvent;
    import flash.events.Event;
    

    public class PathMap extends MovieClip 
    {
        private var line:Shape;

        private var tlPath1:TimelineMax;
        private var tlPath2:TimelineMax;
    
        public function PathMap()
        {
                line = new Shape();
                addChild(line);

                mc1.x = p1.x;
                mc1.y = p1.y;
    
                tlPath1= new TimelineMax( { paused:true, onUpdate:drawLine } );
                tlPath1.appendMultiple([
                TweenLite.to(mc1, 1, {x:p2.x, y:p2.y}),
                TweenLite.to(mc1, 1, {x:p3.x, y:p3.y}),
                TweenLite.to(mc1, 1, {x:p4.x, y:p4.y}),
                TweenLite.to(mc1, 1, {x:p5.x, y:p5.y})
                ], 0, TweenAlign.SEQUENCE);

                               tlPath2= new TimelineMax( { paused:true, onUpdate:drawLine } );
                tlPath2.appendMultiple([
                TweenLite.to(mc1, 1, {x:p2.x, y:p2.y}),
                TweenLite.to(mc1, 1, {x:p3.x, y:p3.y}),
                TweenLite.to(mc1, 1, {x:p6.x, y:p6.y}),
                TweenLite.to(mc1, 1, {x:p7\.x, y:p7.y})
                ], 0, TweenAlign.SEQUENCE);

                            function drawLine():void
                {
                    line.graphics.lineTo(mc1.x, mc1.y);
                }

                 }

                 private function clearLines():void
        {
            line.graphics.clear();
            //start new line at first point
            line.graphics.lineStyle(5, 0xFF0000, 1);
            line.graphics.moveTo(p1.x, p1.y)    
        }

                public function showPath(tl:String):void
                {
                     clearLines()
                     tl.restart() // Not Working ERROR..
               } 

```

I know the Error. the showPath function has the parameter tl that will tell which TimelineMax will play, but it is a String… he can’t have the function of restart because restart() is a function of TimelineMax…

but when I change the function of showPath into

public function showPath():void  
{  
clearLines();  
tlPath1.restart(); // this will work, but only tlPath1 will play  
}

and I will change the case

switch (btnShowPath.label) {  
case “Path One”:  
map.showPath()  
break;

```
            case "Path Two":
                   map.showPath() // only tlPath1 will play.
                   break;

         default:
         break;
    }

```

any idea how to solve this problem??
