0
votes

I have created a simple flash object to redirect a browser to a different webpage using "navigatetoURL" while getting the URL from externalinterface calls to the javascript that the page doing the embedding of the flash file has.

I am able to build everything just fine and the html page I created (using swfobject.embedSWF to embed the flash file) runs fine and redirects the browser. However when I move the files that are needed for everything to function (the .swf file, swfobject.js, and the html file that embeds the flash object) the webpage does not redirect anymore. Just a blank space, which seems to be the flash object, is displayed and nothing is redirected.

Is there any compile option in Flashdevelop that I'm missing to prevent correct this?

Here is the actionscript 3 code:

package 
{
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.net.navigateToURL;
 import flash.net.URLRequest;
 import flash.net.URLVariables;
 import flash.external.ExternalInterface;

public class FlashTest extends Sprite
{
 public function FlashTest()
 {
    var url:String = ExternalInterface.call("GetURL");
    var hash:String = ExternalInterface.call("GetHash");
    var new_url:String = url + hash;
    var request:URLRequest = new URLRequest(new_url);
    navigateToURL(request, "_self");

 }
}
}

The HTML code:

<html>
<head>

<script src='js/swfobject.js' type='text/javascript'></script>
<script type='text/javascript'>
swfobject.embedSWF('Flashtest.swf', 'altContent', '100%', '100%', '10.0.0');
function GetURL()
{
   return 'http://www.cnn.com';
}

function GetHash()
{
  return '?hash=2398asb9s8234';
}

</script>
</head>
<body>
<div id='altContent'>
<h1>Flash_test</h1>
<p>Alternative content</p>
<p><a href='http://www.adobe.com/go/getflashplayer'><img 
src='http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif' 
alt='Get Adobe Flash player' /></a></p>
</div>
</body>
</html>
2
I've narrowed it down a bit. A simple hello world type swf file works just fine when directories are changed. It seems it has to do with my particular swf.Brian Schulte

2 Answers

0
votes

Actually, I've been in trouble with swf's being started before they are added to the HTML DOM and/or before the DOM is ready. Have a look at Adobes own article on ExternalInterface.call and javascript isReady. I would also have a look at the allowScriptAccess parameter:

<script type="text/javascript">
   var so = new SWFObject("movie.swf", "mymovie", "400", "200", "8", "#336699");
   so.addVariable("allowScriptAccess", "always");
   so.write("flashcontent");
</script>
0
votes

It's actually a flash player security issue. If you move the files out of the bin folder and run them local they won't work any more.

Each time you create a project in flashdevelop the "bin" folder is added to the exception list of the flash player. If you move the files to another folder then they won't work anymore hence the blank page when opening the html in browser.

The solution is to manually modify the flash player security config file and add the new path or to visit: http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html Click on Global Security Settings > Always Allow > Edit ocations > Add Location > Browse for the new path, where the files are located.