Solved

Flash reads param from html

Posted on 2008-06-23
3
322 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

ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Array is not working ( AS2 ) 4 152
free flash maker 5 212
Shouldn't i be able to use an old win xp machine as an internet radio? 7 124
Actionscript in Flash 3 61
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…

777 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