PDA

View Full Version : loadMovie from html link



z3r0
September 10th, 2003, 10:16 AM
Iīm trying to make a movie swf to load different .swf files but pressing html links in the same page itīs embeded.
What I got is that links are passing good a variable called īvideoī to swf...

Using a jscript in html page, and html links as follows:

<script language = "JavaScript">
<!--
function PassFlash(){
window.document.movie.SetVariable("video", "video.swf");
}
//-->
</script>

<a href="#" onClick="PassFlash()">Load this video into flash please!</a>

But I think I didnīt build the actionscript correctly.. I canīt find the way to make the movie to load a determinated .swf using that variable...

If I put a loadMovie (video, "mclipholder") and a stop (); in a frame the variable is not useful because the movie doesnīt load.

If I add a gotoAndPlay (1) for making the movie loop, the swf loads again and again...


I want the main movie to be able to recognize when an html link is pressed (and passes the variable called īvideoī) and then to load the correct movie....

Any help please?
Thanks!

Eric Jr.
September 10th, 2003, 11:47 AM
Well you can just make a function in Flash like this:


function loadMyMovie(location)
{
swf.loadMovie(location);
}


And call it from Javascript. All you need to do is make a script interpreter in AS, like this one:



_root.onEnterFrame = function() {
if (_root.functionName != "") {
_root[_root.functionName](_root.functParams);
_root.functionName = "";
_root.functParams = "";
}
};


And then call it like this: (in javascript)


function callFunction(fName,fParams,mName)
{
window[mName].SetVariable("_root.functionSet",fName);
window[mName].SetVariable("_root.functParams",fParams);
}

<input type="button" name="button1" value="Exec" onClick="callFunction('loadMyMovie','url_to.swf','FLASHNAME ');">


"FLASHNAME" in the function refers the the name of the Flashobject in the HTML. So you also need to do this in your HTML:



<EMBED ID="FLASHNAME" SRC="my_movie.swf" WIDTH="950" HEIGHT="396" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,23,0">

z3r0
September 10th, 2003, 01:45 PM
Thanks, but I couldnīt make it work... itīs too advanced for me.
Any other way maybe?

Eric Jr.
September 10th, 2003, 03:24 PM
Check it out ...

z3r0
September 10th, 2003, 08:10 PM
Thank you!
I couldnīt open the fla (are you using a higher version than flash mx?).
and buttons loads the same file but I guess we can change that...

Eric Jr.
September 11th, 2003, 02:22 AM
Yeah sorry, I haved it as Flash MX (6) with Actionscript 1, but something messed up. (I use Flash MX 2004)

Did you get it to work already?

ave
September 11th, 2003, 09:37 AM
would u say its worth upgrading to flashMX2004 from flashMX (which i use) ??

Eric Jr.
September 11th, 2003, 10:59 AM
Personally I think so, because it has a LOT of new features.
But most of them are created for thre developer, designs are definately less pleased then people like me.

If you have the money you should do it, but only if you really have development plans with Flash.

ave
September 11th, 2003, 11:14 AM
well im more into the design aspects of it really so dont think ill bother for a while

cheers for the tip :)

stevester
April 9th, 2006, 07:55 PM
Your javascript to flash code doesn't work! I have tried it as well