A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS2.0 maintain object through frames.

  1. #1
    Junior Member
    Join Date
    Jan 2008
    Posts
    1

    AS2.0 maintain object through frames.

    Hey guys,

    This is my first post here so I will try to outline my issues. I am trying to develop a texas holdem demonstation game, basically play hands in front of someone. Deals 2 hands and finds a winner. I have got all of the above done, making it button driven. IE, click 1 button and it calls 4 functions in order and all works fine. The issue I face now is, I want to make my flash driven using frames. IE:

    Frame 1: deals players cards
    Frame 2: deals communical cards
    Frame 3: finds the winner.

    I initalise my objects in frame one, but as soon as it moves to the next frame the objects initialised in frame one are cleared.

    I have one frame which spands frames 1-4 with the following code

    ///////////////////////////////////////// code start ///////////////////////

    //stop();
    import pokerCard
    import pokerDeck
    import pokerGame
    import pokerPlayer
    var cardWidth:Number = 50;
    var cardHeight:Number = 70;

    var allCardsToRemove:Array=new Array();
    var rake:Number = 0;
    var rakeback:Number = 0;
    var pot:Number = 0;
    var myPokerGameokerGame=new pokerGame(2);
    var layerCounter:Number


    function dealCommonCards()
    {
    //do stuff;
    }

    function dealPlayerCards()
    {
    myPokerGame.clearHands();
    myPokerGame.dealGame();
    //do stuff;
    }

    function findWinner()
    {
    //do stuff;
    }

    ///////////////////////////////////////// code end ///////////////////////

    How do I make it so that the objects declared up the top are static to the entire flash movie. Because at the moment I am getting "Undefined" errors and I assume this is because the objects are not remaining initalised as it moves from one frame to another.

    Any help would be greatly appreciated.

    For bonus helping points, can someone then tell me the best method to make this cycle so I can maintain some variables when dealing the next hand. IE
    Var playerMoney = 100;
    Frame 1: playerMoney = 100;
    Frame 2: playerMoney = 150;
    Frame 3: playerMoney = 200;
    Frame 1: playerMoney = 200 (not intialised again)

    I figure the best way would be to initalise everything in frame 1, and then have a loop from frames 2 - 4 (where frame 4 gos to frame 2, but need this to be confirmed)

    Thanks guys again.

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    _global.playerMoney = 100;

    Then you can access that variable from every frame by calling "_global.playerMoney".

  3. #3
    Junior Member
    Join Date
    Jan 2008
    Posts
    1
    Does this mean I can use this _global attribute on all objects to make them static for the entire flash movie? I will give this a shot tonight! Thanks mate.

  4. #4

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