A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Failure to Run

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    6

    Question Failure to Run

    I am writing a RPG battle program in Flash. I haven't gotten very far but I am stuck on part. Each time I test the program, I get this error:

    Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
    at Battle_fla::MainTimeline/Battle_fla::frame1()

    The code looks like this:
    PHP Code:
    var hp1:int 100;
    var 
    hp2:int 75;
    var 
    hpdr:int 500;
    var 
    hpgi:int 200;
    var 
    attack1:int 15;
    var 
    attack2:int 5;
    var 
    attackdr:int 30;
    var 
    attackgi:int 20;
    var 
    defence1:int 10;
    var 
    defence2:int 5;
    var 
    defencedr:int 20;
    var 
    defencegi:int 10;
    var 
    magic1:int 5;
    var 
    magic2:int 15;
    var 
    magicdr:int 20;
    var 
    magicgi:int 0;
    var 
    spirit1:int 5;
    var 
    spirit2:int 10;
    var 
    spiritdr:int 15;
    var 
    spiritgi:int 5;*/
    var 
    spd1:int 5;
    var 
    spd2:int 10;
    var 
    spddr:int 2;
    var 
    spdgi:int 4;
    var 
    mp1:int 15;
    var 
    mp2:int 50;
    var 
    mpdr:int 30;
    var 
    mpgi:int 0;*/
    var 
    monster:int 2;
    var 
    time1:int 0
    var time2:int 0
    var timedr:int 0
    var timegi:int 0

    if (monster == 1) {
        
    Dragon.280
        Dragon
    .80
    }
    else if (
    monster == 2) {
        
    Giant.280
        Giant
    .80
    }
    while (
    hp1 >= || hp2 >= 1)
    {
    time1 +spd1
    time2 
    +spd2
    timedr 
    +spddr
    timegi 
    +spdgi

    while (time1 >= 100) {
        var 
    mag:int 0;
        if (
    mag == 0) {
            
    Atk.10
        Atk
    .5
        mag
    ++
        }
    time1 0
        
    }
        
    hp1 0

    Is it failing because of the insane number of variables? Because of the while loops? In any event assistence would be quite welcome.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    You can test that by deleting certain parts of the script.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Your immediate problem...in your while loop you are waiting for both of your hp values to drop below 1, but you never change the value of hp2, it remains at 75 forever.

    On a grander scale, that type of programming is going to get really messy really fast. Try using Objects for each of your monsters and attaching all those attributes as object properties. Then tuck each monster object into an array so you can automatically keep a count of how many mobs are in play. The goal should be writing code that can be used more flexibly and can be repeated for different circumstances.

  4. #4
    Junior Member
    Join Date
    Mar 2008
    Posts
    6
    I tested it, and it has something to do with the main while loop. I am just unsure what.

  5. #5
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Quote Originally Posted by neznein9
    in your while loop you are waiting for both of your hp values to drop below 1, but you never change the value of hp2, it remains at 75 forever.

  6. #6
    Junior Member
    Join Date
    Mar 2008
    Posts
    6
    The original idea of the while loop was that it would loop, increasing time counters until it was someones turn. Once it was there turn, you would have a button based menu that let you pick your attacks and spells and stuff. Once your turn was over it would go back and loop until it was another person's turn.
    It probably is a fairly inefficient system but it's the best I have been able to come up with. I am quite unfamiliar with action script and this is only my third project using it. Could you please explain what an object is, and how to assign values to them. Any help you could give me with the code would be most helpful. Thank you for the information you have already provided, but I don't really know any other way of doing 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