checking for the existence of a global variable, continuous play vs. single play (code included)

Ask a Question related to Macromedia Director Basics, Design and Development.

  1. #1

    Default checking for the existence of a global variable, continuous play vs. single play (code included)

    I have a director application that I'm working on. There's a version that's
    called "full play" that basically is a copy of the interactive portion, just
    linear. The client wants to also have the option of "continous play".

    My idea was to set a global variable when "continous play" was clicked so
    that when the person clicked the button, it'd just go to the full play
    frame, and go to the end, then just check at the end for the existence of
    the variable, and if it was set to on.

    I've got the button working fine, so that if you select "continuous" it sets
    a global variable called gContinuous and sets it equal to "on". When I'm in
    Full Play mode now and go to my message window, "ShowGlobals" returns my
    global all nice and pretty.

    Now, on the last frame of the full play, there's a bit of lingo that does
    the following:

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    go next
    end if
    end enterFrame

    What I'd LIKE to do is change that to something like this: (my addition in
    caps)

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    IF THE CONTINUOUS GLOBAL IS "ON" THEN
    go frame "full_play"
    ELSE
    go next
    END IF
    end if
    end enterFrame

    The error I get is that I'm trying to use the variable before it's defined,
    but I'm scoping it with "global.gContinuous"....(see actual code below)

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    if global.gContinuous = "on" then
    go frame "full_play"
    else
    go next
    end if
    end if
    end enterFrame

    Any ideas on what I might be doing wrong?


    Jeff Guest

  2. Similar Questions and Discussions

    1. fms ns.play(file, -2) Vs ns.play(stream, -2)
      Hi, I have a very strange problem. I have created an application on fms. on the streams/_definst_/instance directory there is a sample flv...
    2. Can't play local swf files, but web files play fine
      I installed Flash 9.0.16 on my pc, and I am trying to play swf files from my local drive. The files don't open in Internet Explorer, it's just a...
    3. Help with my form. Checking existence of variables
      I have a form which submits to another page. The submission page checks for the existence of some variables. If they don't exist it assigns a...
    4. play only if variable==true problem...
      Dear fellow Flashers, I'm trying to command flash, with a button on another level, to only play a keyframe, labeled "start_here" if it is at a...
    5. Help Please: 'Warning 5001 global variable "iF_timer" already defined in global scope
      Hi there, I have just started to get this error: 'Warning 5001 global variable "iF_timer" already defined in global scope The variable name...
  3. #2

    Default checking for the existence of a global variable, continuous play vs. single play (code included)

    I have a director application that I'm working on. There's a version that's
    called "full play" that basically is a copy of the interactive portion, just
    linear. The client wants to also have the option of "continous play".

    My idea was to set a global variable when "continous play" was clicked so
    that when the person clicked the button, it'd just go to the full play
    frame, and go to the end, then just check at the end for the existence of
    the variable, and if it was set to on.

    I've got the button working fine, so that if you select "continuous" it sets
    a global variable called gContinuous and sets it equal to "on". When I'm in
    Full Play mode now and go to my message window, "ShowGlobals" returns my
    global all nice and pretty.

    Now, on the last frame of the full play, there's a bit of lingo that does
    the following:

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    go next
    end if
    end enterFrame

    What I'd LIKE to do is change that to something like this: (my addition in
    caps)

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    IF THE CONTINUOUS GLOBAL IS "ON" THEN
    go frame "full_play"
    ELSE
    go next
    END IF
    end if
    end enterFrame

    The error I get is that I'm trying to use the variable before it's defined,
    but I'm scoping it with "global.gContinuous"....(see actual code below)

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    if global.gContinuous = "on" then
    go frame "full_play"
    else
    go next
    end if
    end if
    end enterFrame

    Any ideas on what I might be doing wrong?


    Jeff Guest

  4. #3

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    You must declare the global at the head of the script.

    global gContinuous
    > on enterFrame me
    > if sound(1).isBusy() then
    > go loop
    > else
    if gContinuous = "on" then
    > go frame "full_play"
    > else
    > go next
    > end if
    > end if
    > end enterFrame
    Andrew Morton
    Andrew Morton Guest

  5. #4

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    You must declare the global at the head of the script.

    global gContinuous
    > on enterFrame me
    > if sound(1).isBusy() then
    > go loop
    > else
    if gContinuous = "on" then
    > go frame "full_play"
    > else
    > go next
    > end if
    > end if
    > end enterFrame
    Andrew Morton
    Andrew Morton Guest

  6. #5

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    > The error I get is that I'm trying to use the variable before it's
    defined,
    > but I'm scoping it with "global.gContinuous"....(see actual code below)
    You need to declare it in any and every script you want to use them by
    putting a

    global gContinuous

    before you want to use them. Then you can just refer to it as plain old
    gContinuous. Foxed me at the beginning; I thought you only needed to do a
    'global gMyGlobalVariable' declaration once in a project, but no, you have
    to do it in every separate script...

    hth

    h


    h Guest

  7. #6

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    > The error I get is that I'm trying to use the variable before it's
    defined,
    > but I'm scoping it with "global.gContinuous"....(see actual code below)
    You need to declare it in any and every script you want to use them by
    putting a

    global gContinuous

    before you want to use them. Then you can just refer to it as plain old
    gContinuous. Foxed me at the beginning; I thought you only needed to do a
    'global gMyGlobalVariable' declaration once in a project, but no, you have
    to do it in every separate script...

    hth

    h


    h Guest

  8. #7

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    "h" <h@howiem.dontspam.meee.com> wrote
    > > The error I get is that I'm trying to use the variable before it's
    > defined,
    > > but I'm scoping it with "global.gContinuous"....(see actual code below)
    >
    > You need to declare it in any and every script you want to use them by
    > putting a
    >
    > global gContinuous
    >
    > before you want to use them. Then you can just refer to it as plain old
    > gContinuous. Foxed me at the beginning; I thought you only needed to do a
    > 'global gMyGlobalVariable' declaration once in a project, but no, you have
    > to do it in every separate script...
    >
    > hth
    >
    > h
    So...even if I declare it in the first frame of the movie, and set it = to
    "off". If I want to simply check for this variable later on someplace, I
    first need to declare it in the script that I'm going to check it in?

    So on my script:

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    if global.gContinuous = "on" then
    go frame "full_play"
    else
    go next
    end if
    end if
    end enterFrame

    all I need is to change it to this?:

    global gContinuous
    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    if global.gContinuous = "on" then
    go frame "full_play"
    else
    go next
    end if
    end if
    end enterFrame


    Jeff Guest

  9. #8

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    "h" <h@howiem.dontspam.meee.com> wrote
    > > The error I get is that I'm trying to use the variable before it's
    > defined,
    > > but I'm scoping it with "global.gContinuous"....(see actual code below)
    >
    > You need to declare it in any and every script you want to use them by
    > putting a
    >
    > global gContinuous
    >
    > before you want to use them. Then you can just refer to it as plain old
    > gContinuous. Foxed me at the beginning; I thought you only needed to do a
    > 'global gMyGlobalVariable' declaration once in a project, but no, you have
    > to do it in every separate script...
    >
    > hth
    >
    > h
    So...even if I declare it in the first frame of the movie, and set it = to
    "off". If I want to simply check for this variable later on someplace, I
    first need to declare it in the script that I'm going to check it in?

    So on my script:

    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    if global.gContinuous = "on" then
    go frame "full_play"
    else
    go next
    end if
    end if
    end enterFrame

    all I need is to change it to this?:

    global gContinuous
    on enterFrame me
    if sound(1).isBusy() then
    go loop
    else
    if global.gContinuous = "on" then
    go frame "full_play"
    else
    go next
    end if
    end if
    end enterFrame


    Jeff Guest

  10. #9

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    "Jeff" <jsmall@lhwh.com> wrote
    > So...even if I declare it in the first frame of the movie, and set it = to
    > "off". If I want to simply check for this variable later on someplace, I
    > first need to declare it in the script that I'm going to check it in?
    >
    > So on my script:
    >
    > on enterFrame me
    > if sound(1).isBusy() then
    > go loop
    > else
    > if global.gContinuous = "on" then
    > go frame "full_play"
    > else
    > go next
    > end if
    > end if
    > end enterFrame
    >
    > all I need is to change it to this?:
    >
    > global gContinuous
    > on enterFrame me
    > if sound(1).isBusy() then
    > go loop
    > else
    > if global.gContinuous = "on" then
    > go frame "full_play"
    > else
    > go next
    > end if
    > end if
    > end enterFrame
    Apparently so! Thanks for the help, worked like a charm.


    Jeff Guest

  11. #10

    Default Re: checking for the existence of a global variable, continuous play vs. single play (code included)

    "Jeff" <jsmall@lhwh.com> wrote
    > So...even if I declare it in the first frame of the movie, and set it = to
    > "off". If I want to simply check for this variable later on someplace, I
    > first need to declare it in the script that I'm going to check it in?
    >
    > So on my script:
    >
    > on enterFrame me
    > if sound(1).isBusy() then
    > go loop
    > else
    > if global.gContinuous = "on" then
    > go frame "full_play"
    > else
    > go next
    > end if
    > end if
    > end enterFrame
    >
    > all I need is to change it to this?:
    >
    > global gContinuous
    > on enterFrame me
    > if sound(1).isBusy() then
    > go loop
    > else
    > if global.gContinuous = "on" then
    > go frame "full_play"
    > else
    > go next
    > end if
    > end if
    > end enterFrame
    Apparently so! Thanks for the help, worked like a charm.


    Jeff Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139