Add MIME Type to getURL() ?

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

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?
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

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

Why. Did I. Not think of that.
:banghead:
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

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
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Thanks for that. That will save me some time looking up how to do it. Cheers!
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

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.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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. }
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

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.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

: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.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

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"); }
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6249
  • Loc: Seattle, WA

Post 3+ Months Ago

Doh! Duh.

In that case you can get rid of the URLLoader object since you no longer need it.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

gottcha. Thanks for the help spork. Got me going in the right direction.

Post Information

  • Total Posts in this topic: 16 posts
  • Users browsing this forum: No registered users and 11 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.