A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Scores will not show up after load

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    5

    Scores will not show up after load

    I have a splash intro for my game. After you click play it loads like this

    loadMovieNum("game.swf", 1)
    stop();


    Then in the game, the score does not show up or work. Now when I load the game.swf by itself, the score works and shows up.

    Here is the script for score im using


    (Script for the number thats suppose to show)

    onClipEvent(load){
    score=0
    }


    (How you add the score after clicking right answer)

    on(press){
    _root.scorer.score+=1
    }


    Thanks for help!

  2. #2
    When you know are. Son of Bryce's Avatar
    Join Date
    Aug 2002
    Location
    Los Angeles
    Posts
    838
    Because you're loading in the swf from another file, the swf doing the loading is now the "_root". So when you refer to root, you're calling the loader shell file, where the score doesn't actually exist.

    Instead of using "_root" you can try using "this" or "_parent" until you reach the level where your variable exists.

    In AS2, which it seems you're using, it would go something like this...

    Code:
    on(press){
       this.scorer.score+=1
    }
    or

    Code:
    on(press){
       this._parent.scorer.score+=1
    }
    or

    Code:
    on(press){
       this._parent._parent.scorer.score+=1
    }
    until you reach the level where your score is. Not sure how many movieclips deep your button is nested.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    Quote Originally Posted by Son of Bryce View Post
    Because you're loading in the swf from another file, the swf doing the loading is now the "_root". So when you refer to root, you're calling the loader shell file, where the score doesn't actually exist.

    Instead of using "_root" you can try using "this" or "_parent" until you reach the level where your variable exists.

    In AS2, which it seems you're using, it would go something like this...

    Code:
    on(press){
       this.scorer.score+=1
    }
    or

    Code:
    on(press){
       this._parent.scorer.score+=1
    }
    or

    Code:
    on(press){
       this._parent._parent.scorer.score+=1
    }
    until you reach the level where your score is. Not sure how many movieclips deep your button is nested.

    Thanks for reply,

    I put in all three options but the score simply does not show up at all after loading the .swf file. I dont understand it

    onClipEvent(load){
    score=0
    }

    is it because its onClipEvent? Like said before, it works when I play it from the original file, but if loaded the score disappears!

  4. #4
    Member
    Join Date
    Apr 2014
    Posts
    51
    Did the scores already show up after loading? Have you tried using the ActionScript 3 for your game script?

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    Have you tried using the ActionScript 3 for your game script?
    AS3 wanted to be like Java so much, while AS1/2 were more like JavaScript. Now look where AS3 is and where JavaScript is But really, I made myself to love these closures, instead of making a class an/or method for everything. They could probably drop "this" keyword, and have JS still useable.
    who is this? a word of friendly advice: FFS stop using AS2

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