Hey guys, brand new to Flash, so please bare with me if this problem is really simple, I've been searching the tubes all day for a solution but haven't found anything (not sure if I'm searching for the wrong thing)
Here's some AS3 that I just wrote:
Code:
var myServer:String = "https://censored";
var mySite:String = "/cen";
var mySubSiteID:String = "33";
var myXML:String = myServer + "/includes/headerXML.cfm?subsiteid=" + mySubSiteID;
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest(myXML));
myLargeText.text = "1. data loaded";
function LoadXML(e:Event):void {
myLargeText.text = "2. data loaded";
xmlData = new XML(e.target.data);
myLargeText.text = "3. data loaded";
ParseHeader(xmlData);
}
function ParseHeader(xmlInput:XML):void {
trace("XML Output");
trace("------------------------");
trace(xmlInput.header.smalltext.text()[0]);
trace(xmlInput.header.maintext.text()[0]);
myLargeText.text = xmlInput.header.maintext.text()[0];
mySmallText.text = xmlInput.header.smalltext.text()[0];
myLargeTextShadow.text = xmlInput.header.maintext.text()[0];
mySmallTextShadow.text = xmlInput.header.smalltext.text()[0];
}
backtomin.addEventListener(MouseEvent.CLICK, backtominHandler);
function backtominHandler(event:MouseEvent):void {
navigateToURL(new URLRequest("/"), '_self');
trace("Action: Back to MIN");
}
linkarea.addEventListener(MouseEvent.CLICK, linkareaHandler);
function linkareaHandler(event:MouseEvent):void {
navigateToURL(new URLRequest(mySite), '_self');
trace("Action: Go to Current Page");
}
The problem is, when I do Control -> Test Movie, the page works great, goes out, grabs the XML, replaces the text in the swf with the text it found there. However, when I export the movie and open it on my page in a browser, it doesn't do it. I added the myLargeText.text = "1. data loaded"; parts to see how far it was getting, and it always stops working after the first one, which leads me to believe there is a problem with the URLRequest that is not completing.
Is this online, or from a local filesystem? Flash has a sandbox for local filesystem stuff that prevents the player from accessing network resources. Upload it to a server and try again.
Not trying to be pedantic here, just clear. If you're accessing it with a file:// url, you'll get the sandbox behavior. You have to see it with http://
If that's the case, I don't know what else might be wrong.
I understand, the ground-level approach really does help think thru a problem, but I am accessing with http://, (actually, https://, but even that works fine in CS3 for testing)
the only other thing i could think of, is i am running it thru a noclick script (so that activex box doesn't show up around it by default) but i don't see anything wrong with that myself. maybe some fresh eyes will catch something though.
The idea for finding said bug is the KISS method. If you have an issue with a simple problem don't try to solve it with obscure complexity. Make another swf that mebbe ONLY has a URLRequest in it and absolutely nothing else. If that works then you know your issue is of different origins. Then you will also have more to discuss in the case of solving your issue.
Yes, I am completely aware of how to keep it simple, if you would like me to verify I have done something, you can just ask, being pedantic only serves to be insulting. I provided the other information so anyone looking at the problem was able to see the entire thing, it's much easier in the long run than slowly rolling out pieces that may or may not be related.
But just to verify, yes a swf with nothing but a URLRequest continues to work in CS3 and not in the web browser, I can also view the xml as a valid file from within the web browser.
All right. Perhaps it's a security model thing. URLLoader can dispatch lots of events for different types of errors. I suggest putting in basic handlers for each of them just to see which is happening. The events can be found on the URLLoader livedocs page: http://livedocs.adobe.com/flash/9.0/...URLLoader.html
For quick reference, these events are:
complete Dispatched after all the received data is decoded and placed in the data property of the URLLoader object.
httpStatus Dispatched if a call to URLLoader.load() attempts to access data over HTTP.
ioError Dispatched if a call to URLLoader.load() results in a fatal error that terminates the download.
open Dispatched when the download operation commences following a call to the URLLoader.load() method.
progress Dispatched when data is received as the download operation progresses.
securityError Dispatched if a call to URLLoader.load() attempts to load data from a server outside the security sandbox.
I suspect that either ioError or securityError is happening.
If that was the problem, he wouldn't get the swf at all. He's stated that it does up to the first trace, so he's getting the swf on the screen. There is no requirement that the swf and html it's embedded in actually be in the same folder. I routinely keep swfs in a different directory.
Ah, yes. It's important that the path to the xml file is relative to the right path (swf or html). I forget which is used by default. One can explicitly set the base path through the use of the "base" parameter which will end up being the path used to resolve all relative urls in the swf.
which in the browser displays the text "error #2032". I searched and found some documentation that flash dislikes when an xml document has the header values: