Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 25

Thread: Draw with Flash

  1. #11
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    1. The bouncing effect needs angular movement (so, if I say it to bounce along the 30 deg it should bounce along the 30 degree line)
    I'm not 100% sure what you mean. If you wan't some sort of 3D movement, that's not going to be possible with mc_tween. You need a 3D engine -- PaperVision, Sandy3D...something like that.

    But, if you're just talking about 2D movement. You'll need to figure out the math...but I image if you tween both the x and y axis at the same time and the same distance, you'll achieve what you want. Look into the slideto() method of mc_tween.

    2. I need the bouncing to stop whenever I create a new line.
    A couple of ways to do that -- stopTween(), onTweenComplete(), onTweenUpdate()

    3. I need to draw the line and make the registration point in the middle. (in other words when I hit rotate it should rotate along the center. It does that now but its a little bit off.)
    There is no way to change the registration point with ActionScript. Take a look at the following pages for some options:

    http://www.kirupa.com/forum/showthread.php?t=70919
    http://www.actionscript.org/forums/s...nt+dynamically
    Last edited by Medyman; 04-03-2008 at 02:56 PM.

  2. #12
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thank you
    Last edited by neo_philiac; 04-07-2008 at 02:38 PM.

  3. #13
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    One more thing


    take a look at this function: (Its in the script)
    Code:
    /*  On press bounces the shape */
    
    		bounce_Button.onRelease = function() {  
    
    		
    		var gravity = 100;
    		var floor = tmp_mc._y+200;
    		var Vy = 0;
    		//tmp_mc._y = 40;
    
    		tmp_mc.tween = function() {
    		
    		Vy += gravity;
    		tmp_mc._y += Vy/4;
    
    		if (tmp_mc._y > floor) {
    		tmp_mc._y = floor;
    		Vy = -Vy;
    	}
       }
    		
     }
    How can i make it frame independent? So, I can either make it bounce for a certain period of time (in a for loop) but i encounter the problem of running slideTo() on both direction at the same time. Its not like I can slide the line to X direction and the come back for a certain time. How do I do it?

    I was abel to do it by putting -- tmp_mc.tween = function() {

    But I cant stop it with stopTween().


    Please help.

  4. #14
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    OK i have been able to do that this way,

    Code:
    bounce_Button.onRelease = function() {  
    while (i<=2){
    		
    		tmp_mc.slideTo((tmp_mc._x+100),undefined,1);
    		
    		tmp_mc.onTweenComplete = function(){
    			
    			tmp_mc.slideTo((tmp_mc._x-100),undefined,1);
    			
    				tmp_mc.onTweenComplete = function(){
    			
    				tmp_mc.stopTween();
    				}
    		}
    		i=i+1;
    	}
    }
    But ! without the while loop. If put the while loop, it crashes. It says it cant run the script. What am i doing wrong?

  5. #15
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    It crashes because you're running a while loop inside of the for loop. So you're actually doing everything 2 or 3 times (depending on how your for loop is set up).

    What's your reason for using the while loop? It looks like an if statement would be better used here.

  6. #16
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks Medyman for all your replies. The answer is simple. I want to setup the time for iterated bounce. At this point without the while loop there is only one cycle. Say I want it to bounce for 10 sec. Thats is!

    Thanks again!

  7. #17
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Quote Originally Posted by neo_philiac View Post
    Thanks Medyman for all your replies. The answer is simple. I want to setup the time for iterated bounce. At this point without the while loop there is only one cycle. Say I want it to bounce for 10 sec. Thats is!

    Thanks again!
    Ahh, I see. In that case, I would probably use a function that would keep track of how many times the function has run and keep running it until the limit is set.

    Maybe something like this:

    Code:
    var bounced:Number = 0;
    function bounce(limit) {
        if (bounced< limit) {
             bounced++;
            // Bounce Tween with 1 second 
            mc.onTweenComplete = function() { bounce(limit) };
        }
        else { trace ("limit expired") };
    }
    If you're only doing it once, you can get rid of the passed limit variable and just hard code the value, otherwise you can pass it dynamically. The limit would be how many times you want the function to run. So if you're doing 1 tween per second and want to run it for 10 seconds, the limit would be 10. If the tween is .5 seconds, the limit would be 20, etc...

    You could also use a setInterval() that does pretty much the same thing as above.

    Be sure to clear the "bounced" variable the first time you run it.

    With this, I'm assuming you want the tween to run over and over again for a period of 10 seconds, not that one tween should run for 10 seconds.

    Note: I just wrote the code above in the browser. There are probably some mistakes but the logic should work.

  8. #18
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Thanks but am I doing something wrong? Its not working - here is what i did

    Code:
    /*  On press bounces the shape */
    
    	bounce_Button.onRelease = function() {  
    	
    	var bounced:Number = 0;
    	var limit:Number = 10;
    	
        function bounce(limit) {
        if (bounced< limit) {
             bounced++;
            // Bounce Tween with 1 second 
    		
    		tmp_mc.slideTo((tmp_mc._x+100),undefined,1);
    		
    		tmp_mc.onTweenComplete = function(){
    			
    			tmp_mc.slideTo((tmp_mc._x-100),undefined,1);
    			
    				tmp_mc.onTweenComplete = function(){
    			
    				tmp_mc.stopTween();
    				}
    		}
    		
            tmp_mc.onTweenComplete = function() { bounce(limit) };
        }
        else { trace ("limit expired") };
    }

  9. #19
    Join Date
    Jul 2006
    Posts
    139
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Default

    Medyman I need help!!!

  10. #20
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Post your .fla in it's current state and I'll have a look. It's impossible to get a sense of what's going on with just that small snippet.

    There's nothing explicitly wrong in that code block. Whatever is happening is because of its interaction with the rest of your code.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •