Add MIME Type to getURL() ?

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 17th, 2008, 7:49 am

Anyone know how (or if it's possible) to add a MIME Type to getURL() for a button?

I'm basically trying to get what I have here in this HTML link to work on a Flash Button.
Code: [ Select ]
<a href="http://www.alaron-nuclear.com/ozzu/flyto-1.kml" type="application/vnd.google-earth.kml">KML Test</a>


I know this is the syntax getURL( url {,window, method} ) And I can't see how to get the MIME Type to work with that.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 17th, 2008, 7:49 am

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 17th, 2008, 8:00 am

I've used getURL() in plenty of Flex projects and I don't believe it's possible.

Have you considered setting up a simple server-side script to deliver the file with the correct headers?
The Beer Monocle. Classy.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 17th, 2008, 8:07 am

Well, that's sort of what zwirko was trying to do in this thread and it wasn't working.

I was trying to figure out a way to implement my solution which works in a Flash Button.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 17th, 2008, 8:26 am

I just got essentially the same answer at actionscript.org forum, but they did say AS 3 has a URLRequest function that will let me do it. I'm upgrading to CS3 anyway next week so I'll just wait until then.
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 17th, 2008, 8:33 am

ATNO/TW wrote:
AS 3 has a URLRequest function that will let me do it.

Why. Did I. Not think of that.
:banghead:
The Beer Monocle. Classy.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 17th, 2008, 8:44 am

Code: [ Select ]
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");
request.requestHeaders = new Array(
    new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml")
);
loader.load(request);
  1. var loader:URLLoader = new URLLoader();
  2. var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");
  3. request.requestHeaders = new Array(
  4.     new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml")
  5. );
  6. loader.load(request);


These are the Flex language refs but should be the same as the Flash ones (except for the AIR-specific things):
http://livedocs.adobe.com/flex/3/langre ... quest.html
http://livedocs.adobe.com/flex/3/langre ... oader.html
The Beer Monocle. Classy.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 17th, 2008, 8:55 am

Thanks for that. That will save me some time looking up how to do it. Cheers!
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 30th, 2008, 11:18 am

A little help. I'm trying to set this up now and having difficulty getting the button to do what it's supposed to. I've tried a variety of things and after some research and study, this is what I think should work, but it's not.

Code: [ Select ]
btnTest.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");
        new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml");
   
        loader.load(request);
}
  1. btnTest.addEventListener(MouseEvent.CLICK, onClick);
  2. function onClick(e:MouseEvent):void {
  3.     var loader:URLLoader = new URLLoader();
  4.     var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");
  5.         new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml");
  6.    
  7.         loader.load(request);
  8. }


The syntax is all valid, but when clicked the button does nothing. I'm just doing a simple test. The instance name of the button is btnTest
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 30th, 2008, 11:50 am

You're actually missing some code there. Check my code from above; the URLRequestHeader object needs to be placed in an array, and then that array has to be assigned to the requestHeaders property of the URLRequest object.
The Beer Monocle. Classy.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 30th, 2008, 12:24 pm

odd. I had it that way. Not sure how or why that got altered. Switched to this, but still no joy. No errors generated. Just nothing on click.

Code: [ Select ]
btnTest.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {
       var loader:URLLoader = new URLLoader();
   var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");
   request.requestHeaders = new Array(
        new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml")
   );
   
   loader.load(request);
}
  1. btnTest.addEventListener(MouseEvent.CLICK, onClick);
  2. function onClick(e:MouseEvent):void {
  3.        var loader:URLLoader = new URLLoader();
  4.    var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");
  5.    request.requestHeaders = new Array(
  6.         new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml")
  7.    );
  8.    
  9.    loader.load(request);
  10. }
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 30th, 2008, 12:30 pm

Code: [ Select ]
btnTest.addEventListener(MouseEvent.CLICK, onClick);

Where is that line being executed? Currently it appears to be outside of any function or routine, which I don't believe is allowed. My guess is that the function is never being attached to the event.
The Beer Monocle. Classy.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 30th, 2008, 12:55 pm

I guess that's my problem. Never seen AS3 prior to today and trying to make this work in a hurry 'cause my CEO wants it, and I have no friggin' clue what I'm doing *lol
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 30th, 2008, 1:03 pm

:lol:

Don't worry - keep toying with AS3 long enough and you'll begin to love it, especially if you've used AS2 at all.
The Beer Monocle. Classy.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Joined: May 28, 2003
  • Posts: 23404
  • Loc: Woodbridge VA
  • Status: Offline

Post July 30th, 2008, 1:38 pm

I just got some advice at my post at actionscript.org, which almost works perfectly
http://www.actionscript.org/forums/show ... post772461

Only problem as you'll see it doesn't pass the MIME Type so IE gets all cranky about it.

//edit. Actually the second and third time I tried that in IE it did work!

So the correct code to use is
Code: [ Select ]
import flash.net.navigateToURL;
btnTest.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void {     
var loader:URLLoader = new URLLoader();     
var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");     
request.requestHeaders = new Array(new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml"));     
navigateToURL(request,"_self"); }
  1. import flash.net.navigateToURL;
  2. btnTest.addEventListener(MouseEvent.CLICK, onClick);
  3. function onClick(e:MouseEvent):void {     
  4. var loader:URLLoader = new URLLoader();     
  5. var request:URLRequest = new URLRequest("http://www.alaron-nuclear.com/ozzu/flyto-1.kml");     
  6. request.requestHeaders = new Array(new URLRequestHeader("Content-Type", "application/vnd.google-earth.kml"));     
  7. navigateToURL(request,"_self"); }
"There's no place like 127.0.0.1 except for ::1."
Alexandria Networks. Leader in IT consulting for associations/non-profits, and small to medium sized businesses around the northern Virginia and Washington D.C. metro area.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Joined: Sep 22, 2003
  • Posts: 6130
  • Loc: Seattle, WA
  • Status: Offline

Post July 30th, 2008, 2:03 pm

Doh! Duh.

In that case you can get rid of the URLLoader object since you no longer need it.
The Beer Monocle. Classy.
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post July 30th, 2008, 2:03 pm

Post Information

  • Total Posts in this topic: 16 posts
  • Users browsing this forum: No registered users and 41 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.