To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Games

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-13-2007, 07:56 AM   #1
praful
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
praful is offline   Reply With Quote
Old 08-13-2007, 08:27 AM   #2
renderhjs
Student
 
Join Date: Apr 2001
Location: -
Posts: 4,756
please DON´T create multple threads on the same matter.
renderhjs is offline   Reply With Quote
Old 08-13-2007, 08:45 AM   #3
praful
Member
 
Join Date: Aug 2007
Posts: 34
Hi,
Sir

tell me How you make the balls fly out in differant directions?
praful is offline   Reply With Quote
Old 08-13-2007, 09:10 AM   #4
T1ger
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.
T1ger is offline   Reply With Quote
Old 08-13-2007, 09:24 AM   #5
Fall_X
crossconscious
 
Join Date: Sep 2005
Location: Belgium
Posts: 1,186
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.
__________________
www.crossconscious.com
Fall_X is offline   Reply With Quote
Old 08-13-2007, 09:53 AM   #6
praful
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.
praful is offline   Reply With Quote
Old 08-13-2007, 10:18 AM   #7
T1ger
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.
T1ger is offline   Reply With Quote
Old 08-13-2007, 10:34 AM   #8
renderhjs
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
renderhjs is offline   Reply With Quote
Old 08-13-2007, 10:39 AM   #9
praful
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;
}
};
praful is offline   Reply With Quote
Old 08-14-2007, 08:38 AM   #10
T1ger
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"+i, i); //(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.
T1ger is offline   Reply With Quote
Old 08-14-2007, 09:55 AM   #11
praful
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"+i, i); //(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.
praful is offline   Reply With Quote
Old 08-15-2007, 05:22 AM   #12
T1ger
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.
T1ger is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Games

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:06 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.