• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Question on Variable Syntax

New Here ,
Apr 03, 2009 Apr 03, 2009

Copy link to clipboard

Copied

Hi.

I am trying to get a variable to load into my flash movie from the html page in which it is located.

In the Object tag I am placing:
<param name="movie" value="images/navigation.swf?Section=about" />
In the Embed tag I am placing:
src="images/navigation.swf?Section=about"

In the first frame of the Actions layer of my movie I have:
stop()
baseRate = 12;
thisPage = Section;

In the movie clip from which I am calling the variable I have:
onClipEvent(load) {
if (thisPage = about){
this._alpha = 100;
}else{
this._alpha = 0;
}
}

The movie is recognizing that there is an conditional statement but is not passing the variable. I am assuming my syntax at least is incorrect someplace.
Thank you.
TOPICS
ActionScript

Views

541

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 03, 2009 Apr 03, 2009

Copy link to clipboard

Copied

MikiNack,

At this point ...

> <param name="movie" value="images/navigation.swf?Section=about" />

... you're passing in a string. The string instructs Flash to define a
variable named Section and set its value to the (string) value "about". So
far, so good.

> In the movie clip from which I am calling the variable I have:
> onClipEvent(load) {
> if (thisPage = about){

There are two issues here. First, you're checking to see if thisPage
equals about -- but that word, "about", isn't in quotes, which means it
isn't a string. But the variable you passed in is a string, so you'll need
to wrap the word "about" in quotes. In addition to that, you'll need to use
the equality operator (==), instead of the equals sign. In ActionScript,
the equals sign *sets* a value to something, while the double equals sign
*checks* if one value matches another.

onClipEvent(load) {
if (thisPage == "about") { ...

See the difference?

While you're at it, honestly ... you may as well just check for the
original variable name you passed in, Section. It doesn't hurt anything to
set thisPage = Section in previous code, but it doesn't help anything,
either. You can skip the "thisPage = Section" line and simply change your
on() code to look like this:

onClipEvent(load) {
if (Section == "about") { ...


David Stiller
Co-author, Foundation Flash CS4 for Designers
http://tinyurl.com/dpsFoundationFlashCS4
"Luck is the residue of good design."


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 06, 2009 Apr 06, 2009

Copy link to clipboard

Copied

Thank you - I will give this a try.

MN

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 08, 2009 Apr 08, 2009

Copy link to clipboard

Copied

Still not working.

Here is what I have in the flash:

onClipEvent(load) {
    if (section == "about"){
        this._alpha = 100;
    }else{
    this._alpha = 0;
    }
}

On the page I have:

<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="400" id="test" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="test.swf?section=about" />

<param name="quality" value="high" />

<param name="bgcolor" value="#ffffff" />

<embed src="test.swf?section=about" quality="high" bgcolor="#ffffff" width="550" height="400" name="test" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>

When I publish the test - the _alpha is 0 so Flash is reading the conditional statement. But the variable "about" is not being passed at all.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2009 Apr 09, 2009

Copy link to clipboard

Copied

LATEST

I think I have it working now - I changed it to this:

onClipEvent(load) {
    if (_level0.section=="about"){
        this._alpha = 100;
    }else{
    this._alpha = 0;
    }
}

adding the '_level0' did the trick - now I will try it in my real application!

MikiNack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines