A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: How to record movieclip position

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    5

    How to record movieclip position

    Dear Users,

    i try to make replay's in simply f1 flash game (car driving on some tracks). I wonder if You be so kind and help me with making replay’s in Flash (like in haxball). Ofcourse i don’t ask for fully soulution. I just ask if You can point me the corect way to make it.

    The only idea i have to do replay’s, is to record object (car) position on the track. But with 30fps and f.e. 15 minutes race i will have to get 27.000 data of X,Y position. It's huge information to send :/

    Is there any other possibility to make Replay’s?

    I will be appreciate for any sugestions.

    Regards
    AoW

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    you don't have to store every frame. check out splines.
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    p.s.
    27.000 data of X,Y position. It's huge information to send
    assuming 4 bytes per number, it is 211 KB. way less than typical jpeg image.
    who is this? a word of friendly advice: FFS stop using AS2

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    No idea how big it would be after 15mins @ 30 fps, realMakc suggests no bigger than a very small image file.
    But maybe this may be of some use??
    PHP Code:
    var TheX = [];
    var 
    TheY = [];

    function 
    GetPositions()
    {
        
    TheX.push(car._x);
        
    TheY.push(car._y);
        if (
    _root._currentframe == _root._totalframes)
        {
            
    clearInterval(GetPos);
            
    trace("X-Coords=[" TheX "]");
            
    trace(TheX.length);
            
    trace("--------------------");
            
    trace("Y-Coords=[" TheY "]");
            
    trace(TheY.length);
        }
    }
    GetPos setInterval(GetPositions33); 

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    not quite,
    PHP Code:
           trace("X-Coords=[" TheX "]"); 
    this would be quite large, because every number + its comma could easily be ~20 characters. what I had in mind was ByteArray, where you could use writeFloat() to use 4 bytes per number. then there is compress() to zip all bytes and get it even more compact.
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Junior Member
    Join Date
    Jul 2013
    Posts
    5
    Hi again,

    i'm back again and trying to save an array of X,Y to php. I made in flash

    var arrayexample=new Array();
    and

    onClipEvent (enterFrame) {
    arrayexample[myTimer.getMili()]= [int(track_x),int(track_y)];
    }

    I can see that in debug mode my arrayexample looks good. But when i'm trying to save this array in php file (i'm using: loadVariablesNummethod in flash, and php:

    $data = $_POST['arrayexample'];
    $file = "arrayexample.txt";
    $fp = fopen($file, "a");
    flock($fp, 2);
    fwrite($fp, $data);
    flock($fp, 3);
    fclose($fp);

    i get all undefined values and only the last are good.

    What i'm doing wrong?

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