I'm trying to create an interactive map for a farmers market. The user hovers the cursor over the stands and the farm and farmer's names pop up. When clicked the button redirects the user to the farmer's page on the bloomington.in.gov website. The .swf reads a .xml file for the farmer/farm/url data, so the .swf can be more dynamic.
The .swf will sit somewhere on the bloomington.in.gov domain, but I don't have access to it to test if it will work on there. As a result I'm trying to test the .swf by running it from a flash drive on different computers in either adobe flash player or chrome.
Everything seems to function when I test the file in Adobe Flash, but when I try to publish the .swf and run it in Adobe Flash Player I get this error message:
SecurityError: Error #2028: Local-with-filesystem SWF file file:///G|/FarmersMarketMap/FarmersMarketMap2.swf cannot access Internet URL https://bloomington.in.gov/documents/viewDocument.php?document_id=7483. at global/flash.net::navigateToURL() at MethodInfo-7()
The xml file seems to load because the farm/farmer names show up, however there seems to be this security issue with the URLs.
I've played flash games that linked me to external websites. Why is what I'm trying to do not allowed?
I've tried the internet's various suggestions:
- crossdomain xml policies
- Adobe flash publishing settings
- Security.allowDomain("*");
- changing html allowScriptAccess to "always"
Alternatively, when the .swf is finally embedded in the bloomington.in.gov domain, will all of the links (which are consequently within that domain) suddenly work? Nevertheless, it's nerve wracking sending it off not knowing whether or not it will work in advance.
Here's my code for what it's worth:
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.text.Font;
//http://www.republicofcode.com/tutorials/flash/as3text/;
var farmFont:Font = new nevis as Font;
var farmerFont:Font = new DistrictPro as Font;
//FarmText Format
var farmFormat:TextFormat = new TextFormat();
farmFormat.font = farmFont.fontName;
farmFormat.size = 28;
farmFormat.align = TextFormatAlign.LEFT;
//FarmerText Format
var farmerFormat:TextFormat = new TextFormat();
farmerFormat.font = farmerFont.fontName;
farmerFormat.size = 24;
farmerFormat.align = TextFormatAlign.LEFT;
//Set Farm Text Attributes
var farmText:TextField = new TextField();
farmText.embedFonts = true;
farmText.defaultTextFormat = farmFormat;
farmText.antiAliasType = AntiAliasType.ADVANCED;
farmText.text = "This is the Farm Text.";
farmText.x = 324.15;
farmText.y = 42.1;
farmText.autoSize = "left";
//Set FarmerTextAttributes
var farmerText:TextField = new TextField();
farmerText.embedFonts = true;
farmerText.defaultTextFormat = farmerFormat;
farmerText.antiAliasType = AntiAliasType.ADVANCED;
farmerText.text = "This is the Farmer Text";
farmerText.x = 324.15;
farmerText.y = 70.1;
farmerText.width = 475.85;
farmerText.wordWrap = true;
//Default Text
var firstLine:String = "Vendor Locations";
var secondLine:String = "Click on market spaces for more information.";
farmText.text = firstLine;
farmerText.text = secondLine;
addChild(farmText);
addChild(farmerText);
//http://www.republicofcode.com/tutorials/flash/as3xml/
var XMLinput:XML;//var variableIdentified:DataType;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("MarketSpreadsheet.xml"));
//loads xml file;
myLoader.addEventListener(Event.COMPLETE, processXML);
//checks for when xml is loaded, processXML=function to be done when xml is loaded;
var i:int;//counter
//var j:int;//nested counter
//generates the xml variable data array
var XMLData:Array = new Array(4);
for (i=0; i<4; i++)
{
XMLData[i] = new Array(100);
}
function processXML(e:Event):void
{
XMLinput = new XML(e.target.data);
for (i=0; i<100; i++)
{
if (isNaN(Number(XMLinput.*.Lot[i])) == false)
{
XMLData[0][i] = ("N" + XMLinput.*.Lot[i]);
}
else
{
XMLData[0][i] = XMLinput.*.Lot[i];
}
XMLData[1][i] = XMLinput.*.Farm[i];
XMLData[2][i] = XMLinput.*.Farmer[i];
XMLData[3][i] = XMLinput.*.Link[i];
}
//Add the button event handler to the buttons' parent clip.
butts.addEventListener(MouseEvent.CLICK, buttClick);
butts.addEventListener(MouseEvent.MOUSE_OVER, buttOver);
butts.addEventListener(MouseEvent.MOUSE_OUT, buttOut);
//Button Handlers
function buttClick(e:MouseEvent)
{
trace(e.target.name + " Click");
for (i=0; i<XMLData[0].length; i++)
{
if (XMLData[0][i] == e.target.name)
{
navigateToURL(new URLRequest(XMLData[3][i]));
trace(XMLData[3][i]);
}
}
}
function buttOver(e:MouseEvent)
{
for (i=0; i<XMLData[1].length; i++)
{
if (XMLData[0][i] == e.target.name)
{
farmText.text = XMLData[1][i];
farmerText.text = XMLData[2][i];
}
}
}
function buttOut(e:MouseEvent)
{
farmText.text = firstLine;
farmerText.text = secondLine;
}
}