<?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"
> 
<channel>
	<title>Appcelerator Developer Center Q&amp;A Tag Feed (once)</title> 
	<atom:link href="http://developer.appcelerator.com/questions/feed/tag/once" rel="self" type="application/rss+xml" /> 
	<link>http://developer.appcelerator.com/questions/feed/tag/once</link> 
	<description>Appcelerator Developer Center Q&amp;A feed for the tag: "once"</description> 
	<lastBuildDate>Sun, 19 May 2013 04:43:00 -0700</lastBuildDate> 
	<pubDate>Sun, 19 May 2013 04:43:00 -0700</pubDate>
	<copyright>Copyright (c) 2008-2013 by Appcelerator Inc.</copyright>
	<webMaster>info@appcelerator.com</webMaster>
	<generator>Appcelerator Developer Center</generator>
	<ttl>5</ttl>
	<language>en</language>
	<item>
		<title>How to get webview load to fire once and then reset</title> 
		<link>http://developer.appcelerator.com/question/144848/how-to-get-webview-load-to-fire-once-and-then-reset</link>
		<pubDate>Mon, 19 Nov 2012 00:43:39 -0800</pubDate>
		<dc:creator>Ned Turner</dc:creator> 
				<category><![CDATA[webview]]></category> 
				<category><![CDATA[addeventlistener]]></category> 
				<category><![CDATA[load]]></category> 
				<category><![CDATA[once]]></category> 
				<guid isPermaLink="true">http://developer.appcelerator.com/question/144848/how-to-get-webview-load-to-fire-once-and-then-reset</guid>
		<description><![CDATA[Hi All

I am using webview load to detect when a page is loaded but i need it to only fire once but it fires many times i have come up with a solution below to get it fire once, but this will only happen once and once only i need it to fire every time a page is loaded but only once example.

~~~
webviewload = true;
webview.addEventListener('load', function() {

	if(webviewload){
 
	    //run code to add stuff to webview this will run once
            webview.remove(oldsidebar);
            webview.add(newsidebar);
            webviewload = false;
       }

});
~~~

the above works fine for one webview load but if you run again it is obviously set to false so i can only run this code once.

I found a hack that kind off works for me but i am looking for a better solution i understand its firing because it fires on every element load ads etc on webview.

~~~
webviewload = true;
webview.addEventListener('load', function() {

	if(webviewload){

	    //run code to add stuff to webview this will run once
            webview.remove(oldsidebar);
            webview.add(newsidebar);
            webviewload = false;
       }
       
       setTimeout(function(){
		webviewload = true;
	},5000)

});
~~~

ok above works but isn't ideal if the page take longer than 5 seconds to load etc i am getting problems.

Can anyone give me a suggestion on how to fire webview load once then reset so i can run a block of code correctly.

Hope this makes sense thanks]]></description>
		<content:encoded><![CDATA[<p>Hi All</p>

<p>I am using webview load to detect when a page is loaded but i need it to only fire once but it fires many times i have come up with a solution below to get it fire once, but this will only happen once and once only i need it to fire every time a page is loaded but only once example.
<pre class="javascript codeblock">webviewload <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span>
webview.<span class="me1">addEventListener</span><span class="br0">&#40;</span><span class="st0">'load'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
    <span class="kw1">if</span><span class="br0">&#40;</span>webviewload<span class="br0">&#41;</span><span class="br0">&#123;</span>
&nbsp;
        <span class="co1">//run code to add stuff to webview this will run once</span>
            webview.<span class="me1">remove</span><span class="br0">&#40;</span>oldsidebar<span class="br0">&#41;</span><span class="sy0">;</span>
            webview.<span class="me1">add</span><span class="br0">&#40;</span>newsidebar<span class="br0">&#41;</span><span class="sy0">;</span>
            webviewload <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span>
       <span class="br0">&#125;</span>
&nbsp;
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre>
the above works fine for one webview load but if you run again it is obviously set to false so i can only run this code once.</p>

<p>I found a hack that kind off works for me but i am looking for a better solution i understand its firing because it fires on every element load ads etc on webview.
<pre class="javascript codeblock">webviewload <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span>
webview.<span class="me1">addEventListener</span><span class="br0">&#40;</span><span class="st0">'load'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span>
&nbsp;
    <span class="kw1">if</span><span class="br0">&#40;</span>webviewload<span class="br0">&#41;</span><span class="br0">&#123;</span>
&nbsp;
        <span class="co1">//run code to add stuff to webview this will run once</span>
            webview.<span class="me1">remove</span><span class="br0">&#40;</span>oldsidebar<span class="br0">&#41;</span><span class="sy0">;</span>
            webview.<span class="me1">add</span><span class="br0">&#40;</span>newsidebar<span class="br0">&#41;</span><span class="sy0">;</span>
            webviewload <span class="sy0">=</span> <span class="kw2">false</span><span class="sy0">;</span>
       <span class="br0">&#125;</span>
&nbsp;
       setTimeout<span class="br0">&#40;</span><span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
        webviewload <span class="sy0">=</span> <span class="kw2">true</span><span class="sy0">;</span>
    <span class="br0">&#125;</span><span class="sy0">,</span><span class="nu0">5000</span><span class="br0">&#41;</span>
&nbsp;
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre>
ok above works but isn't ideal if the page take longer than 5 seconds to load etc i am getting problems.</p>

<p>Can anyone give me a suggestion on how to fire webview load once then reset so i can run a block of code correctly.</p>

<p>Hope this makes sense thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>Display alert message only once</title> 
		<link>http://developer.appcelerator.com/question/135281/display-alert-message-only-once</link>
		<pubDate>Thu, 12 Apr 2012 07:32:08 -0700</pubDate>
		<dc:creator>Markus Renström</dc:creator> 
				<category><![CDATA[window]]></category> 
				<category><![CDATA[alert]]></category> 
				<category><![CDATA[eventlistener]]></category> 
				<category><![CDATA[appear]]></category> 
				<category><![CDATA[once]]></category> 
				<guid isPermaLink="true">http://developer.appcelerator.com/question/135281/display-alert-message-only-once</guid>
		<description><![CDATA[I have a button, on click an alert appears and a new win will open.
~~~
button1.addEventListener('click', function(){
	var win1 = Ti.UI.createWindow({
    	url:'some.js',
  })
  
  {
	alert(&quot;Hello! You will only se me once :)&quot;);
}; 
	win1.open();
});
~~~
Is it possible to display this alert only once (it will never appear again)?]]></description>
		<content:encoded><![CDATA[<p>I have a button, on click an alert appears and a new win will open.<pre class="javascript codeblock">button1.<span class="me1">addEventListener</span><span class="br0">&#40;</span><span class="st0">'click'</span><span class="sy0">,</span> <span class="kw2">function</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="br0">&#123;</span>
    <span class="kw2">var</span> win1 <span class="sy0">=</span> Ti.<span class="me1">UI</span>.<span class="me1">createWindow</span><span class="br0">&#40;</span><span class="br0">&#123;</span>
        url<span class="sy0">:</span><span class="st0">'some.js'</span><span class="sy0">,</span>
  <span class="br0">&#125;</span><span class="br0">&#41;</span>
&nbsp;
  <span class="br0">&#123;</span>
    <span class="kw3">alert</span><span class="br0">&#40;</span><span class="st0">&quot;Hello! You will only se me once :)&quot;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="sy0">;</span> 
    win1.<span class="kw3">open</span><span class="br0">&#40;</span><span class="br0">&#41;</span><span class="sy0">;</span>
<span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span></pre>Is it possible to display this alert only once (it will never appear again)?</p>
]]></content:encoded>
	</item>
	<item>
		<title>How to start sound when android app starts</title> 
		<link>http://developer.appcelerator.com/question/119811/how-to-start-sound-when-android-app-starts</link>
		<pubDate>Tue, 17 May 2011 16:17:17 -0700</pubDate>
		<dc:creator>David Craigster</dc:creator> 
				<category><![CDATA[android]]></category> 
				<category><![CDATA[sound]]></category> 
				<category><![CDATA[started]]></category> 
				<category><![CDATA[play]]></category> 
				<category><![CDATA[once]]></category> 
				<guid isPermaLink="true">http://developer.appcelerator.com/question/119811/how-to-start-sound-when-android-app-starts</guid>
		<description><![CDATA[Hey there. Is there a way to start sound automatically once an android app has started? I can't find documentation on this site.
Thank you]]></description>
		<content:encoded><![CDATA[<p>Hey there. Is there a way to start sound automatically once an android app has started? I can't find documentation on this site.
Thank you</p>
]]></content:encoded>
	</item>
	<item>
		<title>Swipe Event, fire only once</title> 
		<link>http://developer.appcelerator.com/question/119816/swipe-event-fire-only-once</link>
		<pubDate>Tue, 17 May 2011 20:58:12 -0700</pubDate>
		<dc:creator>Clayton McIlrath</dc:creator> 
				<category><![CDATA[iphone]]></category> 
				<category><![CDATA[event]]></category> 
				<category><![CDATA[function]]></category> 
				<category><![CDATA[swipe]]></category> 
				<category><![CDATA[fire]]></category> 
				<category><![CDATA[call]]></category> 
				<category><![CDATA[only]]></category> 
				<category><![CDATA[once]]></category> 
				<guid isPermaLink="true">http://developer.appcelerator.com/question/119816/swipe-event-fire-only-once</guid>
		<description><![CDATA[I have a swipe event listener on window, and I want it to only call loadMug() which does an xhr request only once.. currently when I swipe it calls my function for each x position I've moved, what's the easiest way to do this? 

~~~
win.addEventListener('swipe', loadMug);
~~~]]></description>
		<content:encoded><![CDATA[<p>I have a swipe event listener on window, and I want it to only call loadMug() which does an xhr request only once.. currently when I swipe it calls my function for each x position I've moved, what's the easiest way to do this? 
<pre class="javascript codeblock">win.<span class="me1">addEventListener</span><span class="br0">&#40;</span><span class="st0">'swipe'</span><span class="sy0">,</span> loadMug<span class="br0">&#41;</span><span class="sy0">;</span></pre></p>
]]></content:encoded>
	</item>
</channel>
</rss>