• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 602
  • Last Modified:

Cannot call flash functions

Greetings;

I created a SWF movie that load an MP3 file dynamically through a javascript call, when the HTML file is loaded normally, calls to flash embedded functions are being excuted successfuly.
But when the HTML file is being loaded through ajax from another page, when I try to cal the flash function, I get a Javascript error: "Object doesn't support this property or method".

The problem only happens on Internet Explorer, Chrome and firefox doesn't return any error and excutes the function as expected.

Please advice.

Best regards,
McHaimech.
<script>
	<!--  
	function thisMovie(movieName) {
	  if (navigator.appName.indexOf ("Microsoft") !=-1) {
		return document.getElementById(movieName);
	  }	else {
		return document[movieName]
	  }
	}

	//-->     
	function PlayAudio()
	{
		thisMovie('AudioPlayer').SetVideo('test.flv');
	}
	function StopAudio()
	{
		thisMovie('AudioPlayer').StopVideo();
	}
</script>
	<object CLASSID="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" CODEBASE="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab" id="AudioPlayer" width="230" height="20">
		<param name="movie" value="AudioPlayer.swf?id=79">
		<PARAM NAME="PLAY" VALUE="false" />
		<PARAM NAME="LOOP" VALUE="false" />	
		<PARAM NAME="QUALITY" VALUE="high" />
		<PARAM NAME="SCALE" VALUE="SHOWALL" />
		<param name="wmode" value="transparent" />
        <embed name="AudioPlayer" width="230" height="20" src="AudioPlayer.swf?id=79" PLAY="false" LOOP="false" QUALITY="high" SCALE="SHOWALL" swLiveConnect="true" wmode="transparent" PLUGINSPAGE="http://www.macromedia.com/go/flashplayer/">
		</embed>
	</object>
	  <input type="button" value="play" onclick="PlayAudio()" /><br />
	  <input type="button" value="stop" onclick="StopAudio()" />

Open in new window

0
mchaimech
Asked:
mchaimech
  • 2
1 Solution
 
phpsalesCommented:
To communicate between JavaScript and the internal Flash modules you'll need to add "allowScriptAccess" param tag. E.g.

<param name="allowScriptAccess" value="always">

Also be sure that the Flash modules are registered to be called externally by JavaScript inside your Flash application using the ExternalInterface addCallBack method.

More Information: http://livedocs.adobe.com/flex/3/langref/flash/external/ExternalInterface.html#addCallback%28%29 
0
 
mchaimechAuthor Commented:
Hi phpsales, and thank you for your reply.
Well, I added the tag "AllowScriptAccess" as you mentioned without, but didn't affected the problem.
As I stated in previous post, the flash functions are already registered, and when I open the HTML file normally, javascript calls to flash functions run as expected, but when the HTML is being loaded through ajax, the problem appears.
So, I think that the IE is not registering the flash functions when loaded through ajax, unlike other browsers (chrome, FF) where these browsers are registering the flash functions, those the test runs successfuly.

Best regards,
McHaimech
0
 
mchaimechAuthor Commented:
Hello again,

I recreated my flash file, but instead of calling the function through javascript to pass variables I am now passing it through flashvars, and it's working just fine, even when Loaded through ajax.
Again, thank you so much phpsales for trying to help. :)

Best regards,
McHaimech
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now