Solved

Flash reads param from html

Posted on 2008-06-23
3
318 Views
Last Modified: 2013-11-11
Hi Experts

I am new to Flash.  I am creating a flash animation which will be a banner across the top of a standard HTML page.

I want the flash to detect what page is showing, then display different text depending on the page.  For example if the user is on the 'about us' page, flash will detect that and display the words 'about us' in a flash movie.

Ideally Flash would read a param from the HTML head of the page.

How is that done?
0
Comment
Question by:willnjen
  • 2
3 Comments
 

Author Comment

by:willnjen
ID: 21852052
Actually, thinking about it...I need to display a different image depending on the page.

So same as my initial description, Flash would read a param from a header, then display an image relevant to the page.

Cheers

Will
0
 
LVL 18

Accepted Solution

by:
Antonio Estrada earned 500 total points
ID: 21852166
Ok, first of all, I'm going to recommend using swfobject. A fantastic JavaScript that lets you add swf movies in a really easy way. Get it here: http://blog.deconcept.com/swfobject/

This is how you would use it:

<code>

Ok, so if we break down the HTML, we can see a bunch of things.

1. We have an "alternate" content to display if the user viewing your website does not have Flash Player installed, you can add a link there to Adobe's website or whatever.
2. The var so = new SWFObject ... has a bunch of arguments, in order of appearance, we have the following:
   " Movie path: A string to the path of your movie (in my example it's "myFlashMovie.swf")
   " Name: The title of your movie - not that important actually (in my example it's "Movie")
   " Width: The width of your movie as a string ("723" in my example)
   " Height: The height of your movie as a string ("600" in my example)
   " Version: The Flash Player version required to play the movie, again as a string ("8" in this example)
   " Background color: The background color to use... ("#FFFFFF", white in my example)
3. After the declaration of the initial values of our movie, we can add them some variables to play with in our Flash movie, that's accomplished with the addVariable() method.
   In my example, I'm creating a variable named currentPage and giving it a value of "aboutUs". You can add as many variables as you wish.
4. In the end, we write the Flash movie in the browser with the write() method.

Ok... so that's it for the HTML part, now let's move on to the Flash part.

The currentPage variable will exist in the _root of your movie. From there you can do simple things like check on the first frame the value of the variable and from there... do something like gotoAndPlay(); or whatever you choose to do. Mind you, you won't be able to test it on the Flash environment unless you create the variable for testing purposes and then delete it (otherwise this won't work).

Let's say that we'll go to different frames of the movie depending on the value of currentPage. If so; we'd do something like this:

// ActionScript - Frame 1

if(currentPage=="aboutUs") {
   gotoAndPlay(10);
} else if(currentPage=="index") {
   gotoAndPlay(15);
} else if(currentPage=="differentThings") {
   gotoAndPlay(20);
} else {
   //do nothing
}

Something along these lines will do the trick. If you need further assistance, please let me know.

-V
<HTML>

<HEAD>

<TITLE>My Webpage</TITLE>

<script type="text/javascript" src="./swfobject.js"></script>

</HEAD>

<BODY>

<div id="flashcontent">

      <p>Here you type your normal html if the user doesn't have Flash Player installed. It can be a table or whatever.</p>

</div>

<script type="text/javascript">

      // <![CDATA[

      var so = new SWFObject("myFlashMovie.swf", "Movie", "723", "600", "8", "#FFFFFF");

      so.addVariable("currentPage","aboutUs");

      so.write("flashcontent");

      // ]]>

</script>

</BODY>

</HTML>

Open in new window

0
 

Author Closing Comment

by:willnjen
ID: 31470031
Hi Vulturous

So sorry I didn't get back to the this earlier.  Thanks for your brilliant answer!!

Will
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Does Flash have a Firefox problem? 5 312
flash cs6 4 344
Google Chrome - Where is "Enable Resource Tracking" 2 11,545
Flash builder 4.13 list scroller does not work 1 37
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now