how to load flash movies into a movieclip using html and javascript

Posted on 2009-02-14
Last Modified: 2013-11-17
I am trying to find a way to load either movieclips or .swf files into a Flash movie from my html page. I have been researching using javascript, but have not had any success. I have 4 HTML text links which when clicked will each play a different movie and stop the other movies. I basically need a javascript function to loadmovie into my flash movie, which has a empty mc (loader_mc). I have been using this javascript code , but it only plays the movies ontop of each other. I need the movie to stop and load a new movie when clicked.

Thanks for your time.

<script type="text/javascript">

	function loadMovie(url,layer) {




<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

<script src="Scripts/flexcroll.js" type="text/javascript"></script>


<body leftmargin="0" topmargin="0">

	<div id="prod_container">


		<div id="home">

		  <div align="right"><a href="#products" target="_self"></a><img src="images/products.jpg" width="250" height="30" /></div>


		<div id="product_list">

		  <table width="200" border="0" cellspacing="0" cellpadding="2">


              <td class="text"><div align="right"><a onclick='javascript:example.TPlay("_level0/movie1_mc")'href="#juice", target="_self">Juice</a>




              <td class="text"><div align="right"><a onClick='javascript:example.TPlay("_level0/movie2_mc")'href="#spreads", target="_self">Spreads</a> </div></td>			



              <td class="text"><div align="right"><a onClick='javascript:example.TPlay("_level0/movie3_mc")'href="#sauces", target="_self">Sauces</a>




              <td class="text"><div align="right"><a onClick='javascript:example.TPlay("_level0/movie4_mc")'href="#cherry", target="_self">Pitted Cherry</a></div></td>



              <td class="text"><div align="right"><a href="javascript:loadMovie("mc_products2.swf", "_root.test.content")">Export Order Form</a></div></td>




	  <div id="flashbox"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="example" name="example" codebase=",0,29,0" width="259" height="350">

<param name="movie" value="test.swf">

<param id="example" value="example">

<param name="example" value="example">

<param name="quality" value="high">

<embed src="test.swf" id="example" name="example" swliveconnect="true" quality="high" pluginspage="" type="application/x-shockwave-flash" width="259" height="350"></embed>


Open in new window

Question by:legionl2k
    LVL 8

    Expert Comment

    Hi legionl2k,

    Maybe I'm missing the point here, but if you want to load swf's into your currently loaded swf. Then I suggest doing this through actionscript.

    Write the code for loading the movies inside your main flash application.



    Author Comment

    Sorry I should have spelled it out a bit more thoroughly. The 4 text links in the HTML page are working with a custombuilt scrollpane. The user clicks on a link and the scrollpane moves to the desired named anchor, then the main movie is triggered to play that particular product movie. So I have the scroll pane named anchor working fine with a <A HREF>, and I have included a <A OnClick> to handle the loadmovie call.

    (<td class="text"><div align="right"><a onClick='javascript:example.TPlay("_level0/movie2_mc")'href="#spreads", target="_self">Spreads</a>

    So I need a way of doing both things (named anchor & loadmovie call ) with the one text link.

    I hope this clears it up. Im at my wits end. I have tried so many tutorials I am getting really lost. Its such a simple thing too, according to the forums !!

    Accepted Solution

    Wello I managed to work it out in the end. It seems there were errors in the Javascript code supplied from the tutorial. I just took the T out of the TPlay.

    " (<td class="text"><div align="right"><a onClick='javascript:example.TLoad("_level0/movie2_mc")'href="#spreads", target="_self">Spreads</a>
    Now it loads no problem.


    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Suggested Solutions

    Title # Comments Views Activity
    JavaScript - Chessboard 36 32
    Problem to echo 6 32
    appending location.reload to url with javascript 4 33
    javascript to html map 8 19
    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…
    Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
    The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: : Click on Too…
    The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

    746 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

    14 Experts available now in Live!

    Get 1:1 Help Now