A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: move movie clips around on y axis

Threaded View

  1. #1
    Senior Member
    Join Date
    Oct 2009
    Posts
    112

    [RESOLVED] move movie clips around on y axis

    have two sets of movie clips.
    I'm communicating to these movie clips with another program via binary sockets.
    For the first set of movie clips: when it recieves its instance name, and a second number (InstanceName+#) from the socket, the named movie clip will jump to the frame corresponding with that number. for ex:
    if the incoming data from the socket is (mc7+3), then movieclip 7 will jump to frame 3.

    For the second set of movie clips: when it recieves its instance name, and a second number (InstanceName+#) from the socket, the named movie clip will move location across the screen, by the y coordinate moving to the # given by the socket...thats a little confusing. for ex:
    if the incoming data from the socket is (mc4+500), then movieclip 4 will move so that it's y coordinate is at 500.

    Here is my code:
    Code:
    var socketBuffer:String = "";
    s.addEventListener(ProgressEvent.SOCKET_DATA, onDATA);
    function onDATA(e:ProgressEvent):void{
      var d:String=s.readUTFBytes(s.bytesAvailable);
      socketBuffer = socketBuffer.concat(d);
      var tokens:Array = socketBuffer.split(".");
      var done:Boolean = false;
      while (tokens.length > 1 && !done){
        var token:String = tokens.shift();
        if (!processToken(token)){
           socketBuffer = token;
           done = true;
        }
      }
      if (!done){
        socketBuffer = tokens.shift();
      }
    }
    
    function processToken(token:String):Boolean{
    	var tempBoolean:Boolean;
            var embeddedNums:Array = token.split('+');
    	if (!embeddedNums  || (embeddedNums.length < 2)){
    		tempBoolean=false;
    	}
    	var clipName:String = embeddedNums[0];
    	var frameIndex:int = Number(embeddedNums[1]);
            if (this[clipName]){
      	  this[clipName].gotoAndStop(frameIndex);
    	  tempBoolean = true;
            }
    		if (this[clipName==FADER.name]){
    		this[clipName].y=(frameIndex);		
    	}
    return tempBoolean;
    }
    i got rid of some errors. the first part is working where the movie clips jump to the frame they are told to so no errors there. but when i try to move the movie clips in reference to the FADER array, (along the y axis) nothing happens. (look at bold part of code) this is pretty confusing so let me know if u need more explanation

    theres also another method i'm willing to approach but i'm not sure how to go about it. rahter than using the FADER array, I would rewrite the code for each individual movie clip, so that it says "if incomign data names a movie clip and gives a number, change the named movie clip's y coordinate to the incoming number"
    Last edited by mattwatts15; 11-20-2009 at 10:24 AM. Reason: change title

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