dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: I think I may need some assistance

  1. #1
    Senior Member
    Join Date
    Mar 2002
    Posts
    183
    Hello,
    I am making a movie that has a ball that randomly moves about the screen. I want it so that when you click it five times, it goes to frame 3. That's it. For some reason, it's not working. Maybe I have all the right script in all the wrong places. Here is my script.

    Main Timeline:
    Frame 1: num=0
    Frame 2: stop()
    Frame 3: stop()

    Ball Instance in Main Timeline:
    onClipEvent (enterFrame) {
    if (hit=1) {
    num+=1
    }
    if (num=5) {
    gotoandPlay(3);
    }
    }

    Ball Timeline:
    Frame 1: _x=250; _y=250;
    Frame 2:
    random1 = 2*Math.random()-1
    random2 = 2*Math.random()-1
    xvel = random1*10
    yvel = random2*10
    _x+=xvel
    _y+=yvel
    if (_x>=500) {
    _x+=-50
    }
    if (_x<=0) {
    _x+=50
    }
    if (_y>=500) {
    _y+=-50
    }
    if (_y<=0) {
    _y+=50
    }
    Frame 3:gotoandPlay(2);

    Invisible Button Instance on ball:
    on (release) {
    hit = 1
    }
    The ball moves around exactly how I want it. But, no matter how many times I click the ball, nothing happens. I am not sure what I am doing wrong. In theory, it seems like it shoudl work, but...nothing.
    I would really really appreciate any help.

  2. #2
    www.intensewd.com
    Join Date
    Apr 2002
    Location
    Australia
    Posts
    450
    hi

    i'm not sure if this will work, but in the as for your ball instance on main timeline..

    why not enclose the whole lot in a:

    while (num<5){
    do that other stuff;
    }

    Ben

  3. #3
    Senior Member
    Join Date
    Mar 2002
    Posts
    183
    yup, it worked, thanks a lot

  4. #4
    Senior Member
    Join Date
    Jan 2002
    Posts
    368
    minger, the main problem were your if statements.
    you were saying if(hit=1) etc.

    = is the assignment operater. you were making hit equal to 1.

    you want to say if(hit==1) which is the equality test operator

    a common mistake. (not that _I_ have ever made it! )

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