A Flash Developer Resource Site

Results 1 to 17 of 17

Thread: [Problem]: if (distX >= 390) { Its not workin!!

  1. #1
    Senior Member
    Join Date
    May 2005
    Posts
    223

    [Problem]: if (distX >= 390) { Its not workin!!

    I am using flash 8 and im making a space ship game, here is my problem . . . I have this bar at the bottum of the screen, its width is equal to distX and everytime I move to the write of the screen distX increases. This way I can tell how far I have moved. My problem is that I have this code and it wont work!!

    onClipEvent(enterFrame) {
    if(_root.distX >= 390) {
    _root.gotoAndStop("finish1",1);
    }

    I always have these problems with gotoAndStop on certain frames, im sure its just a smalle problem but if you have any suggestions please post!
    Thanks
    -Joey-

  2. #2
    Senior Member Gloo pot's Avatar
    Join Date
    Aug 2005
    Location
    Australia Mate!
    Posts
    874
    Try
    _root.gotoAndStop("finish1") I dont have a clue why the 1 is there.
    and make shore you have declaired _root.distx to 0 or somthing first because if you havent it will place numbers next to it istead of adding them EG
    Undeclaired = 11121
    declaired to 0 first = 6
    92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!

  3. #3
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Ya I have the distX working perfect, the bar grows and everthing. The reason why I have the 1 there is because I thought that meant, scene1 and frame 1 but oh well ill give it a try

  4. #4
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Man its still not working!

  5. #5
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Did you labeled the frame you want playhead to be sent as "finish1"?

  6. #6
    Razor
    Join Date
    Aug 2002
    Location
    Canada
    Posts
    721
    It should be:
    onClipEvent(enterFrame) {
    if(_root.distX._width >= 390) {
    _root.gotoAndStop("finish1",1);
    }

  7. #7
    my x booty it is that BIG
    Join Date
    Jun 2004
    Location
    New York
    Posts
    696
    he is using scenes i think thats why
    Project||[GAME]-on hold for now
    ------------------
    [Hero]-80%
    [Enemies]-1%
    [Weapons]-90%
    [Items]-0%
    [Levels]-10%

  8. #8
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Quote Originally Posted by chuckury
    It should be:
    onClipEvent(enterFrame) {
    if(_root.distX._width >= 390) {
    _root.gotoAndStop("finish1",1);
    }

    Well distX is the variable that the bar "distance" is based off of, Thanks anyways but I got it working, I just said gotoAndPlay(4); and because there is nothing there it goes to the next scene and the first frame of that scene has a stop action.

    thanks for the reply though!

  9. #9
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Quote Originally Posted by mixedtrigeno
    he is using scenes i think thats why

    Ya im using scenes, I dont know why but I always have problems with goto scenes lol

  10. #10
    my x booty it is that BIG
    Join Date
    Jun 2004
    Location
    New York
    Posts
    696
    well how about takingout your scenes and keeping it all in scene
    when it comes to games you dont need more then 1 scene unless u wanna make 1 scene for intro and 1 for the game just use the frames and pictur them as if they were scenes
    Project||[GAME]-on hold for now
    ------------------
    [Hero]-80%
    [Enemies]-1%
    [Weapons]-90%
    [Items]-0%
    [Levels]-10%

  11. #11
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Thanks guys! I have another problem with same game though if you feel like helping!
    My problem is this: I have a function (reset) on the enemy1 spaceship, so that everytime you kill it it comes back with different speeds and x y positions. When I finish the level and I goto a different scene then they are there moving across the screen and resetting, is there an action to cancel a function??

    function (reset) {
    stop;
    }

  12. #12
    do your smiles love u? slicer4ever's Avatar
    Join Date
    Dec 2005
    Location
    in a random occurance
    Posts
    475
    well not to my knowledge one but i always put this at the bottom of my enemy ship:
    code:

    if(_root._currentframe==3){
    // thats just the frame i usally go to after i beat it but you may also want to put an or in and repeat that with all frames
    this._y=999
    //this way you don't see them even though they may still be there although sometimes it seems to just go away if you put the one line of code other times it seems that you need to put them somewhere out of sight


  13. #13
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Thats a good idea, but then like that would make youre game run slower wouldnt it??

  14. #14
    do your smiles love u? slicer4ever's Avatar
    Join Date
    Dec 2005
    Location
    in a random occurance
    Posts
    475
    perhaps in the long run this only works for simple games but if your makeing something big youd probable be better off finding a better method
    edit: be back at most by 4 tommorow

  15. #15
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Its not working! I tired this for script but it wont work wtf!

    if (_root._currentframe=="gameOver") {
    this._y=600;
    }
    if (_root._currentframe=="finish1") {
    this._y=600;
    }
    I also tried this

    if (_root._currentframe==3) {
    this._y=600;
    }
    if (_root._currentframe==4) {
    this._y=600;
    }

  16. #16
    Senior Member
    Join Date
    May 2005
    Posts
    223
    Ok so I got this working lol but again I have another problem . . .

  17. #17
    Senior Member
    Join Date
    May 2005
    Posts
    223
    WHen I go to frame four after having the "distance" bar I was talking about earlier in this thread hitTest the "finish" mc wich is what I eneded up doing to make it work. Then in the fourth frame it will be the finish frame. It will take youre score and minus the (seconds x 100 + hour x 1000) it took you to get to the finish the level and give you that much cash. Here is my problem, I dont know how to get my timer to stop once I have finished the level so that I can calcualate everything. Here is the script for my timer.

    [QUOTE]millitime = getTimer()/60000-(int(getTimer()/60000));
    seconds = (int(millitime*60));
    mymin = (int(getTimer()/60000));
    if (Number(mymin)<1) {
    mintime = "00";
    } else {
    mintime = (int(getTimer()/60000));
    }
    minfield = mintime;

    If you have any qeustions about what im asking then please post and thanks for all the help you have given me and will hopefully give me!
    Thanks alot
    -Joey-

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