A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: filament particle animation (type error)

  1. #1
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    Question filament particle animation (type error)

    Hello,

    I am studying the behaviour of filaments in a fluid where the filament is approximated by a number of interconnected beads. For eacht timestep I got a text file containing coordinates from the simulating c-program. What I want to do now is visualize it using flash+AS3. I want to use AS3 to read coordinate datafiles I have, and to use these coordinates to create an animation in flash.

    This is what I have, although I get a 'type error' when I run it.
    TypeError: Error #1010: A term is undefined and has no properties.
    at display_fla::MainTimeline/frame1()
    I define my multidimensional coordinate arrays and the URLLoader.
    Code:
    var loader:URLLoader = new URLLoader();
    var xpos:Array = new Array();
    var ypos:Array = new Array();
    I push the one dimensional array onto my multidimensional array.
    Code:
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, loading);
    function loading (event:Event):void {
    xpos.push(loader.data.xpositions.split(","));
    ypos.push(loader.data.ypositions.split(","));
    }
    Here I call the loading function for each file I have (in this case onle test0.txt and test1.txt, later there will be much more).
    Code:
    for (var j:Number = 0; j < 2; j++){
    loader.load(new URLRequest("test"+j+".txt"));
    }
    So far I think I have created two multidimensional arrays, one for x versus the timestep and one for y versus the time step. Now I want to add MovieClips (of the bead) and move them around the screen according to the coordinate arrays.

    I make an array of movieclips (for testing I had restricted to just 10 beads)
    Code:
    var bead_:Array = new Array();
    
    //add enough beads
    for (var n:Number = 0; n < 10; n++) {
    bead_[n] = new bead();
    addChild(bead_[n]);
        }
    In this loop I intend to continuously change the positions of the beads on screen to create an animation, however, it's not working yet.
    Code:
    //move around
    for (var k:Number = 0; k < 2; k++){
    for (var i:Number = 0; i < 3; i++) {
    bead_[i].x = xpos[k][i];
    bead_[i].y = ypos[k][i];
        }
    }
    Thanks for any help!
    Last edited by supersybren; 06-13-2008 at 03:44 AM.

  2. #2
    Junior Member
    Join Date
    Feb 2000
    Posts
    19

    little update

    The txt files test0.txt and test1.txt look like this

    xpositions=2,4,5,6,4,3,2,3,4,5,4,3,4
    &ypositions=2,5,6,4,5,6,7,8,9,8,7,8,6
    The complete code. (It's all in the first frame of the flash movie)
    Code:
    var loader:URLLoader = new URLLoader();
    var xpos:Array = new Array();
    var ypos:Array = new Array();
    
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, loading);
    function loading (event:Event):void {
    xpos.push(loader.data.xpositions.split(","));
    ypos.push(loader.data.ypositions.split(","));
    }
    
    for (var j:Number = 0; j < 2; j++){
    loader.load(new URLRequest("test"+j+".txt"));
    }
    
    var bead_:Array = new Array();
    
    for (var n:Number = 0; n < 3; n++) {
    bead_[n] = new bead();
    addChild(bead_[n]);
    	}
    
    for (var k:Number = 0; k < 2; k++){
    for (var i:Number = 0; i < 3; i++) {
    bead_[i].x = xpos[k][i];
    bead_[i].y = ypos[k][i];
    	}
    }

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