Using java script to make flash link

Q&A about the latest versions
Post Reply
User avatar
hum@no.id
Posts: 945
Joined: Sat Sep 09, 2006 10:35 pm
Location: Dark side of the Moon
Contact:

OK. I'm working on a new version of my HomePage (portfolio).
There is a need to use various third-party modules for the gallery via JS from Flash

I learned this place (as the full sample) http://gardengnomesoftware.com/wiki/Pan ... Script_API
"Complete example" bookmark

This syntax work fine on page (and other call functions).

Code: Select all

<a onClick="pano.moveTo(140,-40,70,10);" href="#">test</a>

But if I set this action through Flash and attaches into page (or better solution into the main Flash) this properly written syntax does not work (any test button)

Code: Select all

on (release) {
getURL("javascript:pano.moveTo(140,-40,70,10);" );
}
learn from http://www.kirupa.com/forum/showthread.php?t=76495

I not change the original HTML page general code from ("Complete example" bookmark http://gardengnomesoftware.com/wiki/Pan ... Script_API)...

RESUME: How to correct write this Pano2VR condition - "onClick (...)" JS to "on (release) {...}" AS (External flash attached in HTML page or embedded into main pano SWF)
Gumir J | VR Panoramic Photographer | mobile: +77055717171 | skype: gumirj
website: gumirj.com | google.com/+gumirj | facebook.com/gumirj | twitter.com/gumirj
Sebastian
Posts: 209
Joined: Sun Jul 13, 2008 9:08 am
Contact:

I don't have an actual example to test it, but few things to keep in mind when using java-script function in conjunction with URL request.

First, it's good to VOID the function in the end void(0);
Second, if you export your panorama, you are using AS3.0 and in AS3.0 you can't add actions to an object (button). That's an old method used in AS and AS1/2, which is no longer supported in AS3.0
Perhaps you have a mismatch of actions within same file, hence it does not work.
3rd, most of JavaScript functions won't work locally, on desktop or in browser. You might need to upload online and test it directly on your server. You could try to change the security setting in your player to
include your working folder or the entire C: drive in the trusted file list. Still, best testing it online in real time.

regards
Seba
User avatar
hum@no.id
Posts: 945
Joined: Sat Sep 09, 2006 10:35 pm
Location: Dark side of the Moon
Contact:

Hi, Sebastian

its work on server (with standard p2q_embed_object.js and pano Pano2VR3b)

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
		<title></title>
		<script type="text/javascript" src="p2q_embed_object.js" />
	</head>
<body>
		<p>
		<script type="text/javascript">
<!--
			function getFlashMovie(movieName) {
				var isIE = navigator.appName.indexOf("Microsoft") != -1;
				return (isIE) ? window[movieName] : document[movieName];
			}
			if ((window.p2q_Version) && (window.p2q_Version>=2.0)) {
				var flashvars="";
				// enable javascript interface
				flashvars+="externalinterface=1&pan=22";
				p2q_EmbedFlashId('pano','test.swf','640','480','allowFullScreen','true','FlashVars',flashvars);

				// Check to see if the version meets the requirements for playback
				if (!DetectFlashVer(9,0,0)) {
					document.write('<p class="warning">This content requires Adobe Flash Player Version 9 or higher. '
								 + '<a href="http://www.adobe.com/go/getflash/">Get Flash<\/a><\/p>');
				}
			} else {
				document.writeln('<p class="warning">p2q_embed_object.js is not included or it is too old!');
				document.writeln(' Please copy this file into your html directory.<\/p>');
			}
//-->
		</script>
		<noscript>
			<p class="warning">Please enable Javascript!</p>
		</noscript>
		<br>
		<a onClick="pano.moveTo(140,-40,70,10);" href="#">Move To 140,-40</a>
		<a onClick="pano.moveTo(-100,40,70,3);" href="#">Move To -100,40</a>
		<a onClick="pano.moveTo(-140,30);" href="#">Move To -140,30</a>
		<a onClick="pano.stop();pano.setPan(-100);pano.setTilt(-50);" href="#">Jump To -100,-50</a>
	</body>
</html>
I attach into upper HTML page, new test SWF button with code in BODY

Code: Select all

<object width="150px" height="150px" classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
<param name="movie" value="button.swf">
<param name="quality" value="high">
<param name="bgColor" value="#E6E6E6">
<param name="wmode" value="window">
<embed src="button.swf" width="150px" height="150px" quality="high" TYPE="application/x-shockwave-flash" wmode="window" bgColor="#E6E6E6" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>
</object>
code form SWF test button (AS2)

Code: Select all

on (release) {
getURL("javascript:pano.moveTo(140,-40,70,10);" );
}
all test on server (button not work)

_______

I think that should even write a little Delegate script something like this (for interact with the new object),
new adding JavaScript in HTML

Code: Select all

function pano.moveTo(pan,tilt,fov,speed){
...
}
but I do not know, how to correct write it...

_______

just attachment button.fla
Attachments
button.fla
(7.17 KiB) Downloaded 4092 times
Gumir J | VR Panoramic Photographer | mobile: +77055717171 | skype: gumirj
website: gumirj.com | google.com/+gumirj | facebook.com/gumirj | twitter.com/gumirj
Sebastian
Posts: 209
Joined: Sun Jul 13, 2008 9:08 am
Contact:

Just to make sure I understood you correctly, the button is outside of the panorama file? Is that right?

if you are using one flash button to invoke Javascript to control another flash file, I'm sure you need to specify the frame name (if you running it in frames), otherwise the button looks for function within its own HTML document. Also, as I said earlier, try to void the function at the end void(0);

NOTE! flash JS call function by default won't work on desktop, it has to be tested in browser online. Browser/Player security feature.

I don't have Flash CS5 on this laptop, so I can't make samples to test it, tho I will try later when I back to office or home.

regards
Seba
User avatar
hum@no.id
Posts: 945
Joined: Sat Sep 09, 2006 10:35 pm
Location: Dark side of the Moon
Contact:

Hi, again
OK. test here - http://mmgfx.com/test/

Condition: Pano created with P2VR3b5
Just to make sure I understood you correctly, the button is outside of the panorama file? Is that right?
Inside and outside (two variants) - Button: Grey rectangle into panorama (as external embedding file) and pure external file attach into page
Also, as I said earlier, try to void the function at the end void(0);
void(0) - like as "return false"? How to place it?
NOTE! flash JS call function by default won't work on desktop, it has to be tested in browser online. Browser/Player security feature.
Yes.
____

Thanks You for support
into attach ZIP public test files
Attachments
1.ZIP
(123.74 KiB) Downloaded 308 times
Gumir J | VR Panoramic Photographer | mobile: +77055717171 | skype: gumirj
website: gumirj.com | google.com/+gumirj | facebook.com/gumirj | twitter.com/gumirj
Post Reply