Solved

Redirect a flash-based website depending on URL entered in browser address bar?

Posted on 2011-03-11
4
379 Views
Last Modified: 2012-05-11
Hi There,

Is it possible to redirect a user to a specific portion of a Flash-based website (a Flash movie) depending on the url entered in the address bar?

For example, let's say I have a few sections within the Flash-based site (Home, About Us, Contact Us).  If somebody types in thecompany.com, then the browser loads the site normally--showing the homepage area of the Flash movie.  If somebody types in thecompany.com/about--the Flash movie would load the About Us page of the Flash movie.  

I was thinking I would need to do something with the default page at thecompany.com/about that send the user to the page with the embedded flash movie and that would add some params at the end of the url which would be read by Actionscript, and would trigger the correct loading of content within the Flash movie, but is that the right approach?

Please, let me know if you have ever done this, and the best way to go about handling that.

Thanks!

0
Comment
Question by:ariestav
  • 2
  • 2
4 Comments
 
LVL 20

Expert Comment

by:Mark Brady
Comment Utility
I would say you are on the correct path. Add something like "loc=about" into the URL and use actionscript to get the location (loc) from the URL. Then you can do an "if" statements to find out what that value is and can direct them to the correct scene in the movie.
0
 
LVL 4

Author Comment

by:ariestav
Comment Utility
What ActionScript would I use to analyze the URL?
0
 
LVL 20

Accepted Solution

by:
Mark Brady earned 250 total points
Comment Utility
Me and flash don't have a very good friendship sorry. I'm not good with flash/actionscript. I just googled how to retrieve a URL and this is what I found. Use flashVar property like so to get the URL.

var flashvars = {
  browserURL: escape(location.href)
};
Once you have that you need to do something similar to javascripts "indexOf()" function to find location of "loc=" for example. Here's some logic for you. If you used "loc=1" or "loc=2" the numbers could represent locations in your flash movie. If they click "contact" it might represent "4" for eg so "index.php?loc=4" would mean they want the contact page. Look for the position of "loc=" then if found, add 5 to the first number and that would be the position of the number we need. Get that number then you will know where the user wants to go so with a simple if statement you set which scene to go to based on which number was found.

I can't do the action script for you, only the logic behind it. Google will be your best bet I imagine. Of course all this is assuming you have a different page on each scene (eg: scene1 is the home page, scene2 is the products page etc...)
0
 
LVL 4

Author Closing Comment

by:ariestav
Comment Utility
I suppose I was looking for some actionscript code, by my question implied a general direction for a solution, and you provided that.

Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
The viewer will learn how to count occurrences of each item in an array.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

762 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

5 Experts available now in Live!

Get 1:1 Help Now