Skip navigation
igor22co
Currently Being Moderated

Help loading Yahoo finance data into SWF

Dec 14, 2011 9:15 AM

Tags: #cs5 #flash #php #as3 #html #dreamweaver #yahoo #finance #stock #quote #ticker

I need to retrieve data from Yahoo finance, then display it on a webpage -  from the following url:

 

http://finance.yahoo.com/d/quotes.csv?s=SNA.V&f=l1sd1

 

I'm able to format and display the text within my swf, however once its uploaded to the internet - the text either won't show up, or the flash player shows a security error "flash player is trying to communicate with finance.yahoo.com"

 

I've tried to feed the data through to my own domain, but I'm not sure how to program for it. I've found php examples online, but I'm not sure how to implement them either. I need the stock quote price to display and update either once a day, or only when the swf loads. Currently I'm using the following code to retrieve the data (within flash):

 

fl_TextLoader:URLLoader = new URLLoader();

var fl_TextURLRequest:URLRequest = new URLRequest("http://finance.yahoo.com/d/quotes.csv?s=SNA.V&f=l1sd1");

 

fl_TextLoader.addEventListener(Event.COMPLETE, fl_CompleteHandler);

 

function fl_CompleteHandler(event:Event):void

{

          var fl_TF:TextField;

          var fl_TextToDisplay:String = new String(fl_TextLoader.data);

          var textData:String = new String(fl_TextLoader.data);

          var myTextFormat:TextFormat = new TextFormat();

          trace(textData);

          fl_TF = new TextField();

          fl_TF.autoSize = TextFieldAutoSize.LEFT;

          fl_TF.background = false;

          fl_TF.textColor = 333333;

          fl_TF.border = false;

          fl_TF.scaleZ = 200;

          fl_TF.maxChars = 22;

          fl_TF.x = 665;

          fl_TF.y = 579;

          fl_TF.text = fl_TextToDisplay;

          myTextFormat.font = "Calibri";

          myTextFormat.size = 18;

          addChild(fl_TF);

}

 

fl_TextLoader.load(fl_TextURLRequest);

 
Replies
  • Currently Being Moderated
    Dec 15, 2011 3:14 AM   in reply to igor22co

    Instead of loading finance.yahoo.com URL load your PHP code. Your PHP code should call the finance.yahoo.com and returns the data.

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Currently Being Moderated
    Dec 15, 2011 3:40 AM   in reply to igor22co

    Hi

     

    You can find a complete tutorial here for using Yahoo Finance in Flash.

     

    Source and example also available.

     

    Although it looks like a Phone App it can be used anywhere.

     

    Hope it helps.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points