A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [F8] Code not working.

  1. #1
    Im a rag doll
    Join Date
    Apr 2006
    Posts
    26

    [F8] Code not working.

    I have a Movie in which bullets are to be fired by the Ctrl key press. But this is not happening. Can I get help on this please!
    Code:
    var vel=20;
    var vx;
    var vy;
    var rt=0;
    var fr=0;
    var i=0;
    turret.onEnterFrame=function(){
    if(Key.isDown(Key.UP)){	
    rt++;
    }
    if(Key.isDown(Key.DOWN)){
    rt--;
    }
    if(Key.isDown(Key.CONTROL)){
    fr=1;
    }else{
    fr=0;	
    }
    turret._rotation=rt;
    }
    if(fr==1){
    ballm=_root.attachMovie("ball", "ball"+i, 100+i,{_x:300,_y:200});
    i++;
    }
    ballm.onEnterFrame=function(){
    if(fr==1) {
    vx = vel*Math.cos(rt*Math.PI/180);
    vy = vel*Math.sin(rt*Math.PI/180);
    ballm._x+=vx;
    ballm._y+=vy;
    }
    }
    stop();
    also attached the FLA (F8)
    Attached Files Attached Files
    Let us be friends.

  2. #2
    Im a rag doll
    Join Date
    Apr 2006
    Posts
    26

    Nobody to help!

    I've been shifted to page:2
    Nobody to help!
    Let us be friends.

  3. #3
    When in doubt ask Eager Beaver's Avatar
    Join Date
    Feb 2007
    Location
    Planet Earth
    Posts
    911
    I don't know the answer. let's hope somebody cares to help you.
    Last edited by Eager Beaver; 04-21-2007 at 02:18 AM.
    <signature removed by admin>

  4. #4
    Im a rag doll
    Join Date
    Apr 2006
    Posts
    26
    I am sorry nobody including the moderators care to look into my problem.
    What's wrong with my code?
    I have included the code as well as the FLA.
    Can I conclude it's a waste of time to post a thread in these forums.
    Let us be friends.

  5. #5
    Member
    Join Date
    Dec 2006
    Posts
    52
    don't be so demanding/whiney.

    its very hard to understand your code, as the variable names are abstract and not self explanatory like they should be, also your code formatting is horrible which makes it a mission to read through.

    so yes it is a waste of your time to post a thread in these forums if your going to DEMAND others go out of their way to wade through illegible, uncommented code.

    A hint for the future is to make your question concise and to the point, instead of "please help me make my game work". for example, you could cut out all the code that makes the turret move up and down, as that has nothing to do with the problem, and post a small excerpt of the code where you have found error.

  6. #6
    Im a rag doll
    Join Date
    Apr 2006
    Posts
    26
    No error is reported in the code.
    The turret is rotating, but the balls are not getting attached in the root and they are not moving, when the Ctrl key is pressed.
    Let us be friends.

  7. #7
    I'm curious
    Join Date
    Feb 2007
    Location
    world
    Posts
    37
    Hi! Pinky,
    Please try the modified/corrected code.
    Code:
    var vel=20;
    var vx;
    var vy;
    var rt=0;
    var i=0;
    turret.onEnterFrame=function(){
    turret._rotation=rt;
    if(Key.isDown(Key.UP)){	
    rt++;
    }
    if(Key.isDown(Key.DOWN)){
    rt--;
    }
    if(Key.isDown(Key.CONTROL)){
    ballm=_root.attachMovie("ball","ball"+i,100,{_x:300,_y:200});
    i++;
    }
    ballm.onEnterFrame=function(){
    vx = vel*Math.cos(rt*Math.PI/180);
    vy = vel*Math.sin(rt*Math.PI/180);
    this._x+=vx;
    this._y+=vy;
    }
    }
    stop();
    Don't hate! Love!

  8. #8
    Im a rag doll
    Join Date
    Apr 2006
    Posts
    26
    Thank you very much Tormenter!
    I have used the modified/corrected code posted by you, and the movie is working perfectly OK!
    Let us be friends.

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