A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: on enterframe makes the balls fly out in differant directions from the Stage center

  1. #1
    Member
    Join Date
    Aug 2007
    Posts
    34

    on enterframe makes the balls fly out in differant directions from the Stage center

    Hi,

    Gude me to on enterframe makes the balls fly out in differant directions from the center of the Stage.

    ThankX.

    Praful

  2. #2
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    please DON´T create multple threads on the same matter.

  3. #3
    Member
    Join Date
    Aug 2007
    Posts
    34
    Hi,
    Sir

    tell me How you make the balls fly out in differant directions?

  4. #4
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    You could just use ANGLE = Math.random*360; beware that this is in degrees, you probably need to convert it to radians to use in Math.cos and sin, just look in flash help for how to do that.
    I don't have a photograph, but you can have my footprints. They're upstairs in my socks.

  5. #5
    crossconscious
    Join Date
    Sep 2005
    Location
    Belgium
    Posts
    1,188
    Quote Originally Posted by praful
    Hi,
    Sir

    tell me How you make the balls fly out in differant directions?
    By getting someone to kick your scrotum real hard.

    Seriously mate, you post two threads on the same topic, someone points out ttat that's not appropriate behaviour, and you tell them - not ask them politely, no, you tell them - to explain something to you.

  6. #6
    Member
    Join Date
    Aug 2007
    Posts
    34

    Sorry for the language that i used.

    Quote Originally Posted by Fall_X
    By getting someone to kick your scrotum real hard.

    Seriously mate, you post two threads on the same topic, someone points out ttat that's not appropriate behaviour, and you tell them - not ask them politely, no, you tell them - to explain something to you.
    Sorry for the language that i used.
    i tryed, to do it of my own, one movieclip in moving,but remaing duplicates are not changing there angles and not moving.

    Thanks.
    Praful.

  7. #7
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    Then posting what you have done usually helps, because then you show that you actually have tried. Also post the code you have written, then maybe we can help you rewrite it so it works
    I don't have a photograph, but you can have my footprints. They're upstairs in my socks.

  8. #8
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    we are NOT here to do other´s work, come with something that can be discussed about like T1ger suggested.
    It propably will a onEnterFrame event and some trigonometry- but lets first show us what you got

  9. #9
    Member
    Join Date
    Aug 2007
    Posts
    34
    Hi,
    T1ger

    this is the code:

    stop();
    speed = .2;
    angle = 0;
    raj.onEnterFrame = function() {
    speed += speed;
    angl++;
    xpos = Math.cos(speed);
    ypos = Math.sin(speed);
    for (p=1; p<=6; p++) {
    this["raj"+p]._rotation = angl;
    this["raj"+p]._x += xpos;
    this["raj"+p]._y += ypos;
    }
    };

  10. #10
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    I guess you have dragged 6 movieclips onto the stage and named them raj1 - raj6? Alternative to this is to create them dynamically. Right click on the MC in the library, and click "linkage", choose export for actionscript, and write "ball" in the identifier input field, then ok.

    then you can put this in first frame:
    PHP Code:
    stop();
    startX Stage.width/2//where the balls start, x-value
    startY Stage.height/2//where the balls start, y-value
    ballNum 6//this is how many balls we will have
    speed 2//the speed of the balls
    for (i=0;i<ballNum;i++) { //create the balls
        //attach the MC to the stage and store it temporary in the variable ball
        
    ball attachMovie("ball""ball"+ii); //(linkage name, new name ball0, ball1, etc, and depth i)
        //Put the ball in the middle of the stage
        
    ball._x startX;
        
    ball._y startY;
        
    //Make a random angle for each ball, in radians. Degrees goes from 0-360 degrees, radians is the same, it just goes from 0-2*PI, or 0-6.28.
        //Math.random() returns a number between 0 and 1.
        
    ball.angle Math.random()*Math.PI*2;
        
    //set the x and y-speed for this ball
        
    ball.xSpeed Math.cos(ball.angle);
        
    ball.ySpeed Math.sin(ball.angle);
    }
    this.onEnterFrame = function() {
        
    //loop through all balls
        
    for (i=0;i<ballNum;i++) {
            
    //put the ball in a temporary variable "ball"
            
    ball this["ball"+i];
            
    //add xspeed and yspeed to the _x and _y variable
            
    ball._x += ball.xSpeed;
            
    ball._y += ball.ySpeed;
        }

    Try to understand this, I have commented everything
    I don't have a photograph, but you can have my footprints. They're upstairs in my socks.

  11. #11
    Member
    Join Date
    Aug 2007
    Posts
    34

    Thanks for the help.

    Quote Originally Posted by T1ger
    I guess you have dragged 6 movieclips onto the stage and named them raj1 - raj6? Alternative to this is to create them dynamically. Right click on the MC in the library, and click "linkage", choose export for actionscript, and write "ball" in the identifier input field, then ok.

    then you can put this in first frame:
    PHP Code:
    stop();
    startX Stage.width/2//where the balls start, x-value
    startY Stage.height/2//where the balls start, y-value
    ballNum 6//this is how many balls we will have
    speed 2//the speed of the balls
    for (i=0;i<ballNum;i++) { //create the balls
        //attach the MC to the stage and store it temporary in the variable ball
        
    ball attachMovie("ball""ball"+ii); //(linkage name, new name ball0, ball1, etc, and depth i)
        //Put the ball in the middle of the stage
        
    ball._x startX;
        
    ball._y startY;
        
    //Make a random angle for each ball, in radians. Degrees goes from 0-360 degrees, radians is the same, it just goes from 0-2*PI, or 0-6.28.
        //Math.random() returns a number between 0 and 1.
        
    ball.angle Math.random()*Math.PI*2;
        
    //set the x and y-speed for this ball
        
    ball.xSpeed Math.cos(ball.angle);
        
    ball.ySpeed Math.sin(ball.angle);
    }
    this.onEnterFrame = function() {
        
    //loop through all balls
        
    for (i=0;i<ballNum;i++) {
            
    //put the ball in a temporary variable "ball"
            
    ball this["ball"+i];
            
    //add xspeed and yspeed to the _x and _y variable
            
    ball._x += ball.xSpeed;
            
    ball._y += ball.ySpeed;
        }

    Try to understand this, I have commented everything




    Hi T1ger

    this script works exectly i wanted to, Thakns once again for your help.


    do you suggest any book or any article on the net to developed the scripting skill

    Thanks once again!

    Regards.
    Praful.

  12. #12
    Feeling adventurous? T1ger's Avatar
    Join Date
    Mar 2004
    Posts
    850
    Read the readme-thread http://board.flashkit.com/board/showthread.php?t=513006 if you havent already, and google tonypa, and read his excellent tile tutorials. They learn you making tile-based games, but also syntax and scripting
    I don't have a photograph, but you can have my footprints. They're upstairs in my socks.

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