We help IT Professionals succeed at work.

Flash 4 ActionScript not working as expected [75 points]

AlfaNoMore
AlfaNoMore asked
on
I have my Flash movie pulling some variables from an ASP page. The result of this ASP page is:

gstrText=%2D+LAUNCH+OF+NEW+TV+ADVERTISING+CAMPAIGN++%2D+Click+here&gstrLink=http%3A%2F%2Fwww%2Eaandl%2Dir%2Eco%2Euk%2Fnon%2Dhtml%2Floader%2Easp%3Fd%3Dinvestor%26p%3Dhistoric%2Dresults%2Easp%26s%3D2&gstrActive=True

Or:

gstrText = "- LANUCH OF NEW TV ADVERTISING CAMPAING  - Click here"
gstrLink = "http://www.aandl-ir.co.uk/non-html/loader.asp?d=investor&p=historic-results.asp&s=2"
gstrActive = "True"

Inside my Flash movie, I'm performing the following script on the very first frame:

Stop
Load Variables ("/non-html/news_box/flashVars.asp", 0)
Set Variable: "Looper" = 1
If (/:gstrActive ne "False")
      Go to and Play (2)
End If

BUT, for some reason, regardless of how many times I've reworked that IF statement, I can't get the movie to stop on it's current frame if gstrActive = False.

I've tried:

If (gstrActive = False): Stop
If (gstrActive = "False"): Stop
If (gstrActive eq False): Stop
If (gstrActive eq "False"): Stop
If (/:gstrActive eq "False"):Stop

Well, you get the idea. Can anyone please tell me how I should be scripting this statement so that the movie stops if gstrActive = False.

Thanks
Comment
Watch Question

Commented:
First of al, have you verified that the spelling is correct (including casing) of the variable AND of the value that is being passed on?

I think the problem is the following:
You say that you have the script (IF statement) on your first frame. You start your first frame with the "Stop" command, which means that the script on that page is run once and then no more. If you want to continuously check if the variable gstrActive has a certain value you have to make your movie loop over that frame continuously.
For example:

In your first frame:
Load Variables ("/non-html/news_box/flashVars.asp", 0)
Set Variable: "Looper" = 1
If (/:gstrActive ne "False")
     Go to and Play (3)
End If


And in your second frame:
Go to and Play (1)


As you can see, the variable is loaded. If the gstrActive has value "False" it will go to frame 3 and you can do what you want there. Otherwise it will not do anything and go on to frame 2. There it will return to frame 1 and check the value of the variable again.
Remember not to use the "Stop" command in your action script here...

Hope this helps...

BA

Author

Commented:
OK, I took your advice, and have this on frame 1:

Load Variables ("/non-html/news_box/flashVars.asp", 0)
Set Variable: "Looper" = 1
If (/:gstrActive ne "False")
      Go to and Play (3)
End If

This on frame 2:

Stop

And frame 3 is the movie proper.

I have checked the ASP page, and it is returning a variable named "gstrActive" and it's equal to "False".

So clearly [If (/:gstrActive ne "False")] should equal False, preventing [Go to and Play (3)] from happening, except it doesn't, it just goes straight into the movie!!! What is wrong with Flash?

Hi AlfaNoMore,

At the and of your asp-string, put a '&' so that the end of the string loks like:

...2Easp%26s%3D2&gstrActive=True&

When you don't, there is a possibility that flash detects a CrLf at the end of the value of gstrActive, and thats not the same as "True".

I think this would work.

When you have further questions, please feel free to ask.

Greetings,

Roy
Commented:
AlfaNoMore,

Like I said, do not use the STOP command.
Here is another try. This should work, I just tested it here....

In your first frame:
Load Variables ("/non-html/news_box/flashVars.asp", 0, vars=POST)


In your second frame, the if statement:
If (/:gstrActive ne "False")
  Go to and Play 3
Else
  Go to and Play 1
End If


In your third frame, the rest of the movie....
It is important that you use either the POST or GET method (1st frame), otherwise nothing happens....i mean, the value is not passed and in the if statement, gstrActive is empty (thus ne "False") and it will go to frame 3.
Make sure that the value that you pass on for the variable "gstrActive" (case sensitive) is exactly "False" (case sensitive).
Otherwise that statement will never be true, and it will go on to frame 3 no matter what you do.

Goodluck,

BA

Author

Commented:
Frame 1:
      Load Variables ("/non-html/news_box/flashVars.asp", 0, vars=POST)
      Set Variable: "Looper" = 1

Frame 2:
      If (gstrActive ne "False")
            Go to and Play (3)
      Else
            Go to and Play (1)
      End If

Frame 3 - 41:
      Rest of movie.

But, it's still not doing it's thing. I think it could be a caching problem. Even though I've cleared my local cache (while being off the page), I'm not seeing a change.

Author

Commented:
Hah, figured it out!!!

My first frame was laoding the variables, and the second frame was making a decision on those variables. Thing was, the variables hadn't laoded properly until about frame 5! So I've extended the distances between the laoding frame and the decision making frame, and it's now working.

I guess baltman kinda helped me on my way, so the points are going your way.

Cheers

Commented:
Thanks for that Alpha!
Hmm...I don't know why that is, but hey, if it's working....why not! Hehehe...

BA

Commented:
Thanks for that Alpha!
Hmm...I don't know why that is, but hey, if it's working....why not! Hehehe...

BA

Author

Commented:
although I'm still aving an awful time with file caching. Bo matter how many times I hit the refresh button, my changes don't get updated until I clear my cache?

Anything I can do within the movie itself? I've already got no caching within the HTML page?

Explore More ContentExplore courses, solutions, and other research materials related to this topic.