<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Flash AS3 Search Twitter API</title>
	<atom:link href="http://www.codingcolor.com/as3/flash-as3-search-twitter-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/</link>
	<description>is Manuel Gonzalez</description>
	<lastBuildDate>Fri, 20 Jan 2012 11:45:22 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
	<item>
		<title>By: admin</title>
		<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/comment-page-1/#comment-618</link>
		<dc:creator>admin</dc:creator>
		<pubDate>Tue, 23 Nov 2010 19:06:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.codingcolor.com/?p=1779#comment-618</guid>
		<description>Hi Dave,

I&#039;m sorry to hear you are stuck in AS2 land, but I&#039;m glad you are making the transition to AS3. I&#039;m not aware of an AS2 library that is readily available for you to implement into your current projects. To keep the whole project in AS2, I would recommend you use a different approach. As you may know by now, even if you altered the code above to your likings, you would not be able to use the AS3 approach, due to the issues of loading an AS3swf into an AS2swf, Google it. Tho, not the end of the world, you could probably come up with a wonky solution using Local Connection, but I wouldn&#039;t advise it.  Instead I&#039;m going to push you in a new direction, one that requires Flash to communicate with PHP. That way you can use your AS2 knowledge to load in php results. There are tons of Flash to PHP communication on the interwebs, fire up a Google search. 

Here&#039;s a link to Ryan Faermans blog post on a php solution to search twitter : http://ryanfaerman.com/twittersearch/.  You could easily alter his code to return the search values to flash. You could probably find tons more of php related Twitter functionality. As I mentioned in my post you will end up hitting Twitters query limit, and have to start looking for a proxy approach, so you might as well go down that road now. At this point I&#039;m not sure if the questions you asked are relevant now, but here a few quick answers:

(1)  Easy, update the _currentSearchKeyword variable and call the searchTwitter() method in the constructor like so:

public function Main() {
           
            _content = new Sprite();
            _content.x = 20;
            _content.y = 65;
            addChild(_content);
            _searchButton = sButton;
            _searchInput = sInput;
            _searchInput.text = _currentSearchKeyword;
            _twtr = new Tweetr();
            addSearchFormListeners();
           //update the search var
           _currentSearchKeyword = “I love NY”;
          //call the method
          searchTwitter();
           
        }

(2) You could do this 2 ways: 1- create a new method call addSearchButton() and add the button listeners to it or 2- add to existing method addSearchFormListeners()

private function addSearchFormListeners():void {
            _searchButton.addEventListener(MouseEvent.CLICK, startTwitterSearch);
            _searchButton.enabled = true;
            _searchInput.addEventListener(Event.CHANGE,updateSearchKeywords);
            _searchInput.enabled = true;
          // add new buttons
          _buttonOne.addEventListener(MouseEvent.CLICK, buttonOneStartTwitterSearch);//the listener which detects the on click mouse event
          _buttonOne.enabled = true;//make sure the button is enabled or clickable
          _buttonTwo.addEventListener(MouseEvent.CLICK, buttonTwoStartTwitterSearch);
          _buttonTwo.enabled = true;
          //keep adding your desired number of buttons
        }

oh and revise the removeSearchFormListeners() method to remove the the listeners - just good coding practice

private function removeSearchFormListeners():void {
            _searchButton.removeEventListener(MouseEvent.CLICK, startTwitterSearch);
            _searchButton.enabled = false;
            _searchInput.removeEventListener(Event.CHANGE,updateSearchKeywords);
            _searchInput.enabled = false;
            //
            _buttonOne.removeEventListener(MouseEvent.CLICK, buttonOneStartTwitterSearch);
             _buttonOne.enabled = false;
            _buttonTwo.removeEventListener(MouseEvent.CLICK, buttonTwoStartTwitterSearch);
             _buttonTwo.enabled = false;
             //ect..ect.
          
        }

and  then add the 2 methods which those buttons call. The methods basically updates the search keyword and calls the searchTwitter() method

//method for button one

private function buttonOneStartTwitterSearch(event:MouseEvent):void {
           _currentSearchKeyword = “green giant washington”;
            searchTwitter();
        }

and

//method for button 2

private function buttonOneStartTwitterSearch(event:MouseEvent):void {
           _currentSearchKeyword = “flawless alligator escapes”;
            searchTwitter();
}


(3)  So when ever Twitter responds with results the onCompleteHandler() method is called. If you review the method you will notice that it:

           var sXml:XML = new XML(event.data);//receives the data in xml format
            _searchArray = DataParser.parseSearchResults(sXml);//parses the data into an array of objects
            createTweetPanel(_searchArray);//and then creates the Tweet Panel

In the createTweetPanel() method you will notice that I build the actual panel using an object in the library - new TweetPanel().
then I add it to stage like so:
 _content.addChild(tn); // which basically states to add the thumbnail object into the content Sprite - the equivalent in as2 is attach movieclip

Now you will notice that _content sprite is in the constructor which is where I actually do the placement:

_content.x = 20;
_content.y = 65;

So to move it around, just revise the numbers.

(4) Fonts is the reason why. You need to embed a font which handles the umlauts.

(5) Use a proxy. If I ever get around to it, I will post it for all to see. I need to get a blessing from my Php guru before I release it. 
In a nutshell this is what it does:

Flash calls the proxy passing a query string (search string). Php checks a results folder to see if a file exists with the search name (&quot;earthday.txt&quot;), if a file does exist it checks a time stamp to determine how old the file is, if its relatively new, it reads the text files content and returns the results to flash. If its real old, it removes the file and makes a new call to Twitter, returns the results to flash and writes the file to the results folder (caching).

If a file does not exist it makes a call to Twitter, returns the results to flash and writes the file to the results folder with a timestamp.

Anyhow good luck, and I hope this helps.

M</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>I&#8217;m sorry to hear you are stuck in AS2 land, but I&#8217;m glad you are making the transition to AS3. I&#8217;m not aware of an AS2 library that is readily available for you to implement into your current projects. To keep the whole project in AS2, I would recommend you use a different approach. As you may know by now, even if you altered the code above to your likings, you would not be able to use the AS3 approach, due to the issues of loading an AS3swf into an AS2swf, Google it. Tho, not the end of the world, you could probably come up with a wonky solution using Local Connection, but I wouldn&#8217;t advise it.  Instead I&#8217;m going to push you in a new direction, one that requires Flash to communicate with PHP. That way you can use your AS2 knowledge to load in php results. There are tons of Flash to PHP communication on the interwebs, fire up a Google search. </p>
<p>Here&#8217;s a link to Ryan Faermans blog post on a php solution to search twitter : <a href="http://ryanfaerman.com/twittersearch/" rel="nofollow">http://ryanfaerman.com/twittersearch/</a>.  You could easily alter his code to return the search values to flash. You could probably find tons more of php related Twitter functionality. As I mentioned in my post you will end up hitting Twitters query limit, and have to start looking for a proxy approach, so you might as well go down that road now. At this point I&#8217;m not sure if the questions you asked are relevant now, but here a few quick answers:</p>
<p>(1)  Easy, update the _currentSearchKeyword variable and call the searchTwitter() method in the constructor like so:</p>
<p>public function Main() {</p>
<p>            _content = new Sprite();<br />
            _content.x = 20;<br />
            _content.y = 65;<br />
            addChild(_content);<br />
            _searchButton = sButton;<br />
            _searchInput = sInput;<br />
            _searchInput.text = _currentSearchKeyword;<br />
            _twtr = new Tweetr();<br />
            addSearchFormListeners();<br />
           //update the search var<br />
           _currentSearchKeyword = “I love NY”;<br />
          //call the method<br />
          searchTwitter();</p>
<p>        }</p>
<p>(2) You could do this 2 ways: 1- create a new method call addSearchButton() and add the button listeners to it or 2- add to existing method addSearchFormListeners()</p>
<p>private function addSearchFormListeners():void {<br />
            _searchButton.addEventListener(MouseEvent.CLICK, startTwitterSearch);<br />
            _searchButton.enabled = true;<br />
            _searchInput.addEventListener(Event.CHANGE,updateSearchKeywords);<br />
            _searchInput.enabled = true;<br />
          // add new buttons<br />
          _buttonOne.addEventListener(MouseEvent.CLICK, buttonOneStartTwitterSearch);//the listener which detects the on click mouse event<br />
          _buttonOne.enabled = true;//make sure the button is enabled or clickable<br />
          _buttonTwo.addEventListener(MouseEvent.CLICK, buttonTwoStartTwitterSearch);<br />
          _buttonTwo.enabled = true;<br />
          //keep adding your desired number of buttons<br />
        }</p>
<p>oh and revise the removeSearchFormListeners() method to remove the the listeners &#8211; just good coding practice</p>
<p>private function removeSearchFormListeners():void {<br />
            _searchButton.removeEventListener(MouseEvent.CLICK, startTwitterSearch);<br />
            _searchButton.enabled = false;<br />
            _searchInput.removeEventListener(Event.CHANGE,updateSearchKeywords);<br />
            _searchInput.enabled = false;<br />
            //<br />
            _buttonOne.removeEventListener(MouseEvent.CLICK, buttonOneStartTwitterSearch);<br />
             _buttonOne.enabled = false;<br />
            _buttonTwo.removeEventListener(MouseEvent.CLICK, buttonTwoStartTwitterSearch);<br />
             _buttonTwo.enabled = false;<br />
             //ect..ect.</p>
<p>        }</p>
<p>and  then add the 2 methods which those buttons call. The methods basically updates the search keyword and calls the searchTwitter() method</p>
<p>//method for button one</p>
<p>private function buttonOneStartTwitterSearch(event:MouseEvent):void {<br />
           _currentSearchKeyword = “green giant washington”;<br />
            searchTwitter();<br />
        }</p>
<p>and</p>
<p>//method for button 2</p>
<p>private function buttonOneStartTwitterSearch(event:MouseEvent):void {<br />
           _currentSearchKeyword = “flawless alligator escapes”;<br />
            searchTwitter();<br />
}</p>
<p>(3)  So when ever Twitter responds with results the onCompleteHandler() method is called. If you review the method you will notice that it:</p>
<p>           var sXml:XML = new XML(event.data);//receives the data in xml format<br />
            _searchArray = DataParser.parseSearchResults(sXml);//parses the data into an array of objects<br />
            createTweetPanel(_searchArray);//and then creates the Tweet Panel</p>
<p>In the createTweetPanel() method you will notice that I build the actual panel using an object in the library &#8211; new TweetPanel().<br />
then I add it to stage like so:<br />
 _content.addChild(tn); // which basically states to add the thumbnail object into the content Sprite &#8211; the equivalent in as2 is attach movieclip</p>
<p>Now you will notice that _content sprite is in the constructor which is where I actually do the placement:</p>
<p>_content.x = 20;<br />
_content.y = 65;</p>
<p>So to move it around, just revise the numbers.</p>
<p>(4) Fonts is the reason why. You need to embed a font which handles the umlauts.</p>
<p>(5) Use a proxy. If I ever get around to it, I will post it for all to see. I need to get a blessing from my Php guru before I release it.<br />
In a nutshell this is what it does:</p>
<p>Flash calls the proxy passing a query string (search string). Php checks a results folder to see if a file exists with the search name (&#8220;earthday.txt&#8221;), if a file does exist it checks a time stamp to determine how old the file is, if its relatively new, it reads the text files content and returns the results to flash. If its real old, it removes the file and makes a new call to Twitter, returns the results to flash and writes the file to the results folder (caching).</p>
<p>If a file does not exist it makes a call to Twitter, returns the results to flash and writes the file to the results folder with a timestamp.</p>
<p>Anyhow good luck, and I hope this helps.</p>
<p>M</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/comment-page-1/#comment-616</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Tue, 23 Nov 2010 11:33:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codingcolor.com/?p=1779#comment-616</guid>
		<description>Hi,

Thanks for this amazing post! I have some questions about tweaking it a bit though. 

Just recently started the transition from AS2 to AS3 so I&#039;m fairly new to the language.

First things first. Are there any ways to accomplish this with AS2? Mainly because an update to existing sites/projects already created in AS2 would be great. I&#039;ve had a hard time to find AS2 examples.

1. If I&#039;d like to have this widget pull up tweets when it starts, instead of starting blank, how do I edit the code? Lets say I&#039;d start of with the search string &quot;I love NY&quot; upon start?

2. How to implement buttons with &#039;search-strings&#039; in the widget? Lets say button A has the words &quot;green giant washington&quot; and button B has the words &quot;flawless alligator escapes&quot;.

3. Where is the parameter to position the twitter result text field located within the code?

4. There seem to be a problem to show some characters in the twitter posts, in my case scandinavian umlauts (å,ä,æ,ö,ø). Any suggestions why?

5. You mention the twitter search limitation (I think it is 150 searches per hour) for high traffic websites. Reality is that it&#039;s not that hard to reach those numbers on an average site as well. Every time the page with the twitter widget is reloaded a new request is sent out. Do you have other suggestions to alternative suggestions?

Thanks for a great blog, Manuel</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>Thanks for this amazing post! I have some questions about tweaking it a bit though. </p>
<p>Just recently started the transition from AS2 to AS3 so I&#8217;m fairly new to the language.</p>
<p>First things first. Are there any ways to accomplish this with AS2? Mainly because an update to existing sites/projects already created in AS2 would be great. I&#8217;ve had a hard time to find AS2 examples.</p>
<p>1. If I&#8217;d like to have this widget pull up tweets when it starts, instead of starting blank, how do I edit the code? Lets say I&#8217;d start of with the search string &#8220;I love NY&#8221; upon start?</p>
<p>2. How to implement buttons with &#8216;search-strings&#8217; in the widget? Lets say button A has the words &#8220;green giant washington&#8221; and button B has the words &#8220;flawless alligator escapes&#8221;.</p>
<p>3. Where is the parameter to position the twitter result text field located within the code?</p>
<p>4. There seem to be a problem to show some characters in the twitter posts, in my case scandinavian umlauts (å,ä,æ,ö,ø). Any suggestions why?</p>
<p>5. You mention the twitter search limitation (I think it is 150 searches per hour) for high traffic websites. Reality is that it&#8217;s not that hard to reach those numbers on an average site as well. Every time the page with the twitter widget is reloaded a new request is sent out. Do you have other suggestions to alternative suggestions?</p>
<p>Thanks for a great blog, Manuel</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johnny IPL</title>
		<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/comment-page-1/#comment-296</link>
		<dc:creator>Johnny IPL</dc:creator>
		<pubDate>Thu, 01 Apr 2010 02:20:21 +0000</pubDate>
		<guid isPermaLink="false">http://www.codingcolor.com/?p=1779#comment-296</guid>
		<description>Good afternoon, This is a superb blog, and Allow me to agree with what was composed here. I will be back to see the comments soon. Thanks</description>
		<content:encoded><![CDATA[<p>Good afternoon, This is a superb blog, and Allow me to agree with what was composed here. I will be back to see the comments soon. Thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Salvador Brisbin</title>
		<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/comment-page-1/#comment-295</link>
		<dc:creator>Salvador Brisbin</dc:creator>
		<pubDate>Wed, 31 Mar 2010 02:27:42 +0000</pubDate>
		<guid isPermaLink="false">http://www.codingcolor.com/?p=1779#comment-295</guid>
		<description>Awesome blog post, thanks for keeping me busy!  Twitter RULES!</description>
		<content:encoded><![CDATA[<p>Awesome blog post, thanks for keeping me busy!  Twitter RULES!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: twitter layouts</title>
		<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/comment-page-1/#comment-283</link>
		<dc:creator>twitter layouts</dc:creator>
		<pubDate>Sun, 21 Mar 2010 11:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.codingcolor.com/?p=1779#comment-283</guid>
		<description>Hi, Great post about Twitter. I think Twitter is going to be one of the best networks because of the fact that it is supported by so many industries. I also think when Twitter shows some of it&#039;s new functions, returning traffic will increase to show the real growth of the network. Keep up the great work!</description>
		<content:encoded><![CDATA[<p>Hi, Great post about Twitter. I think Twitter is going to be one of the best networks because of the fact that it is supported by so many industries. I also think when Twitter shows some of it&#8217;s new functions, returning traffic will increase to show the real growth of the network. Keep up the great work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Flash AS3 Search Twitter API- Coding Color &#187; O Empreendedor Neófito</title>
		<link>http://www.codingcolor.com/as3/flash-as3-search-twitter-api/comment-page-1/#comment-273</link>
		<dc:creator>Flash AS3 Search Twitter API- Coding Color &#187; O Empreendedor Neófito</dc:creator>
		<pubDate>Wed, 10 Mar 2010 07:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.codingcolor.com/?p=1779#comment-273</guid>
		<description>[...] Go here to read the rest: Flash AS3 Search Twitter API- Coding Color [...]</description>
		<content:encoded><![CDATA[<p>[...] Go here to read the rest: Flash AS3 Search Twitter API- Coding Color [...]</p>
]]></content:encoded>
	</item>
</channel>
</rss>

