FLASH get url and if equal gotoandstop frame

Im trying to get flash ActionScript 2 to read the current url and if it has say ?page=Meeting on the end of it it would goto and stop on a frame number i.e 40
martin69Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

courtthreeCommented:
Cool, what kind of page does the flash movie appear in? Is it ASP.NET or PHP or something else? Have you already dealt with the issue of extracting the name value pairs from the url and getting that into the HTML of the page?
0
martin69Author Commented:
Php index.php

If you can do it with php that will be fine
0
courtthreeCommented:
OK, what's your site structure? Is it a single dynamic movie that you need to have the url talk to? That is, the same page is called several times but with a different name value pair?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

martin69Author Commented:
the site structure consists of one php file index.php the flash movie does not talk to anything at present in php. it has roll over buttons that change the picture in the middle. but what i would like it to do is have an if statement that is ?page=Metting it would jump to say frame 40 and stop.
0
courtthreeCommented:
OK, there are two main ways to get the PHP and the Flash talking to each other (which is what you'll need to do if you want the Flash movie to read and react to the URL). The first is a LoadVars function and the second FlashVars. What method have you used to embed your Flash movie? Is it Adobe's run active content js or, perhaps, swfobject? Either way, we need to introduce FlashVars and I'll run you through that when you let me know your embedding method.
0
martin69Author Commented:
think its object. but not sure so code below. thanks

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="840" height="316">
              <param name="movie" value="flash/photos.swf">
              <param name="quality" value="high">
          <embed src="flash/photos.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="840" height="316"></embed></object>
0
courtthreeCommented:
OK, do you know how to use the name value pair from the url in the html page? I'm not a PHP man but it is probably something like this:

<? echo $_GET['page'] ?>

This probably needs a clean up but that will be the essence of it. Notice that 'page' corresponds with the name of the name value pair in your url: ?page=Meeting

So, as you can see, that's nothing to do with Flash at the moment. You need your PHP page to do some work first, interpreting the url for you.

Now, to pass that value into Flash using the OBJECT tag you have above, we must add a FlashVar to it. See the code snippet attached below.

Again, in this snippet, I have used the potentially dodgy PHP marker from above but, assuming you're comfortable with PHP, it will be easy for you to correct if its wrong!

The code snippet is a duplication of yours, but with two key things added which act as a bridge for your Flash movie and your PHP application. The first new line is:

<param name="FlashVars" value="varFromPHP=<? echo $_GET['page'] ?>">

This adds your FlashVar to the OBJECT part of the tag. Then, second:

FlashVars="varFromPHP=<? echo $_GET['page'] ?>"

This adds your FlashVar to the EMBED part of the tag. They are replications of each other but are required in both circumstances (such is the Betamax / VHS world we live in ;-)

Now, when you run your Flash movie in that PHP page, it will have a variable available to it called varFromPHP. Now you can use this in your original actionscript condition:

if (varFromPHP == "Meeting") {
    gotoAndStop(10);
};

Note: varFromPHP is not a special keyword and is simply the name I chose for illustrative purposes. You can change that to whatever you like. I avoided the use of the variable name "page" as something like that can often trip you up by being a reserved keyword in PHP or Flash. I've lost many hours of my life chasing silly problems like that around an app!!!

Feel free to come back to me with any further questions mate.


<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="840" height="316">
    <param name="movie" value="flash/photos.swf">
    <param name="quality" value="high">
    <param name="FlashVars" value="varFromPHP=<? echo $_GET['page'] ?>">
    <embed src="flash/photos.swf" quality="high" FlashVars="varFromPHP=<? echo $_GET['page'] ?>" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="840" height="316"></embed>
</object>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
martin69Author Commented:
brilliant. works a treat. also if i double the points can i ask you this questioned too.

I have 3 pictures that fade on then after so many seconds fade on to another one.

how do i use xml to have one fade on and wait time line but it does it for how ever many items are listed in the xml in AS2

0
courtthreeCommented:
Well there's many, many ways to accomplish this! Tell me, have you already imported the references to the images via the XML? If so, have you loaded them into an array?
0
martin69Author Commented:
Hi no i have not imported or implemented an xml reference file to pictures yet. not sure where to start.
0
courtthreeCommented:
One other thing, how are the images managed? Will you manage them or do you have a scenario where third parties are uploading them etc?

If you're managing them, a simple text file that you can easily update will do the job. Let me now and write something out for you.
0
martin69Author Commented:
Hi, I have managed to do it in the end but thanks for the help with the phph and flash vars a great help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.