views:

167

answers:

3

Hi folks,

I've got a situation where I have a visitor arriving at a php page with a ID key. They then navigate to page 2 where they key id is carried along in a querystring variable.

i.e. http://www.mysite.com?x=abcde12345

Page 2 has a flash video on it - that is playing a movie. Once the movie stops playing I want flash to redirect to page 3 - bringing the querystring along with it, as page 3 needs to use the querystring to look up a database value.

I used to have this working great in older flash with GetURL - but need it in AS3 now. I've searched for quite awhile on it - and I can see how to redirect with a querystring - but can't see how to redirect with a dynamic querystring - and i'm pretty lost when it comes to flash.

Any ideas?

Thank you.

Update: I'm not sure where I am going wrong here.

Here is my HTML code

<script>
document.write('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'); document.write('codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"');
document.write('WIDTH="550" HEIGHT="400" id="movie" ALIGN="">');
document.write(' <PARAM NAME=movie VALUE="Movie-test.swf">');
document.write(' <PARAM NAME=FlashVars VALUE="x='+toPage+'">');
document.write(' <PARAM NAME=quality VALUE=high>');
document.write(' <PARAM NAME=bgcolor VALUE=#FFFFFF>');

document.write('<EMBED src="Movie-test.swf"');
document.write('    FlashVars="x='+toPage+'"');
document.write('    bgcolor=#99CC33 WIDTH=550 HEIGHT=400 ');
document.write('    TYPE="application/x-shockwave-flash">');
document.write('  </EMBED>');
document.write(' </OBJECT>');
</script>

And my AS3 code

var params:Object = this.loaderInfo.parameters;
var id:String = params.x;

//then after the movie completes

function onComplete(event:Event):void
{
   var page3URL:String = "page2.php?" + "x=" +id;
   navigateToURL( new URLRequest( page3URL ) );
}

The video just loops and replays on itself.

What I've got is layer 1 has the movie, up to frame 2993. I created Layer2, and on Layer 2 - frame 2993 I inserted a keyframe - and put the above as3 script.

Can you see where I'm going wrong?

Thank you.

A: 

I would add the ID key using php to the Flashvars property then use

LoaderInfo(this.root.loaderInfo)
to extract it inside Flash, then append the key to the redirect string.

Also look at the ExternalInterface class.

daidai
+1  A: 

You have two option:

1. Loading the ID into your flash using flashvars.

Here is a tut on this http://www.permadi.com/tutorial/flashVars/index.html then var nexturl:URLRequest = new URLRequest("http://www.domain.com/page3.php?id="+id); navigateToURL(nexturl,"_self");

or

2. Calling a Javascript function from inside flash

just make a small redirect function in HTML

function nextPage(){ }

and from inside flash

var temp:Object = ExternalInterface.call("nextPage");

Joseph Allen
+1  A: 
var params:Object = this.loaderInfo.parameters;
var id:String = params.x;

//then after the movie completes

function onComplete(event:VideoEvent):void
{
   var page3URL:String = "http://example.com?" + "x=" +id;
   navigateToURL( new URLRequest( page3URL ) );
}

PatrickS
can you see the update above to see what i'm doing wrong?
Chasester
you don't need to add flashvars in your embed code, the variable is read from the url
PatrickS
alright I got it! Had to remove the part about function onComplete and just call the navigatetourl from there. and it works. Is there an advantage to having it in there vs just on the frame after the end of the movie? Thank you so much!
Chasester
i was assuming that the video would dispatch a VideoEvent.COMPLETE at the end , hence the onComplete listener
PatrickS
roger on that. Thank you Patrick
Chasester