If statement problem
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: If statement problem

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    12

    If statement problem

    I have 2 different movieclips named stain1 and stain2

    in stain1 there is a integer variable "val1" which is initially = 0
    in stain2 there is another integer named "val2" and its value is also = 0

    At the end of each movieclip, I set these values to "1"

    Now, in my main stage, I have "stop();" command for one of the layers and after this command there is a if statement which goes like;


    if(stain1.val1 == 1 && stain2.val2 == 1)
    {
    gotoAndPlay(2);
    }

    By this code what I want to do is after finishing the animations in both stain1 and stain2 movieclips, playing the main stage.
    But it doesn't work. I traced the val1 and val2 values, they becomes 1 however this if statement doesn't work. Even tried to write something like trace("test"), but even this message has not been traced.

    So, what might be the problem ?

  2. #2
    Junior Member
    Join Date
    Jan 2014
    Posts
    12
    Apparently the problem is that, this if statement is executed once at the very beginning and then it's done.
    What I need is checking it all the time. However, a simple while loop doesn't work as well.

  3. #3
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,033
    Hi,

    One of many ways of achieving this could be by using an onEnterFrame() , like so
    PHP Code:
    onEnterFrame = function ()
    {
        if (
    stain1.val1 == && stain2.val2 == 1)
        {
            
    delete onEnterFrame;
            
    gotoAndPlay(2);
        }
    }; 

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

Poll by Flashkit.com