Hi, flash noob here. I would like to embed a video into a flash file, and then embed the swf in an html. What I want to happen is that when the video ends, it redirects the user to another URL in the same browser window. Any help?
Thanks!
| SitePoint Sponsor |

Hi, flash noob here. I would like to embed a video into a flash file, and then embed the swf in an html. What I want to happen is that when the video ends, it redirects the user to another URL in the same browser window. Any help?
Thanks!




If your embedding the video direct onto the timeline then all you need to do is create a blank key frame just after the last frame of your video and then add getURL code
Example:
Code Actionscript:getURL("yourpage.html","_self")
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
and how could you add random URL's when flash video ends so that user gets randomly to different parts of a website?
any tips/hints appreciated!
thanks

Put the urls in an array and pull one out using a randomly generated number as the array index




Something like that maybeCode Actionscript:function randRange(min:Number, max:Number):Number { // Generate a number between and including min – max var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min; return randomNum; } //build array to hold url's var urlArray:Array = new Array(); urlArray[0] = "url1"; urlArray[1] = "url2"; urlArray[2] = "url3"; urlArray[3] = "url4"; urlArray[4] = "url5"; // Get random number created var n:Number = randRange(0, urlArray.length); // getURL(urlArray[n], "_self");
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
What I have tried so far is the following:
Code Actionscript:var urls : Array = ['http://inkenrohweder.com/?page_id=119','http://inkenrohweder.com/?page_id=26','http://inkenrohweder.com/?page_id=121','http://inkenrohweder.com/?page_id=123','http://inkenrohweder.com/?page_id=125'] var index:Number = Math.floor(Math.random() * urls.length)) url = urls[index]
and I've added the following as on a button:
Code Actionscript:on (release){ getURL(url, window); }
however, I get a syntax error. Would any of you see on the fly what is missing in the above?
ta, in the meantime I have a go what Paul has suggested,
Paul, this has worked a treat! thanks :-) is there also a way to set random URLs on a "skip intro" button?




Something like that.Code Actionscript:function randRange(min:Number, max:Number):Number { // Generate a number between and including min – max var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min; return randomNum; } //build array to hold url's var urlArray:Array = new Array(); urlArray[0] = "url1"; urlArray[1] = "url2"; urlArray[2] = "url3"; urlArray[3] = "url4"; urlArray[4] = "url5" someButton.onRelease=function(){ var n:Number = randRange(0, urlArray.length) getURL(urlArray[n], "_self"); }
More examples of using random here.
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
Hi Paul,
thanks also for supplyting the AS code for adding random hyperlinks to a button. I have tried this and when testing i don't get any errors but it seems like the links are not going anywhere.
Basically I use the first AS for the automated re-direct as quoted by you on its own layer on the timeline:
Code Actionscript:function randRange(min:Number, max:Number):Number { // Generate a number between and including min – max var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min; return randomNum; } //build array to hold url's var urlArray:Array = new Array(); urlArray[0] = "url1"; urlArray[1] = "url2"; urlArray[2] = "url3"; urlArray[3] = "url4"; urlArray[4] = "url5"; // Get random number created var n:Number = randRange(0, urlArray.length); // getURL(urlArray[n], "_self");
and on the next layer i add the following AS enabling to click the animation and get directed to random URLS:
can you see with that where I'm going wrong? Do you need the link of where the animation is placed?
thanks a lot for your help,
best, Daniela




If your using/declaring the same code on different layers then there is likely to be a conflict. Can you post your fla?
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
here is the link to download the zipped version of the fla.
http://inkenrohweder.com/intro_inkenrohweder.zip
Let me know when you have downloaded it so I can remove it again from the server. thanks!




.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com




You had a duplicate array and function.
http://www.scotflash.co.uk/share/int...enrohweder.zip
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
alright, i just tried to open it but maybe you saved it in a newer version of flash? am still working with flash 8 .... I get an unexpected file error when trying to open it




Ok that's going back a bit. I am using CS5.5
Just place the code on the last frame with what is below
Code Actionscript:// Get random number created var n:Number = randRange(0, urlArray.length); // getURL(urlArray[n], "_self"); stop()
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
so basically it was just adding a stop() at the end of the AS in last frame? that's what i've done now. however, the animation works, clicking the button still doesn't work and when the animation has finished no random redirect to url's is happening.




Ah yeah sorry you need to give the button an instance name "someButton"
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
super duper! it works a treat now, thanks so much for your help!




.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
Paul, hello! or anyone else who has an idea :-)
with the piece of flash you helped me with (see above) we are experiencing a random "undefined" URL error.
I'm attaching a screenshot.
Any ideas what this is causing?
thanks
Daniela.




How often does it happen and is it in a particular browser?
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
when it happens, then a couple of times after each other, primarly on Safari and FF on Mac. have just tested it about 20 times on PC IE and FF, and there it didn't happen.




Ah sorry. I don't have mac so this is where my help runs dry. Hopefully someone else will be able to help you out that has a mac.
.:To me AS is like LEGO, Only for the big Kids :.
- Site - Blog - Glasgow Flasher
bringmadeleinehome.com
I did some more tests and on Safari the following happened:
10x fine
3x undefined
1x fine
1x undefined
4x fine
1x undefined
12x fine
1x undefined
5x fine
today I couldn't get the undefined page on Firefox but it did appear there before as well, much less than with safari
does this make any sense to you?
any mac flashers/actionscripters out there which might be able to help?
Bookmarks