A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: following a path in as3

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    21

    following a path in as3

    I've looked and looked but i cannot find any way of using as3 scipt to make a movieclip follow a path. ANY help on this topic would be incredibly useful.
    thanks

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Create a guideline and make it a MovieClip. Give it the identifier mc. Then create a Movieclip for the object you want to move. Give it the identifier cr. Get the rgb value from the line, in particular red, which I used here. In my case it is 248. Then add this script and test movie.

    PHP Code:
    var moveArray:Array = new Array();
    var 
    cr:Circle;
    var 
    counter:int 0;
    var 
    bmp:BitmapData = new BitmapData(mc.width,mc.height);
    bmp.draw (mc);
    for (var 
    i:int 0mc.widthi++)
    {
        for (var 
    j:int 1mc.height 1j++)
        {
            
    //var pixelValueString:String = bmp.getPixel32(i,j).toString(16);
            
    var pixelValue:uint bmp.getPixel32(i,j);
            var 
    red:uint pixelValue >> 16 0xFF;
            if (
    red == 248)
            {
                
    moveArray.push ({xpos:i,ypos:j});
            }
        }
    }
    var 
    intervalId:uint setTimeout(myDelayedFunction,100);
    function 
    myDelayedFunction ():void
    {
        
    cr = new Circle();
        
    cr.moveArray[0].xpos;
        
    cr.moveArray[0].ypos;
        
    addChild (cr);
        
    moveObject (moveArray);
    }
    function 
    moveObject (mArray):void
    {
        var 
    moveArray:Array = mArray;
        var 
    myTimer:Timer = new Timer(10,moveArray.length);
        
    myTimer.addEventListener (TimerEvent.TIMERtimerFunction);
        
    myTimer.start ();
        function 
    timerFunction (e:TimerEvent):void
        
    {
            
    cr.moveArray[counter].xpos mc.x;
            
    cr.moveArray[counter].ypos mc.y;
            
    counter++;
        }

    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    21
    thanks alot i like your way of doing it im gonna have a try and build this in

  4. #4
    Junior Member
    Join Date
    Jul 2009
    Posts
    1
    I think this is exactl what I need, and I can get it to work if I remove the fact that it's a circle,and just a path with only distinct X values.. and many Y values..

    I get an error when I compile this..

    1046: Type was not found or was not a compile-time constant: Circle
    1180: Call to a possibly undefined method Circle..

    I tried in AS2, and other errors popped up...

    and,I tried to do a :
    import flash.display.Shape;

    but, that didn't do it eithere..

    any help? or thoughts?/

    Manson

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