<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-4936679048645236623</atom:id><lastBuildDate>Wed, 15 May 2019 11:47:32 +0000</lastBuildDate><category>ActionScript 3</category><category>Tips and Tricks</category><category>Text effects</category><category>Html5</category><category>Special effect</category><category>Games</category><category>ActionScript</category><category>Articles</category><category>Basics</category><category>Navigation</category><category>Audio</category><category>Freebies</category><category>Android</category><category>Animation</category><category>Xml</category><category>Away3D</category><category>Edge</category><category>React</category><category>Box2D</category><category>Git</category><category>Reviews</category><category>Starling</category><category>Video</category><title>ilike2Flash</title><description>Flash, Actionscript and programing</description><link>http://www.ilike2flash.com/</link><managingEditor>noreply@blogger.com (iliketo)</managingEditor><generator>Blogger</generator><openSearch:totalResults>389</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-588772671108330175</guid><pubDate>Sun, 07 Feb 2016 22:15:00 +0000</pubDate><atom:updated>2018-02-07T14:24:18.728-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">React</category><title>Drop down menu with ReactJS</title><description>I will be showing three code examples of drop down menus with ReactJS.&lt;br /&gt;&lt;br /&gt;The first example will be pure static content. The drop down menu items will be loaded and rendered at run time. I have used the ‘isOpen’ state variable to toggle the dropdown menu content from visible to invisible upon button click.&lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;import React, { Component } from &amp;#x27;react&amp;#x27;;&lt;br /&gt;import { render } from &amp;#x27;react-dom&amp;#x27;;&lt;br /&gt;&lt;br /&gt;class App extends Component {&lt;br /&gt;  constructor() {&lt;br /&gt;    super();&lt;br /&gt;    this.state = {&lt;br /&gt;      isOpen:false&lt;br /&gt;    };&lt;br /&gt;    this.onDropDown = this.onDropDown.bind(this);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  onDropDown(){&lt;br /&gt;    this.setState({isOpen: !this.state.isOpen});&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  render() {&lt;br /&gt;    return (&lt;br /&gt;      &amp;#x3C;div className=&amp;#x22;dropdown&amp;#x22;&amp;#x3E;&lt;br /&gt;        &amp;#x3C;button onClick={this.onDropDown}&amp;#x3E;Drop down example&amp;#x3C;/button&amp;#x3E;&lt;br /&gt;        &amp;#x3C;div className=&amp;#x22;dropdown-content&amp;#x22; style={{display:(this.state.isOpen)? &amp;#x22;block&amp;#x22;:&amp;#x22;none&amp;#x22;}}&amp;#x3E;&lt;br /&gt;          &amp;#x3C;ul&amp;#x3E;&lt;br /&gt;            &amp;#x3C;li&amp;#x3E;example 1&amp;#x3C;/li&amp;#x3E;&lt;br /&gt;            &amp;#x3C;li&amp;#x3E;example 2&amp;#x3C;/li&amp;#x3E;&lt;br /&gt;            &amp;#x3C;li&amp;#x3E;example 3&amp;#x3C;/li&amp;#x3E;&lt;br /&gt;          &amp;#x3C;/ul&amp;#x3E;&lt;br /&gt;        &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;      &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    );&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;render(&amp;#x3C;App /&amp;#x3E;, document.getElementById(&amp;#x27;root&amp;#x27;));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The second example is similar to the first one, however I will load the drop down items dynamically from state. I have added a ’dropItems’ array to the state to hold the contents of the drop down items. Note, I have used the javascript map() function to loop through the items in the ’dropItems’ array. A few things to remember when using the map() function with JSX: we have to wrap the code within a set of curly braces; the values to be rendered will also have to be wrapped in a set of curly braces and a special key attribute will need to be included. The key attribute helps React determine if items have be added, changed or removed. An error message will appear if the key attribute is not included. &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;import React, { Component } from &amp;#x27;react&amp;#x27;;&lt;br /&gt;import { render } from &amp;#x27;react-dom&amp;#x27;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;class App extends Component {&lt;br /&gt;  constructor() {&lt;br /&gt;    super();&lt;br /&gt;    this.state = {&lt;br /&gt;      isOpen:false,&lt;br /&gt;      dropItems:[&lt;br /&gt;        &amp;#x27;example 1&amp;#x27;,&lt;br /&gt;        &amp;#x27;example 2&amp;#x27;,&lt;br /&gt;        &amp;#x27;example 3&amp;#x27;&lt;br /&gt;      ]&lt;br /&gt;    };&lt;br /&gt;    this.onDropDown = this.onDropDown.bind(this);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  onDropDown(){&lt;br /&gt;    this.setState({isOpen: !this.state.isOpen});&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  render() {&lt;br /&gt;    return (&lt;br /&gt;      &amp;#x3C;div className=&amp;#x22;dropdown&amp;#x22;&amp;#x3E;&lt;br /&gt;        &amp;#x3C;button onClick={this.onDropDown}&amp;#x3E;Drop down example&amp;#x3C;/button&amp;#x3E;&lt;br /&gt;        &amp;#x3C;div className=&amp;#x22;dropdown-content&amp;#x22; style={{display:(this.state.isOpen)? &amp;#x22;block&amp;#x22;:&amp;#x22;none&amp;#x22;}}&amp;#x3E;&lt;br /&gt;          &amp;#x3C;ul&amp;#x3E;&lt;br /&gt;          {&lt;br /&gt;            this.state.dropItems.map(item =&amp;#x3E; {&lt;br /&gt;               return &amp;#x3C;li key={item}&amp;#x3E;{item}&amp;#x3C;/li&amp;#x3E; &lt;br /&gt;            })&lt;br /&gt;          }  &lt;br /&gt;          &amp;#x3C;/ul&amp;#x3E;&lt;br /&gt;        &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;      &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    );&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;render(&amp;#x3C;App /&amp;#x3E;, document.getElementById(&amp;#x27;root&amp;#x27;));&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  Finally, the last example will load the drop down menu items dynamically from an external source. I will be basing this example on my previous post: &lt;a href=&quot;http://www.ilike2flash.com/2016/01/loading-external-data-in-reactjs.html&quot; target=&quot;_self&quot;&gt;Loading external data in ReactJS&lt;/a&gt;. I will again be using the random Chunk Norris joke generator API with the Axios library. The joke API currently has over 500 jokes, I have limited the number of jokes to appear to only 5.  &lt;br /&gt;  &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;import React, { Component } from &amp;#x27;react&amp;#x27;;&lt;br /&gt;import { render } from &amp;#x27;react-dom&amp;#x27;;&lt;br /&gt;import axios from &amp;#x27;axios&amp;#x27;;&lt;br /&gt;&lt;br /&gt;class App extends Component {&lt;br /&gt;  constructor() {&lt;br /&gt;    super();&lt;br /&gt;    this.state = {&lt;br /&gt;      isOpen:false,&lt;br /&gt;      dropItems:[]&lt;br /&gt;    };&lt;br /&gt;    this.onDropDown = this.onDropDown.bind(this);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  onDropDown(){&lt;br /&gt;    this.setState({isOpen: !this.state.isOpen});&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  componentDidMount(){&lt;br /&gt;    axios.get(&amp;#x22;https://api.icndb.com/jokes&amp;#x22;).then((result) =&amp;#x3E; {&lt;br /&gt;        this.setState({dropItems: result.data.value});&lt;br /&gt;    });&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  render() {&lt;br /&gt;    return (&lt;br /&gt;      &amp;#x3C;div className=&amp;#x22;dropdown&amp;#x22;&amp;#x3E;&lt;br /&gt;        &amp;#x3C;button onClick={this.onDropDown}&amp;#x3E;Drop down example&amp;#x3C;/button&amp;#x3E;&lt;br /&gt;        &amp;#x3C;div className=&amp;#x22;dropdown-content&amp;#x22; style={{display:(this.state.isOpen)? &amp;#x22;block&amp;#x22;:&amp;#x22;none&amp;#x22;}}&amp;#x3E;&lt;br /&gt;          &amp;#x3C;ul&amp;#x3E;&lt;br /&gt;          {&lt;br /&gt;            this.state.dropItems.map((item, index) =&amp;#x3E; {&lt;br /&gt;               if(index &amp;#x3C; 5){&lt;br /&gt;                return &amp;#x3C;li key={item.id}&amp;#x3E;{item.joke}&amp;#x3C;/li&amp;#x3E; &lt;br /&gt;               }&lt;br /&gt;            })&lt;br /&gt;          }  &lt;br /&gt;          &amp;#x3C;/ul&amp;#x3E;&lt;br /&gt;        &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;      &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    );&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;render(&amp;#x3C;App /&amp;#x3E;, document.getElementById(&amp;#x27;root&amp;#x27;));&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2016/02/drop-down-menu-with-reactjs.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-1880418551470666857</guid><pubDate>Fri, 22 Jan 2016 22:10:00 +0000</pubDate><atom:updated>2017-10-10T14:24:21.570-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">React</category><title>Loading external data in ReactJS </title><description>A quick example of how to load an external JSON file in React. This post assumes you have ReactJS already set up. I will be using Axios to load the external data, but you can use any library you wish. Axios is a promise-style Ajax tool with similar API to jquery. &lt;br /&gt;&lt;br /&gt;For the external JSON data I have used the api from ’icndb’ which will load a JSON containing a Chuck Norris joke.   &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;var React = require(&amp;#x27;react&amp;#x27;);&lt;br /&gt;var ReactDOM = require(&amp;#x27;react-dom&amp;#x2019;);&lt;br /&gt;var axios = require(&amp;#x27;axios&amp;#x27;);&lt;br /&gt;&lt;br /&gt;var App = React.createClass({&lt;br /&gt;&lt;br /&gt;    getInitialState: function() {&lt;br /&gt;        return {joke:&amp;#x22;&amp;#x22;}&lt;br /&gt;    },&lt;br /&gt;    &lt;br /&gt;    componentDidMount: function() {&lt;br /&gt;        var _this = this;&lt;br /&gt;        axios.get(&amp;#x22;https://api.icndb.com/jokes/random&amp;#x22;).then(function(result) {&lt;br /&gt;            _this.setState({joke: result.data.value.joke});&lt;br /&gt;        });&lt;br /&gt;    },&lt;br /&gt;&lt;br /&gt;    render: function() {&lt;br /&gt;        return &amp;#x3C;p&amp;#x3E;{this.state.joke}&amp;#x3C;/p&amp;#x3E;&lt;br /&gt;    }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;ReactDOM.render(&amp;#x3C;App/&amp;#x3E;, document.getElementById(&amp;#x27;root&amp;#x27;));&lt;br /&gt;&lt;/pre&gt;Here is the same example written in ES6. &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;import React, { Component } from &amp;#x27;react&amp;#x27;;&lt;br /&gt;import ReactDOM from &amp;#x27;react-dom&amp;#x27;;&lt;br /&gt;import axios from &amp;#x27;axios&amp;#x27;;&lt;br /&gt;&lt;br /&gt;class App extends Component{&lt;br /&gt;  constructor(props){&lt;br /&gt;    super(props);&lt;br /&gt;    this.state = {&lt;br /&gt;      joke:&amp;#x22;&amp;#x22;&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  componentDidMount(){&lt;br /&gt;    axios.get(&amp;#x22;https://api.icndb.com/jokes/random&amp;#x22;).then((result) =&amp;#x3E; {&lt;br /&gt;        this.setState({joke: result.data.value.joke});&lt;br /&gt;    });&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  render() {&lt;br /&gt;      return &amp;#x3C;p&amp;#x3E;{this.state.joke}&amp;#x3C;/p&amp;#x3E;&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; Note, this is just purely an example of loading external data in React. It is generally bad practice to mix views with data fetching or manipulation - the two should stay separate.   &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2016/01/loading-external-data-in-reactjs.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-3529277899742664315</guid><pubDate>Sat, 02 Jan 2016 16:10:00 +0000</pubDate><atom:updated>2017-01-01T08:23:14.781-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">React</category><title>JSX Gotchas </title><description>When working with JSX and React there are a few things to be aware. This list will avoid any headaches when trying to debug your application or website. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;1. ClassName&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;In JSX any html tags with ‘class’ will have to be renamed to ‘className’. This is because ‘class’ is a reserved word in Javascript. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;2. Self closing tags&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;All tags in JSX must be closed with a self closing tag, &amp;lt;Example /&amp;gt; or a corresponding closing tag, &amp;lt;/Example&amp;gt;. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;3. Inline Styles&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Inline styles are not strings like standard HTML, they are Objects. The objects’s styles must be camel case, and the value as a string. Any vendor prefixes must be capital case. &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;var styles = {&lt;br /&gt;textAlign:’center’,&lt;br /&gt;color:’red’&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&amp;lt;div style={styles}&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;4. Render nested&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The render method can only return one node. Therefore if you have more than one component inside the render method, it must be wrapped in a containing div, span or component.  &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;var wrapper = React.createClass({&lt;br /&gt;  render:function(){&lt;br /&gt;    return (&lt;br /&gt;      &amp;lt;div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;/div&amp;gt;&lt;br /&gt;    )&lt;br /&gt;  }&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;5. Always use a key attribute for list components&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;When you are rendering a list of tags then you will need to use a key attribute. &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;var listExample = React.createClass({&lt;br /&gt;  render:function(){&lt;br /&gt;    &amp;lt;ul&amp;gt;&lt;br /&gt;    {this.props.items.map(function(i){&lt;br /&gt;      return &amp;lt;li key={i}&amp;gt;{items.name}&amp;lt;/li&amp;gt;&lt;br /&gt;    })}&lt;br /&gt;    &amp;lt;/ul&amp;gt;&lt;br /&gt; }&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2016/01/jsx-gotchas.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-3058862282865060580</guid><pubDate>Wed, 30 Dec 2015 22:55:00 +0000</pubDate><atom:updated>2016-12-15T15:08:17.689-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">React</category><title>ReactJS simple example</title><description>The best way to learn a new Javascript library is to write a simple bare-bones example. In this post I have a written a simple ReactJS example that displays the classic ‘Hello World’ message.  &lt;br /&gt;&lt;br /&gt;Firstly, we have our basic HTML5 structure including a div tag with the id ‘container’. The external Javascript files included are: the React library itself, and the React-dom library which provides the DOM specific methods. The empty script tag is where we will add the ReactJS code.  &lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;#x3C;!doctype html&amp;#x3E;&lt;br /&gt;&amp;#x3C;html&amp;#x3E;&lt;br /&gt;&amp;#x3C;head&amp;#x3E;&lt;br /&gt;    &amp;#x3C;meta charset=&amp;#x22;UTF-8&amp;#x22;&amp;#x3E;&lt;br /&gt;    &amp;#x3C;title&amp;#x3E;React Example&amp;#x3C;/title&amp;#x3E;&lt;br /&gt;&amp;#x3C;/head&amp;#x3E;&lt;br /&gt;&amp;#x3C;body&amp;#x3E;&lt;br /&gt;&amp;#x3C;div id=&amp;#x201C;container&amp;#x201D;&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;&amp;#x3C;script src=&amp;#x22;https://fb.me/react.js&amp;#x22;&amp;#x3E;&amp;#x3C;/script&amp;#x3E;&lt;br /&gt;&amp;#x3C;script src=&amp;#x22;https://fb.me/react-dom.js&amp;#x22;&amp;#x3E;&amp;#x3C;/script&amp;#x3E;&lt;br /&gt;&lt;br /&gt;&amp;#x3C;script&amp;#x3E;&lt;br /&gt;//Code goes here&lt;br /&gt;&amp;#x3C;/script&amp;#x3E;&lt;br /&gt;&lt;br /&gt;&amp;#x3C;/body&amp;#x3E;&lt;br /&gt;&amp;#x3C;/html&amp;#x3E;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Inside of the empty script tag add the following code below. React is built on the idea of components. Essential everything in a React app is part of a component. Our main component in the example is the App component.  &lt;br /&gt;&lt;br /&gt;A component is created using the createClass method. Every React component must have a render() method which states the HTML to be added to the page. The ReactDOM render() method adds the content from the App component to the div with the id ‘container’. The first argument is the App component and the second argument is a reference to the div.   &lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;var App = React.createClass({&lt;br /&gt;  render:function(){&lt;br /&gt;    return (&lt;br /&gt;      &amp;#x3C;div&amp;#x3E;&lt;br /&gt;      &amp;#x3C;p&amp;#x3E;Hello World&amp;#x3C;/p&amp;#x3E;&lt;br /&gt;      &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    );&lt;br /&gt;  }&lt;br /&gt;});&lt;br /&gt;ReactDOM.render(&amp;#x3C;App /&amp;#x3E;, document.getElementById(&amp;#x27;container&amp;#x27;)); &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;  You may have noticed the HTML content is inside the Javascript code. This is not official HTML, but is a new React concept called JSX which is basically a Javascript extension that allows you to write XML style tags. At runtime the HTML and Javascript get added to the DOM together.  &lt;br /&gt;&lt;br /&gt;We can also nest multiple components inside of the App component. In the following example I have created a ‘Hello World’ Component and added two instances inside of the App component.  &lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;var HelloWorld = React.createClass({&lt;br /&gt;  render:function(){&lt;br /&gt;    return (&lt;br /&gt;      &amp;#x3C;p&amp;#x3E;Hello World&amp;#x3C;/p&amp;#x3E;&lt;br /&gt;    )  &lt;br /&gt;  }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;var App = React.createClass({&lt;br /&gt;  render:function(){&lt;br /&gt;    return (&lt;br /&gt;      &amp;#x3C;div&amp;#x3E;&lt;br /&gt;        &amp;#x3C;HelloWorld /&amp;#x3E;&lt;br /&gt;        &amp;#x3C;HelloWorld /&amp;#x3E;&lt;br /&gt;      &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    );&lt;br /&gt;  }&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;ReactDOM.render(&amp;#x3C;App /&amp;#x3E;, document.getElementById(&amp;#x27;container&amp;#x27;)); &lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/12/reactjs-simple-example.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-3028844597421292286</guid><pubDate>Tue, 29 Dec 2015 21:36:00 +0000</pubDate><atom:updated>2015-12-29T13:36:18.497-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Youtube player HTML5 wrapper</title><description>To make the Youtube Player API easier to use, &lt;a href=&quot;https://github.com/ginpei/html5-youtube.js&quot;&gt;Ginpei&lt;/a&gt;, has created an excellent Youtube Javascript wrapper called html5-youtube.js. With this plugin, Youtube players can be embedded into your HTML page with ease. I have written a few examples below for future reference and for anyone else to learn.  &lt;br&gt;&lt;br&gt;The first example is self explanatory you replace the videoID with the Youtube video you want to use. For simplicity sake I have written all code on one page.  &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;lt;!doctype html&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;meta charset=&amp;quot;UTF-8&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Youtube player HTML5 wrapper example 1&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body onload=&amp;quot;init()&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;div id=&amp;quot;youtube-player&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;script src=&amp;quot;html5-youtube.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;script&amp;gt;&lt;br /&gt;        function init(){&lt;br /&gt;            var playerElement = document.querySelector(&amp;#39;#youtube-player&amp;#39;);&lt;br /&gt;            var videoId = &amp;#39;YL9RetC0ook&amp;#39;;&lt;br /&gt;            var player = youtube({ el:playerElement, id:videoId });&lt;br /&gt;        }&lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;The second example swaps the Youtube video depending on the button clicked. &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;lt;!doctype html&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;meta charset=&amp;quot;UTF-8&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Youtube player HTML5 wrapper example 2&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body onload=&amp;quot;init()&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;div id=&amp;quot;youtube-player&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;div&amp;gt;&lt;br /&gt;        &amp;lt;button class=&amp;quot;video1&amp;quot;&amp;gt;Video 1&amp;lt;/button&amp;gt;&lt;br /&gt;        &amp;lt;button class=&amp;quot;video2&amp;quot;&amp;gt;Video 2&amp;lt;/button&amp;gt;&lt;br /&gt;        &amp;lt;button class=&amp;quot;video3&amp;quot;&amp;gt;Video 3&amp;lt;/button&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;script src=&amp;quot;html5-youtube.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;script&amp;gt;&lt;br /&gt;        function init()&lt;br /&gt;        {&lt;br /&gt;            var playerElement = document.querySelector(&amp;#39;#youtube-player&amp;#39;);&lt;br /&gt;            var videoId = &amp;#39;YL9RetC0ook&amp;#39;;&lt;br /&gt;            var player = youtube({ el:playerElement, id:videoId });&lt;br /&gt;            &lt;br /&gt;            var button1 = document.querySelector(&amp;#39;.video1&amp;#39;);&lt;br /&gt;            var button2 = document.querySelector(&amp;#39;.video2&amp;#39;);&lt;br /&gt;            var button3 = document.querySelector(&amp;#39;.video3&amp;#39;);&lt;br /&gt;            &lt;br /&gt;            button1.addEventListener(&amp;#39;click&amp;#39;, swapVideo);&lt;br /&gt;            button2.addEventListener(&amp;#39;click&amp;#39;, swapVideo);&lt;br /&gt;            button3.addEventListener(&amp;#39;click&amp;#39;, swapVideo);&lt;br /&gt;            &lt;br /&gt;            function swapVideo(e)&lt;br /&gt;            {&lt;br /&gt;                switch(e.currentTarget.className)&lt;br /&gt;                {&lt;br /&gt;                    case &amp;#39;video1&amp;#39;:&lt;br /&gt;                        player.src = &amp;quot;YL9RetC0ook&amp;quot;;&lt;br /&gt;                        break;&lt;br /&gt;                    case &amp;#39;video2&amp;#39;:&lt;br /&gt;                         player.src = &amp;quot;G-og553jauM&amp;quot;;&lt;br /&gt;                        break;&lt;br /&gt;                    case &amp;#39;video3&amp;#39;:&lt;br /&gt;                        player.src = &amp;quot;KK9bwTlAvgo&amp;quot;;&lt;br /&gt;                        break;    &lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/12/youtube-player-html5-wrapper.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-3937319055272214773</guid><pubDate>Fri, 06 Nov 2015 21:31:00 +0000</pubDate><atom:updated>2016-06-06T13:45:51.542-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Speed up Brackets editor</title><description>When I am working on large projects I often find that Brackets becomes increasingly slow as the number of files increases. For example in your project you may have a node_modules and vendors folders. These folders can be particularly huge with all the file dependencies. You may even see a message: &quot;Error Indexing files... this project contains more than 30,000 files&quot;.  &lt;br&gt;&lt;br&gt;The slowness is caused by the indexing of all the files in a current project. I have found an extension called &lt;a href=&quot;https://github.com/JonathanWolfe/file-tree-exclude&quot;&gt;File tree exclude&lt;/a&gt; which ignores the large folders in a project which in turn will increase the speed of bracket.  &lt;br&gt;&lt;br&gt;Any suggestions leave a comment below. &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/11/speed-up-brackets-editor.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-5115590607245377911</guid><pubDate>Mon, 02 Nov 2015 22:28:00 +0000</pubDate><atom:updated>2015-11-06T14:32:15.998-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Gulp image resize for multiple images</title><description>I was looking for a way to automate multiple image resizing and found a Gulp plugin called Gulp-image-resize. This plugin uses the GraphicsMagick and ImageMagicks image processing system for the resizing.  &lt;br&gt;&lt;br&gt;A few posts I read online suggest chaining multiple image-resize pipes together. However, this was causing some undesired results. To overcome this I suggest to separate the chained image-resize script into different tasks then call a master resize task to invoke the other tasks.  &lt;br&gt;&lt;br&gt;This post assumes you have knowledge of Gulp and have the relevant plugins installed on your machine. In the example below I used only use the width option for imageResize which will ensure the output image won’t exceed the value and height will be automatically adjusted. I have also used a few additional modules such as gulp-changed and gulp-rename. &lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;var gulp         = require(&#39;gulp&#39;),&lt;br /&gt;var $            = require(&#39;gulp-load-plugins&#39;)();&lt;br /&gt;&lt;br /&gt;var imgPaths = {&lt;br /&gt;    src:&#39;./images/**/*.{jpg,png}&#39;,&lt;br /&gt;    dist:&#39;./images/&#39;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;gulp.task(&#39;img-resize-large&#39;, function(){&lt;br /&gt;    gulp.src(imgPaths.src)&lt;br /&gt;    .pipe($.changed(imgPaths.dist))&lt;br /&gt;    .pipe($.imageResize({width : 1436}))&lt;br /&gt;    .pipe($.rename({suffix: &#39;-1436&#39;}))&lt;br /&gt;    .pipe(gulp.dest(imgPaths.dist))&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;gulp.task(&#39;img-resize-medium&#39;, function(){&lt;br /&gt;    gulp.src(imgPaths.src)&lt;br /&gt;    .pipe($.changed(imgPaths.dist))&lt;br /&gt;    .pipe($.imageResize({width : 790}))&lt;br /&gt;    .pipe($.rename({suffix: &#39;-790&#39;}))&lt;br /&gt;    .pipe(gulp.dest(imgPaths.dist))&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;gulp.task(&#39;img-resize-small&#39;, function(){&lt;br /&gt;    gulp.src(imgPaths.src)&lt;br /&gt;    .pipe($.changed(imgPaths.dist))&lt;br /&gt;    .pipe($.imageResize({width : 474}))&lt;br /&gt;    .pipe($.rename({suffix: &#39;-474&#39;}))&lt;br /&gt;    .pipe(gulp.dest(imgPaths.dist))&lt;br /&gt;  &lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;gulp.task(&#39;img-resize&#39;, [&#39;img-resize-large&#39;,&#39;img-resize-medium&#39;,&#39;img-resize-small&#39;]);&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/11/gulp-image-resize-for-multiple-images.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-367670538638139247</guid><pubDate>Sun, 24 May 2015 21:36:00 +0000</pubDate><atom:updated>2017-05-24T14:43:17.483-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Setup Gulp with Browserify</title><description>After reading many long-winded posts online about setting up Gulp with Browserify. I have decided to write a basic no-frills example to setup Gulp with Browserify in only two steps. Before we begin I assume you have have some understanding of the terminal, npm and Gulp.&lt;br /&gt;&lt;br /&gt;&lt;b&gt;1 - Install dependencies&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Firstly, we have to create our ‘package.json’&amp;nbsp; file and installed all our required dependencies. Run the following commands in the terminal.&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;npm init -y&lt;br /&gt;npm install -save gulp browserify vinyl-buffer vinyl-source-stream&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;&lt;br /&gt;2 - Gulpfile &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;Type the following into the gulpfile.js&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;// ---------------------------------------------------------&lt;br /&gt;// DEPENDENCIES&lt;br /&gt;// ---------------------------------------------------------&lt;br /&gt;var gulp         = require(&#39;gulp&#39;),&lt;br /&gt;    browserify   = require(&#39;browserify&#39;),&lt;br /&gt;    source       = require(&#39;vinyl-source-stream&#39;),&lt;br /&gt;    buffer       = require(&quot;vinyl-buffer&quot;);&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ---------------------------------------------------------&lt;br /&gt;//SOURCE PATHS&lt;br /&gt;// ---------------------------------------------------------&lt;br /&gt;var BASEPATH = &quot;./src&quot;;&lt;br /&gt;var BUILDPATH = &quot;./dist&quot;;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;var jsPaths = {&lt;br /&gt;  jsFile:&quot;app.js&quot;,&lt;br /&gt;  jsSrc:BASEPATH + &quot;/js&quot;,&lt;br /&gt;  jsDist:BUILDPATH + &quot;/js&quot;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;// ---------------------------------------------------------&lt;br /&gt;// JS - dev (BROWSERIFY)&lt;br /&gt;// --------------------------------------------------------------&lt;br /&gt;gulp.task(&#39;browserify&#39;, function(){&lt;br /&gt;  return browserify({&lt;br /&gt;    entries:jsPaths.jsSrc + jsPaths.jsFile,&lt;br /&gt;    debug:true&lt;br /&gt;  })&lt;br /&gt;  .bundle()&lt;br /&gt;  .on(&quot;error&quot;, $.notify.onError(function(error) {&lt;br /&gt;        return &quot;Browserify Error: &quot; + error.message;&lt;br /&gt;  }))&lt;br /&gt;  .pipe(source(&#39;bundle.js&#39;))&lt;br /&gt;  .pipe(gulp.dest(jsPaths.jsSrc));&lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;You should now have a bare-bones example of setting up Gulp with Browserify. I hope this post was self-explanatory and easy to understand. If you have any questions feel free to leave a comment below.&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/05/setup-gulp-with-browserify.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-8624387896753239656</guid><pubDate>Sun, 24 May 2015 09:46:00 +0000</pubDate><atom:updated>2016-07-24T02:50:17.638-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Git</category><title>Git multi-line commit message</title><description>It is possible to write multi-line commit messages instead of one single line message. In the terminal you would type the following command.  &lt;br&gt; &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;git commit -m &quot;this&lt;br /&gt;&gt; is a multi-line&lt;br /&gt;&gt; commit message&quot;&lt;br /&gt;&lt;/pre&gt;As you can see above, instead of using a closing quotation mark, you would press the enter followed by this “&gt;” symbol. This will put the commit message on a new line.  &lt;br&gt;&lt;br&gt;An alternative method is to use multiple -m symbols like the following command.  &lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;git commit -m “this is a multi-line” -m “commit message”&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/05/git-multi-line-commit-message.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-5244280403405710493</guid><pubDate>Thu, 09 Apr 2015 11:26:00 +0000</pubDate><atom:updated>2015-12-31T04:29:19.549-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>HTML5 image place holders</title><description>Occasionally I use place holder images for web projects when an image asset has not been created or signed off yet. Often this would entail locating a random image online or even creating a temporary one with Photoshop.   &lt;br&gt;&lt;br&gt;However, I found a useful website, placehold.it, that auto generates a place holder image based on the input value. For example, http://placehold.it/200x200 will generate an image that is 200 x 200 pixels and also display the image dimensions on the image.  &lt;br&gt;&lt;br&gt;To use in HTML, you would use the following code: &lt;br&gt;&lt;pre class=&#39;source-code&#39;&gt;&lt;br /&gt;&amp;lt;img src=&amp;quot;http://placehold.it/200x200&amp;quot;&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/04/html5-image-place-holders.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-2045385070731058822</guid><pubDate>Sat, 21 Mar 2015 22:05:00 +0000</pubDate><atom:updated>2015-03-25T15:15:48.465-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Fast Android Studio emulator</title><description>The Android studio default emulator can run sluggish at times and can often take up to five minutes to start depending on the power of your machine. Due to the long waiting times I found a quick emulator solution called GenyMotion. &lt;br /&gt;&lt;br /&gt;To get started with GenyMotion a few essentials things will have to be installed. Firstly, visit the &lt;a href=&quot;https://www.genymotion.com/&quot;&gt;website&lt;/a&gt; and register an account. Once you have registered you can download and install on your machine. &lt;br /&gt;&lt;br /&gt;The Android Studio plugin for GenyMotion will also need to be installed. From the Android Studio Welcome page select Configure &amp;gt; Plugins. Then search for GenyMotion in the search box and install. When the plugin is installed you should see an icon like the image below in your toolbar. &lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-ZwHtqxcoZaY/VRMyL8FGwdI/AAAAAAAAATI/_wquBmfmQHs/s1600/faster-android-emulator-1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-ZwHtqxcoZaY/VRMyL8FGwdI/AAAAAAAAATI/_wquBmfmQHs/s1600/faster-android-emulator-1.jpg&quot; height=&quot;33&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;The plugin will have to be configured so it can run when you test an application. In the plugin settings add the path to the GenyMotion application.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-WnmDxP4vvjU/VRMyfB7kPvI/AAAAAAAAATQ/VF6T2O2Nvqo/s1600/faster-android-emulator-2.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-WnmDxP4vvjU/VRMyfB7kPvI/AAAAAAAAATQ/VF6T2O2Nvqo/s1600/faster-android-emulator-2.jpg&quot; height=&quot;197&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Finally the VirtualBox host will also have to be downloaded and installed. Ensure you select the correct operation system.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://2.bp.blogspot.com/-SYwOoe73OG0/VRMyqENhffI/AAAAAAAAATY/ly0qYvhVu6I/s1600/faster-android-emulator-3.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://2.bp.blogspot.com/-SYwOoe73OG0/VRMyqENhffI/AAAAAAAAATY/ly0qYvhVu6I/s1600/faster-android-emulator-3.jpg&quot; height=&quot;216&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;To get started with GenyMotion you firstly have to add a virtual device by selecting the Add button. Once you have selected the device you want to install, the files will be downloaded automatically and ready for use next time the application is run in Android studio.&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;http://1.bp.blogspot.com/-lVYJmtXwz4k/VRMzXYcOE5I/AAAAAAAAATg/ygCLja6_gzI/s1600/faster-android-emulator-4.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://1.bp.blogspot.com/-lVYJmtXwz4k/VRMzXYcOE5I/AAAAAAAAATg/ygCLja6_gzI/s1600/faster-android-emulator-4.jpg&quot; height=&quot;400&quot; width=&quot;252&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/03/fast-android-studio-emulator.html</link><author>noreply@blogger.com (iliketo)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-ZwHtqxcoZaY/VRMyL8FGwdI/AAAAAAAAATI/_wquBmfmQHs/s72-c/faster-android-emulator-1.jpg" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-1928849343799631771</guid><pubDate>Mon, 16 Feb 2015 20:12:00 +0000</pubDate><atom:updated>2016-04-28T12:14:59.274-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Git</category><title>Remove Node Modules from Git repo</title><description>On the rare occasion that anyone accidentally pushes the ‘Node_Modules’ folder into their Git repository. This snippet of code will remove and push the ‘Node_Modules’ folder back to your repository.  &lt;br&gt; &lt;pre class=&quot;source-code&quot;&gt;git rm -r --cached node_modules&lt;br /&gt;git commit -m &#39;Remove the node_modules folder&#39;&lt;br /&gt;git push origin master&lt;br /&gt;&lt;/pre&gt; Of course you would also add the .gitignore file to exclude the ‘Node_Modules’ folder at this point. &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/02/remove-node-modules-from-git-repo.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-1259897937770590816</guid><pubDate>Fri, 13 Feb 2015 22:48:00 +0000</pubDate><atom:updated>2016-04-13T14:58:30.529-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Git</category><title>Git delete remote branches</title><description>Often when a feature branch has been merged and deployed, the branch will still exist on the remote server until it has been removed. To remove all remote branches from a git server than no longer exist we can use the following Git command. &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;git remote prune origin&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/02/git-delete-remote-branches.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-1764366831510996438</guid><pubDate>Tue, 06 Jan 2015 23:52:00 +0000</pubDate><atom:updated>2015-03-16T16:00:13.775-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Pass data between activities in Android</title><description>Continuing on from using &lt;a href=&quot;http://www.ilike2flash.com/2015/01/start-new-activity-in-android.html&quot;&gt;Intents to Start a new Activity&lt;/a&gt; in Android from my last post I will be passing data between activities using Intent. I will be passing string data with Intents however a collection of other data types are also possible. See the &lt;a href=&quot;http://developer.android.com/reference/android/content/Intent.html&quot;&gt;Intent API&lt;/a&gt; for full list.   &lt;br /&gt;&lt;br /&gt;I have the same setup from the last post with two activities, but this time I will add an Edit text field into the activity_main.xml file. &lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&amp;lt;RelativeLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot; &lt;br /&gt;    android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;    android:layout_height=&amp;quot;match_parent&amp;quot; &lt;br /&gt;    android:paddingLeft=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;    android:paddingRight=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;    android:paddingTop=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;    android:paddingBottom=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;    tools:context=&amp;quot;.MainActivity&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;EditText&lt;br /&gt;        android:id=&amp;quot;@+id/editText&amp;quot;&lt;br /&gt;        android:layout_width=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;        android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;        android:layout_centerHorizontal=&amp;quot;true&amp;quot;&lt;br /&gt;        android:hint=&amp;quot;Edit text messaga&amp;quot;/&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;Button&lt;br /&gt;        android:id=&amp;quot;@+id/button&amp;quot;&lt;br /&gt;        android:layout_width=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;        android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;        android:layout_centerHorizontal=&amp;quot;true&amp;quot;&lt;br /&gt;        android:layout_below=&amp;quot;@id/editText&amp;quot;&lt;br /&gt;        android:text=&amp;quot;Start new Activity&amp;quot;/&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In the MainActivity.java I have used the putExtra() method to pass string data to the SecondActivity.class. &lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;import android.app.Activity;&lt;br /&gt;import android.content.Intent;&lt;br /&gt;import android.os.Bundle;&lt;br /&gt;import android.view.View;&lt;br /&gt;import android.widget.Button;&lt;br /&gt;import android.widget.EditText;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;public class MainActivity extends Activity {&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;        super.onCreate(savedInstanceState);&lt;br /&gt;        setContentView(R.layout.activity_main);&lt;br /&gt;&lt;br /&gt;        final EditText editText = (EditText) findViewById(R.id.editText);&lt;br /&gt;        &lt;br /&gt;        Button button = (Button) findViewById(R.id.button);&lt;br /&gt;        button.setOnClickListener(new View.OnClickListener() {&lt;br /&gt;            @Override&lt;br /&gt;            public void onClick(View v) {&lt;br /&gt;&lt;br /&gt;                Intent intent = new Intent(MainActivity.this, SecondActivity.class);&lt;br /&gt;                intent.putExtra(&quot;MESSAGE&quot;, editText.getText().toString());&lt;br /&gt;                startActivity(intent);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In the SecondActivity.java I have used the getIntent() method to retrieve the data from the Intent in the MainActivity.java file. I also have a Textview in the activity_second.xml layout with the id “secondActivityText” which will display the text from the EditText.  &lt;br /&gt;&lt;br /&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;import android.app.Activity;&lt;br /&gt;import android.content.Intent;&lt;br /&gt;import android.os.Bundle;&lt;br /&gt;import android.widget.TextView;&lt;br /&gt;&lt;br /&gt;public class SecondActivity extends Activity {&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;        super.onCreate(savedInstanceState);&lt;br /&gt;        setContentView(R.layout.activity_second);&lt;br /&gt;&lt;br /&gt;        Intent intent = getIntent();&lt;br /&gt;        String message = intent.getStringExtra(&quot;MESSAGE&quot;);&lt;br /&gt;&lt;br /&gt;        TextView textView = (TextView) findViewById(R.id.secondActivityText);&lt;br /&gt;        textView.setText(message);&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;           &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/01/pass-data-between-activities-in-android.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-2488316035719443664</guid><pubDate>Sun, 04 Jan 2015 16:13:00 +0000</pubDate><atom:updated>2015-03-15T08:19:34.318-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Start a new Activity in Android</title><description>I will be showing how to start a new activity in Android with Android studio. Firstly, this post assumes Android studio is already installed on your machine and a new project has already been setup with a Black Activity.  &lt;br /&gt;&lt;br /&gt;My activitiy_main.xml layout has one button with the id &quot;button&quot; with the text &quot;Start new Activity&quot;. This button will open up a new Activity when it is clicked.  &lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;&amp;lt;RelativeLayout xmlns:android=&amp;quot;http://schemas.android.com/apk/res/android&amp;quot;&lt;br /&gt;    xmlns:tools=&amp;quot;http://schemas.android.com/tools&amp;quot; &lt;br /&gt;    android:layout_width=&amp;quot;match_parent&amp;quot;&lt;br /&gt;    android:layout_height=&amp;quot;match_parent&amp;quot; &lt;br /&gt;    android:paddingLeft=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;    android:paddingRight=&amp;quot;@dimen/activity_horizontal_margin&amp;quot;&lt;br /&gt;    android:paddingTop=&amp;quot;@dimen/activity_vertical_margin&amp;quot;&lt;br /&gt;    android:paddingBottom=&amp;quot;@dimen/activity_vertical_margin&amp;quot; &lt;br /&gt;    tools:context=&amp;quot;.MainActivity&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;Button&lt;br /&gt;        android:id=&amp;quot;@+id/button&amp;quot;&lt;br /&gt;        android:layout_width=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;        android:layout_height=&amp;quot;wrap_content&amp;quot;&lt;br /&gt;        android:text=&amp;quot;Start new Activity&amp;quot;&lt;br /&gt;        android:layout_centerHorizontal=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/RelativeLayout&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In my MainActivity.java file I have added a click event listener to the button. Inside my onClick function I have used an Intent Object. An Intent object &quot;provides runtime binding between component&quot; which basically means you can use it to pass data between activities. The intent has two parameters, the first is the current activity and the second is the Activity to be started. The &quot;SecondActivity.class&quot; will be created in the next step.  &lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;import android.app.Activity;&lt;br /&gt;import android.content.Intent;&lt;br /&gt;import android.os.Bundle;&lt;br /&gt;import android.view.View;&lt;br /&gt;import android.widget.Button;&lt;br /&gt;&lt;br /&gt;public class MainActivity extends Activity {&lt;br /&gt;&lt;br /&gt;    @Override&lt;br /&gt;    protected void onCreate(Bundle savedInstanceState) {&lt;br /&gt;        super.onCreate(savedInstanceState);&lt;br /&gt;        setContentView(R.layout.activity_main);&lt;br /&gt;&lt;br /&gt;        Button button = (Button) findViewById(R.id.button);&lt;br /&gt;        button.setOnClickListener(new View.OnClickListener() {&lt;br /&gt;            @Override&lt;br /&gt;            public void onClick(View v) {&lt;br /&gt;&lt;br /&gt;                Intent intent = new Intent(MainActivity.this, SecondActivity.class);&lt;br /&gt;                startActivity(intent);&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;        });&lt;br /&gt;    }&lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;To create the secondActivity, in your Project panel, right click on the java folder and select New &gt; Activity &gt; Blank Activity. Give the activity name: &quot;SecondActivity&quot; Android studio should automatically fill in the other fields for you. Click Finish to add the SecondActivity to the project. &lt;br /&gt;&lt;br /&gt;Run the App and click the &quot;Start new Activity&quot; button. The new activity will open up.    &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/01/start-new-activity-in-android.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-1113276025389706238</guid><pubDate>Sat, 03 Jan 2015 21:51:00 +0000</pubDate><atom:updated>2015-03-18T13:57:12.099-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Android</category><title>Portrait or landscape screen in Android</title><description>The screen orientation of an Android application can be locked to portrait or landscape mode. It is relatively easy to set the screen orientation by using the screenOrientation property in the manifest file. Each activity to be locked will need to have screenOrientation property added.  &lt;br /&gt;&lt;br /&gt;To set the orientation to portrait mode. You can use portrait property like below.  &lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;&amp;lt;activity android:name=&amp;quot;.MainActivity&amp;quot; android:screenOrientation=&amp;quot;portrait&amp;quot; /&amp;gt;&lt;/pre&gt;&lt;br /&gt;If you want to set the orientation to landscape mode. You can use the landscape property like below.  &lt;pre class=&#39;source-code&#39;&gt;&amp;lt;activity android:name=&amp;quot;.MainActivity&amp;quot; android:screenOrientation=&amp;quot;landscape&amp;quot; /&amp;gt;&lt;/pre&gt;&lt;br /&gt;The screen orientation can also be set programmatically with code using this below.  &lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);&lt;/pre&gt;Or this below.  &lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2015/01/portrait-or-landscape-screen-in-android.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-4754025363253689019</guid><pubDate>Fri, 12 Sep 2014 21:24:00 +0000</pubDate><atom:updated>2015-10-12T14:28:45.362-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Draggable container in EaselJS</title><description>I needed to create a dragging container in EaselJS whereby all objects in the container are moved by the mouse. &lt;br&gt;&lt;br&gt;I found a solution online and it suggested creating a rectangle shape the size of the stage and adding ‘mousedown’ and ‘mousemove’ events to the shape. The only problem with this solution is that the container child objects will not be clickable because the draggable rectangle shape is covering the clickable objects.  &lt;br&gt;&lt;br&gt;To overcome this issue I decided not to use the rectangle shape, but to add ‘stagemousedown’ and ‘stagemousemove’ events onto the stage. This way the container child objects will still be clickable as well as draggable.   &lt;br&gt;&lt;br&gt;Here is the example code below, and an live example can be seen &lt;a href=&quot;http://codepen.io/ilike2/pen/GpvQeY&quot;&gt;here&lt;/a&gt;.  &lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;lt;!doctype html&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;style&amp;gt; &lt;br /&gt;        html,body{padding:0; margin:0;}&lt;br /&gt;        #canvas{background-color: #000000;} &lt;br /&gt;    &amp;lt;/style&amp;gt; &lt;br /&gt;    &amp;lt;script src=&amp;quot;easeljs.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;    &amp;lt;body onload=&amp;quot;init()&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;canvas id=&amp;quot;canvas&amp;quot; width=&amp;quot;800&amp;quot; height=&amp;quot;600&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt;&lt;br /&gt;    &amp;lt;script&amp;gt;&lt;br /&gt;    var stage, containerDrag, dragOffset;&lt;br /&gt;    &lt;br /&gt;    function init(){&lt;br /&gt;        //setup stage&lt;br /&gt;        stage = new createjs.Stage(&amp;#39;canvas&amp;#39;);&lt;br /&gt;        createjs.Ticker.addEventListener(&amp;quot;tick&amp;quot;, tick);&lt;br /&gt;        createjs.Ticker.setFPS(60); &lt;br /&gt;        &lt;br /&gt;        //drag container&lt;br /&gt;        containerDrag = new createjs.Container();&lt;br /&gt;        stage.addChild(containerDrag);&lt;br /&gt;        &lt;br /&gt;        //stage listeners &lt;br /&gt;        stage.addEventListener(&amp;quot;stagemousedown&amp;quot;, startDrag);   &lt;br /&gt;        stage.addEventListener(&amp;quot;stagemouseup&amp;quot;, stopDrag); &lt;br /&gt;        dragOffset = new createjs.Point();&lt;br /&gt;&lt;br /&gt;        &lt;br /&gt;        //add random shapes to container&lt;br /&gt;        for(var i = 0; i &amp;lt; 100; i++){&lt;br /&gt;            var rect = new createjs.Shape();&lt;br /&gt;            rect.graphics.beginFill(&amp;#39;#ff0000&amp;#39;).drawRect(0,0,getRandom(10, 30), getRandom(10, 30));&lt;br /&gt;            rect.x = getRandom(0, stage.canvas.width);&lt;br /&gt;            rect.y = getRandom(0, stage.canvas.height);&lt;br /&gt;            containerDrag.addChild(rect);&lt;br /&gt;        }&lt;br /&gt;      &lt;br /&gt;    }    &lt;br /&gt;    &lt;br /&gt;    //draggable listeners&lt;br /&gt;    function startDrag(){&lt;br /&gt;        dragOffset.x = stage.mouseX - containerDrag.x;&lt;br /&gt;        dragOffset.y = stage.mouseY - containerDrag.y;&lt;br /&gt;        stage.addEventListener(&amp;quot;stagemousemove&amp;quot;, moveDrag);   &lt;br /&gt;    }   &lt;br /&gt;        &lt;br /&gt;    function stopDrag(){&lt;br /&gt;         stage.removeEventListener(&amp;quot;stagemousemove&amp;quot;, moveDrag);   &lt;br /&gt;    } &lt;br /&gt;        &lt;br /&gt;    function moveDrag(e){&lt;br /&gt;      containerDrag.x = e.stageX - dragOffset.x;&lt;br /&gt;      containerDrag.y = e.stageY - dragOffset.y;&lt;br /&gt;    }    &lt;br /&gt;    &lt;br /&gt;    //random utility function    &lt;br /&gt;    function getRandom(min, max){&lt;br /&gt;        return min + (Math.random() * (max-min));&lt;br /&gt;    }  &lt;br /&gt;        &lt;br /&gt;    function tick(e){&lt;br /&gt;        stage.update();&lt;br /&gt;    }&lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/09/draggable-container-in-easeljs.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-3176651127473979950</guid><pubDate>Wed, 27 Aug 2014 09:42:00 +0000</pubDate><atom:updated>2015-09-27T02:51:42.337-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Sync browser and devices</title><description>I found a really good open source tool called Browser sync that syncs multiple browsers and devices at the same time. This means if you make a change in the HTML/CSS/JS all the browsers and devices you have linked up will update live without having to refresh. This makes if useful for cross-device testing and development.   &lt;br&gt;&lt;br&gt;To use Browser sync you firstly need to have Npm installed on your machine. Open up a terminal, I’m using a mac, and type the following command.  &lt;br&gt;&lt;pre class=&#39;source-code&#39;&gt;npm install -g browser-sync&lt;/pre&gt;&lt;br&gt;This will install Browser sync globally on your machine so will be available for all your projects. Once Browser sync is installed you will have to ‘cd’ into the folder and use the following command.  &lt;br&gt;&lt;pre class=&#39;source-code&#39;&gt;browser-sync start --server --files&lt;/pre&gt;&lt;br&gt;Another impressive feature of the Browesr sync is the ‘Interaction sync’ where the click, scroll and form data entry and all mirrored in the devices and browsers.&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/08/sync-browser-and-devices.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-6827140132890036930</guid><pubDate>Sat, 05 Jul 2014 21:54:00 +0000</pubDate><atom:updated>2015-07-05T15:06:33.542-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Display location weather in Javascript</title><description>This is an example of a HTML/JS app to display the weather based on the current location using the public API from openweather.org. If the user denies permission to share the location, a dialog window will appear for the user to enter a postcode.  &lt;br&gt;&lt;br&gt;   In my HTML file I have essentially two main div’s. One of the divs displays the current weather if the user accepts the Geolocation permissions, and the other div shows a dialog box if the user does not accept the Geolocation permissions.  &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;#x3C;!doctype html&amp;#x3E;&lt;br /&gt;&amp;#x3C;html lang=&amp;#x22;en&amp;#x22;&amp;#x3E;&lt;br /&gt;&amp;#x3C;head&amp;#x3E;&lt;br /&gt;  &amp;#x3C;meta charset=&amp;#x22;utf-8&amp;#x22;&amp;#x3E;&lt;br /&gt;  &amp;#x3C;meta http-equiv=&amp;#x22;X-UA-Compatible&amp;#x22; content=&amp;#x22;IE=edge&amp;#x22;&amp;#x3E;&lt;br /&gt;  &amp;#x3C;title&amp;#x3E;Weather&amp;#x3C;/title&amp;#x3E;&lt;br /&gt;&lt;br /&gt;  &amp;#x3C;meta name=&amp;#x22;viewport&amp;#x22; content=&amp;#x22;width=device-width, initial-scale=1.0&amp;#x22;&amp;#x3E;&lt;br /&gt;  &amp;#x3C;link href=&amp;#x27;http://fonts.googleapis.com/css?family=Roboto&amp;#x27; rel=&amp;#x27;stylesheet&amp;#x27; type=&amp;#x27;text/css&amp;#x27;&amp;#x3E;&lt;br /&gt;  &amp;#x3C;link rel=&amp;#x22;stylesheet&amp;#x22; href=&amp;#x22;css/style.css&amp;#x22;&amp;#x3E;&lt;br /&gt;&amp;#x3C;/head&amp;#x3E;&lt;br /&gt;&amp;#x3C;body&amp;#x3E;&lt;br /&gt;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;container&amp;#x22;&amp;#x3E;&lt;br /&gt;        &lt;br /&gt;        &amp;#x3C;div class=&amp;#x22;weather&amp;#x22;&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;        &lt;br /&gt;        &amp;#x3C;div class=&amp;#x22;noweather&amp;#x22;&amp;#x3E;&lt;br /&gt;            &amp;#x3C;div class=&amp;#x22;postcodeContainer&amp;#x22;&amp;#x3E;  &lt;br /&gt;                &amp;#x3C;p class=&amp;#x22;postcode-msg&amp;#x22;&amp;#x3E;Please enter postcode&amp;#x3C;/p&amp;#x3E;&lt;br /&gt;                &amp;#x3C;input type=&amp;#x22;text&amp;#x22; class=&amp;#x22;postcodeText&amp;#x22; id=&amp;#x22;postcode&amp;#x22; placeholder=&amp;#x22;Postcode search&amp;#x22; val=&amp;#x22;&amp;#x22;/&amp;#x3E;&lt;br /&gt;                &amp;#x3C;input type=&amp;#x22;submit&amp;#x22; class=&amp;#x22;postcodeSubmit&amp;#x22; value=&amp;#x22;Go&amp;#x22; id=&amp;#x22;postcodeBtn&amp;#x22;/&amp;#x3E;&lt;br /&gt;                &amp;#x3C;p class=&amp;#x22;postcode-error&amp;#x22;&amp;#x3E;Invalid postcode&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;            &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;        &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;        &lt;br /&gt;    &amp;#x3C;/div&amp;#x3E;&lt;br /&gt;&lt;br /&gt;    &amp;#x3C;script src=&amp;#x22;js/ jquery-1.11.2.min.js&amp;#x22;&amp;#x3E;&amp;#x3C;/script&amp;#x3E;&lt;br /&gt;    &amp;#x3C;script src=&amp;#x27;js/main.js&amp;#x27;&amp;#x3E;&amp;#x3C;/script&amp;#x3E;&lt;br /&gt;&amp;#x3C;/body&amp;#x3E;&lt;br /&gt;&amp;#x3C;/html&amp;#x3E;&lt;/pre&gt;&lt;br&gt;The CSS file will display the weather in the centre of the screen with the ‘Roboto’ Google font. The styling for the postcode dialog box is also styled.  &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;body {font-family: &amp;#x27;Roboto&amp;#x27;, sans-serif;}&lt;br /&gt;p, input { padding: 0; margin: 0; }&lt;br /&gt;.container { position: absolute; top: 50%; left: 50%; padding: 20px; }&lt;br /&gt;.weather { position: relative; width: 600px; height: 200px; margin: -70px 0 0 -120px; display: none; }&lt;br /&gt;.noweather { color: #999999; &lt;br /&gt;position: relative; display: none; width: 200px; height: 128px; height: 128px;&lt;br /&gt;margin: -70px 0 0 -120px;&lt;br /&gt;border: 4px solid #cccccc; &lt;br /&gt;-webkit-box-shadow: 1px 1px 3px 1px rgba(0,0,0,0.5); &lt;br /&gt;-moz-box-shadow: 1px 1px 3px 1px rgba(0,0,0,0.5);&lt;br /&gt;box-shadow: 1px 1px 3px 1px rgba(0,0,0,0.5); }&lt;br /&gt;.postcodeContainer {text-align: center;}&lt;br /&gt;.postcode-msg { font-size: 14px; padding: 16px 0 10px 0; letter-spacing: 0px; }&lt;br /&gt;.postcodeText { width: 170px; padding: 5px 0 5px 0px; margin-bottom: 2px; }&lt;br /&gt;.postcodeSubmit { width: 174px; padding: 5px 0 5px 0; background: #000000; color: #ffffff; margin-bottom: 5px; border: none; }&lt;br /&gt;.postcodeSubmit:hover {background: #999999;}&lt;br /&gt;.postcode-error { color: #ff0000; font-size: 12px; display: none; }&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;In the main.js Javascript file, I firstly detect if the browser supports geolocation. If the geolocation is supported then I called the getWeather() function along with the current longitude and latitude to display the current weather. Conversely if the geolocation is not supported then I display the postcode dialog box, and use the isPostcodeValid() helper function to check if the postcode is valid. I will again reuse the getWeather() function along the postcode to display the current weather. Note, I have used the getWeather() function for both the geolocation and postcode options. I have a pass a parameter which can use either the geolocation or postcode API.  &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;$(document).ready(function() {&lt;br /&gt;    &amp;#x27;use strict&amp;#x27;;&lt;br /&gt;    &lt;br /&gt;    var App = {&lt;br /&gt;        geolocationStr:&amp;#x22;http://api.openweathermap.org/data/2.5/weather?lat=&amp;#x22;,&lt;br /&gt;        postcodeStr:&amp;#x22;http://api.openweathermap.org/data/2.5/weather?zip=&amp;#x22;,&lt;br /&gt;        init:function(){&lt;br /&gt;            App.getLocation();&lt;br /&gt;        },&lt;br /&gt;        getLocation:function(){&lt;br /&gt;                &lt;br /&gt;            if (navigator.geolocation) {&lt;br /&gt;                navigator.geolocation.getCurrentPosition(App.geoSuccess, App.geoError);&lt;br /&gt;            }else {&lt;br /&gt;                 $(&amp;#x27;p&amp;#x27;).text(&amp;#x27;GeoLocation not supported&amp;#x27;).appendTo(&amp;#x27;body&amp;#x27;);&lt;br /&gt;            }&lt;br /&gt;            &lt;br /&gt;        },&lt;br /&gt;        geoSuccess:function(e){&lt;br /&gt;            App.getWeather(App.geolocationStr+e.coords.latitude+&amp;#x22;&amp;#x26;lon=&amp;#x22;+e.coords.longitude);   &lt;br /&gt;        },&lt;br /&gt;        geoError:function(e){&lt;br /&gt;         &lt;br /&gt;            $(&amp;#x27;.noweather&amp;#x27;).show();&lt;br /&gt;            &lt;br /&gt;            $(&amp;#x27;#postcodeBtn&amp;#x27;).on(&amp;#x27;click&amp;#x27;, function(){&lt;br /&gt;                &lt;br /&gt;                var postCodeValue = $(&amp;#x27;#postcode&amp;#x27;).val();&lt;br /&gt;            &lt;br /&gt;                if(isPostcodeValid(postCodeValue)){&lt;br /&gt;                    $(&amp;#x27;.postcode-error&amp;#x27;).hide();&lt;br /&gt;                    $(&amp;#x27;.noweather&amp;#x27;).hide();&lt;br /&gt;                    App.getWeather(App.postcodeStr+postCodeValue +&amp;#x22;,uk&amp;#x22;);  &lt;br /&gt;                    &lt;br /&gt;                }else{&lt;br /&gt;                    $(&amp;#x27;.postcode-error&amp;#x27;).show();&lt;br /&gt;                }&lt;br /&gt;            })&lt;br /&gt;            &lt;br /&gt;        },&lt;br /&gt;        getWeather:function(url){&lt;br /&gt;            &lt;br /&gt;            $.ajax({&lt;br /&gt;                url: url,&lt;br /&gt;                dataType: &amp;#x27;jsonp&amp;#x27;,&lt;br /&gt;                jsonpCallback: &amp;#x27;jsonCallback&amp;#x27;,&lt;br /&gt;                success: function (data) {   &lt;br /&gt;                    $(&amp;#x27;.weather&amp;#x27;).show();&lt;br /&gt;                    $(&amp;#x27;&amp;#x3C;h1&amp;#x3E;&amp;#x27;).text(&amp;#x27;The weather is &amp;#x27; + data.weather[0].main.toLowerCase()).appendTo(&amp;#x27;.weather&amp;#x27;);&lt;br /&gt;                }});&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    App.init();&lt;br /&gt;    &lt;br /&gt;});&lt;br /&gt;&lt;br /&gt;function isPostcodeValid(postcode){&lt;br /&gt;    var regPostcode = /^([a-zA-Z]){1}([0-9][0-9]|[0-9]|[a-zA-Z][0-9][a-zA-Z]|[a-zA-Z][0-9][0-9]|[a-zA-Z][0-9]){1}\s*([0-9][a-zA-z][a-zA-z]){1}$/;&lt;br /&gt;    return regPostcode.test(postcode);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/07/display-location-weather-in-javascript.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-6750141578769549884</guid><pubDate>Thu, 12 Jun 2014 21:30:00 +0000</pubDate><atom:updated>2015-03-30T14:39:46.274-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>HTML templating with Handlebars js</title><description>I was working on a small HTML project where small amount of data needed to be updated frequently. The updates could have been updated manually, but this was too much hassle as the updates were so small. To solve this issue I used a Javascript library called Handlebars. Handlebars is a templating library that loads JSON data with the template design of your choice. This is a simple working example of Handlebars with external JSON data loaded with jquery. &lt;br /&gt;&lt;br /&gt;&lt;b&gt;JSON &lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &quot;jsonCallBack&quot; or JSONP is used to load data from different domains without any cross domain issues. This can be removed if you are loading data from the same domain. &lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;&lt;br /&gt;jsonCallback({&lt;br /&gt;&lt;br /&gt;    &amp;quot;example&amp;quot;:&lt;br /&gt;    [&lt;br /&gt;        {&lt;br /&gt;            &amp;quot;name&amp;quot;: &amp;quot;Mr A&amp;quot;&lt;br /&gt;            &amp;quot;image&amp;quot;: &amp;quot;images/mra.jpg&amp;quot;&lt;br /&gt;            &amp;quot;link&amp;quot;: &amp;quot;http://www.example1.com&amp;quot;&lt;br /&gt;        },&lt;br /&gt;        &lt;br /&gt;        {&lt;br /&gt;            &amp;quot;name&amp;quot;: &amp;quot;Mrs B&amp;quot;&lt;br /&gt;            &amp;quot;image&amp;quot;: &amp;quot;images/mrsb.jpg&amp;quot;&lt;br /&gt;            &amp;quot;link&amp;quot;: &amp;quot;http://www.example2.com&amp;quot;&lt;br /&gt;        },&lt;br /&gt;        &lt;br /&gt;        {&lt;br /&gt;            &amp;quot;name&amp;quot;: &amp;quot;Miss C&amp;quot;&lt;br /&gt;            &amp;quot;image&amp;quot;: &amp;quot;images/missc.jpg&amp;quot;&lt;br /&gt;            &amp;quot;link&amp;quot;: &amp;quot;http://www.example3.com&amp;quot;&lt;br /&gt;        }&lt;br /&gt;    ]&lt;br /&gt;&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;HTML&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The &quot;{{ }}&quot; (double curly braces) indicate where we want Handlebars to generate the code for us. The Handlebars template uses the MIME type text/x-handlebars-template rather than text/javascript to prevent the browser from running the Handlebars code. &lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;&lt;br /&gt;&amp;lt;!doctype html&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;meta charset=&amp;quot;UTF-8&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;Mustache JS Example&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;script src=&amp;quot;js/handlebars.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;script id=&amp;quot;HJ-Template&amp;quot; type=&amp;quot;text/x-handlebars-template&amp;quot;&amp;gt;&lt;br /&gt;   {{#each example}}&lt;br /&gt;        &amp;lt;div class=&amp;quot;example&amp;quot;&amp;gt;&lt;br /&gt;            &amp;lt;div class=&amp;quot;example-image&amp;quot;&amp;gt;&amp;lt;img src={{image}}&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;            &amp;lt;p class=&amp;quot;example-text&amp;quot;&amp;gt;{{name}}&amp;lt;/p&amp;gt;&lt;br /&gt;            &amp;lt;a href={{link}}&amp;gt;Click link&amp;lt;/a&amp;gt;&lt;br /&gt;        &amp;lt;/div&amp;gt;&lt;br /&gt;    {{/each}}&lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;script src=&amp;quot;js/jquery.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;script src=&amp;quot;js/main.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;b&gt;Javascript&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;This loads the example.json file with jQuery and uses the Handlers.compile() method to compile the template in Javascript. The results are added to the body of the HTML. &lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;&lt;br /&gt;$(function(){&lt;br /&gt;    &lt;br /&gt;    $.ajax({&lt;br /&gt;        url: example.json,&lt;br /&gt;        dataType: &amp;#39;jsonp&amp;#39;,&lt;br /&gt;        jsonpCallback: &amp;#39;jsonCallback&amp;#39;,&lt;br /&gt;        success: function (data) {   &lt;br /&gt;&lt;br /&gt;            var source = $(&amp;#39;#HJ-Template&amp;#39;).html(),&lt;br /&gt;            template = Handlebars.compile(source),&lt;br /&gt;            html = template(data.example);&lt;br /&gt;&lt;br /&gt;            $(&amp;quot;body&amp;quot;).append(html);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;    });&lt;br /&gt;            &lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt; &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/06/html-templating-with-handlebars-js.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-7574987557732541236</guid><pubDate>Fri, 30 May 2014 15:34:00 +0000</pubDate><atom:updated>2014-12-30T08:47:37.836-08:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Preload images with Javascript</title><description>It is useful to preload large or multiple images to avoid long waiting times. I have used the Javascript plugin called &#39;imagesLoaded&#39; which can trigger an event when all images have been loaded. While the images are loading a preloaded gif can be displayed until the images have loaded. The preloader will be removed once all the images have been loaded. This will give the user feedback so they know content is loading.  &lt;br&gt;&lt;br&gt;Firstly, in HTML file I have added the class &#39;loading&#39; to the body tag. This class will show the preloader gif when the images are loading and will be removed once the images have loaded. I have added the images to be preloaded inside a div with the class &#39;preload&#39;. This div will be hidden until the images have loaded.  &lt;br&gt;&lt;br&gt;&lt;pre class=&#39;source-code&#39;&gt;&amp;lt;!doctype html&amp;gt;&lt;br /&gt;&amp;lt;html lang=&amp;quot;en&amp;quot; class=&amp;quot;no-js&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;   &amp;lt;meta charset=&amp;quot;UTF-8&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;meta http-equiv=&amp;quot;X-UA-Compatible&amp;quot; content=&amp;quot;IE=edge,chrome=1&amp;quot;/&amp;gt;&lt;br /&gt;   &amp;lt;meta name=&amp;quot;viewport&amp;quot; content=&amp;quot;width=device-width, initial-scale=1&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;title&amp;gt;Preload image Javasript&amp;lt;/title&amp;gt;&lt;br /&gt;   &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;css/style.css&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;script src=&amp;quot;js/vendor/modernizr-2.7.1.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; &lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body class=&amp;quot;loading&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;   &amp;lt;div class=&amp;quot;preload&amp;quot;&amp;gt;&lt;br /&gt;       &amp;lt;img src=&amp;quot;img/img1.jpg&amp;quot;&amp;gt;&lt;br /&gt;       &amp;lt;img src=&amp;quot;img/img2.jpg&amp;quot;&amp;gt;&lt;br /&gt;       &amp;lt;img src=&amp;quot;img/img3.jpg&amp;quot;&amp;gt;&lt;br /&gt;       &amp;lt;img src=&amp;quot;img/img4.jpg&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;/div&amp;gt;&lt;br /&gt;    &lt;br /&gt;   &amp;lt;script src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;   &amp;lt;script src=&amp;quot;js/imagesloaded.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;   &amp;lt;script&amp;gt;&lt;br /&gt;       //add javascript code here&lt;br /&gt;   &amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;In the css file, the loading class displays the preloaded gif positioned at the centre of the page. The preload class uses the &#39;display none&#39; to hide the images. Once the images have loaded the body opacity will be opaque. &lt;br&gt;&lt;br&gt;&lt;pre class=&#39;source-code&#39;&gt;body{&lt;br /&gt;     opacity: 0;&lt;br /&gt;}    &lt;br /&gt;&lt;br /&gt;.loading {&lt;br /&gt;    background: url(&amp;#39;../images/loading.gif&amp;#39;) no-repeat center center;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.preload {&lt;br /&gt;    width: 1px;&lt;br /&gt;    height: 1px;&lt;br /&gt;    position: absolute;&lt;br /&gt;    top: 0;&lt;br /&gt;    left: 0;&lt;br /&gt;    display: none;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.loaded, .no-js  {    &lt;br /&gt;    opacity: 1;&lt;br /&gt;    -webkit-transition: opacity 300ms ease-out;&lt;br /&gt;    -moz-transition: opacity 300ms ease-out;&lt;br /&gt;    transition: opacity 300ms ease-out;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br&gt;Finally, in the HTML file I have added the following Javascript code using the imagesLoaded plugin. This code will remove the class &#39;loading&#39; from the body an add the &#39;loaded&#39; class. &lt;br&gt;&lt;br&gt;&lt;pre class=&#39;source-code&#39;&gt;$(function() {&lt;br /&gt; $(&amp;#39;body&amp;#39;).imagesLoaded(function() {&lt;br /&gt;      $(&amp;#39;body&amp;#39;).removeClass(&amp;#39;loading&amp;#39;).addClass(&amp;#39;loaded&amp;#39;);&lt;br /&gt; });&lt;br /&gt;});&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/05/preload-images-with-javascript.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-3830060333234750022</guid><pubDate>Sat, 17 May 2014 21:29:00 +0000</pubDate><atom:updated>2015-07-13T14:37:50.816-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>3D CSS3 transitions and transforms</title><description>These are 3D examples of CSS3 transitions and transforms continuing on from the last post with &lt;a href=&quot;http://www.ilike2flash.com/2014/05/2d-css3-transitions-and-transforms.html&quot;&gt;2D examples&lt;/a&gt;. I have again used the template HTML structure with inline style. This time I have included the container class in the styles. We are using 3D, so the perspective class will be added to the container. I have used the value of 1000 to prevent distortion on screen. Again the transitions and transforms effects are added to the hover state of the div. &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;#x3C;!doctype html&amp;#x3E;&lt;br /&gt;&amp;#x3C;html&amp;#x3E;&lt;br /&gt;&amp;#x3C;head&amp;#x3E;&lt;br /&gt;    &amp;#x3C;meta charset=&amp;#x22;UTF-8&amp;#x22;&amp;#x3E;&lt;br /&gt;    &amp;#x3C;title&amp;#x3E;3D CSS3 transitions and transforms&amp;#x3C;/title&amp;#x3E;&lt;br /&gt;    &lt;br /&gt;    &amp;#x3C;style&amp;#x3E;&lt;br /&gt;    body{padding:0; margin:0;}&lt;br /&gt;    p{padding:0; margin:0; text-align: center; position: relative; top:110%;}&lt;br /&gt;    .box{width:150px; height:150px; background-color: #ff0000; display: inline-block; margin:0 50px 50px 0;}   &lt;br /&gt;&lt;br /&gt;    .container{&lt;br /&gt;       -webkit-perspective: 1000; &lt;br /&gt;       -moz-perspective: 1000; &lt;br /&gt;       -o-perspective: 1000; &lt;br /&gt;       perspective: 1000; &lt;br /&gt;    }        &lt;br /&gt;&lt;br /&gt;&amp;#x3C;/head&amp;#x3E;&lt;br /&gt;&amp;#x3C;body&amp;#x3E;&lt;br /&gt;&lt;br /&gt;&amp;#x3C;div class=&amp;#x22;container&amp;#x22;&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box1&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;3D Scale&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box2&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Rotate Y&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box3&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Rotate X&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box4&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Rotate Z&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box5&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;3D Rotate&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;&lt;br /&gt;&amp;#x3C;/body&amp;#x3E;&lt;br /&gt;&amp;#x3C;/html&amp;#x3E;&lt;br /&gt;&lt;/pre&gt;This example scales up the div with the scale3d transform property and reduces the opacity. The scale3d has three parameters: x, y, and Z. &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box1{&lt;br /&gt;  -webkit-transform-style:preserve-3d;&lt;br /&gt;  -moz-transform-style:preserve-3d;&lt;br /&gt;  -o-transform-style:preserve-3d;&lt;br /&gt;  transform-style:preserve-3d;&lt;br /&gt;}     &lt;br /&gt;&lt;br /&gt;.box1:hover{&lt;br /&gt;    -webkit-animation:scaleup 1s ease-out forwards;&lt;br /&gt;    -moz-animation:scaleup 1s ease-out forwards;&lt;br /&gt;    -o-animation:scaleup 1s ease-out forwards;&lt;br /&gt;     animation:scaleup 1s ease-out forwards;&lt;br /&gt;    -webkit-backface-visibility:hidden;&lt;br /&gt;    -moz-backface-visibility:hidden;&lt;br /&gt;    -o-backface-visibility:hidden;&lt;br /&gt;    backface-visibility:hidden;&lt;br /&gt;}  &lt;br /&gt;&lt;br /&gt;@-webkit-keyframes scaleup{&lt;br /&gt;    0%{opacity: 1;}&lt;br /&gt;    100%{opacity: 0; -webkit-transform: scale3d(2,2,2);}&lt;br /&gt;}    &lt;br /&gt;@-moz-keyframes scaleup{&lt;br /&gt;    0%{opacity: 1;}&lt;br /&gt;    100%{opacity: 0; -moz-transform: scale3d(2,2,2);}&lt;br /&gt;}    &lt;br /&gt;@-o-keyframes scaleup{&lt;br /&gt;    0%{opacity: 1;}&lt;br /&gt;    100%{opacity: 0; -o-transform: scale3d(2,2,2);}&lt;br /&gt;}    &lt;br /&gt;keyframes scaleup{&lt;br /&gt;    0%{opacity: 1;}&lt;br /&gt;    100%{opacity: 0; transform: scale3d(2,2,2);}&lt;br /&gt;}            &lt;br /&gt;&lt;/pre&gt;The next three examples rotate the div around the x,y and z-axis. &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box2{&lt;br /&gt;    -webkit-transition:-webkit-transform 1s ease;&lt;br /&gt;    -moz-transition:-moz-transform 1s ease;&lt;br /&gt;    -o-transition:-o-transform 1s ease;&lt;br /&gt;    transition:transform 1s ease; &lt;br /&gt;} &lt;br /&gt;        &lt;br /&gt;.box2:hover{&lt;br /&gt;    -webkit-transform:rotateY(-180deg);&lt;br /&gt;    -moz-transform:rotateY(-180deg);&lt;br /&gt;    -o-transform:rotateY(-180deg);&lt;br /&gt;    transform:rotateY(-180deg);    &lt;br /&gt;}&lt;br /&gt;        &lt;br /&gt;.box3{&lt;br /&gt;    -webkit-transition:-webkit-transform 1s ease;&lt;br /&gt;    -moz-transition:-moz-transform 1s ease;&lt;br /&gt;    -o-transition:-o-transform 1s ease;&lt;br /&gt;    transition:transform 1s ease; &lt;br /&gt;} &lt;br /&gt;        &lt;br /&gt;.box3:hover{&lt;br /&gt;    -webkit-transform:rotateX(-180deg);&lt;br /&gt;    -moz-transform:rotateX(-180deg);&lt;br /&gt;    -o-transform:rotateX(-180deg);&lt;br /&gt;    transform:rotateX(-180deg);    &lt;br /&gt;}         &lt;br /&gt;&lt;br /&gt;.box4{&lt;br /&gt;    -webkit-transition:-webkit-transform 1s ease;&lt;br /&gt;    -moz-transition:-moz-transform 1s ease;&lt;br /&gt;    -o-transition:-o-transform 1s ease;&lt;br /&gt;    transition:transform 1s ease; &lt;br /&gt;} &lt;br /&gt;        &lt;br /&gt;.box4:hover{&lt;br /&gt;    -webkit-transform:rotateZ(360deg);&lt;br /&gt;    -moz-transform:rotateZ(360deg);&lt;br /&gt;    -o-transform:rotateZ(360deg);&lt;br /&gt;    transform:rotateZ(360deg);    &lt;br /&gt;}         &lt;br /&gt;&lt;/pre&gt;The final example rotates in 3D and the parameters are x, y, z and angle.  &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box5{&lt;br /&gt;    -webkit-transition:-webkit-transform 1s ease;&lt;br /&gt;    -moz-transition:-moz-transform 1s ease;&lt;br /&gt;    -o-transition:-o-transform 1s ease;&lt;br /&gt;    transition:transform 1s ease; &lt;br /&gt;} &lt;br /&gt;        &lt;br /&gt;.box5:hover{&lt;br /&gt;    -webkit-transform:rotate3d(1,0,1, 360deg);&lt;br /&gt;    -moz-transform:rotate3d(1,0,1, 360deg);&lt;br /&gt;    -o-transform:rotate3d(1,0,1, 360deg);&lt;br /&gt;    transform:rotate3d(1,0,1, 360deg); &lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;   &lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/05/3d-css3-transitions-and-transforms.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-1034079545445829860</guid><pubDate>Mon, 12 May 2014 13:57:00 +0000</pubDate><atom:updated>2015-07-09T07:04:16.209-07:00</atom:updated><title>2D CSS3 Transitions and Transforms</title><description>I have written a few examples of 2D CSS3 transitions and transforms for future reference. I will firstly cover single transitions and transforms on a single element. Then move onto multiple transitions and transforms on a single element. &lt;br&gt;&lt;br&gt;I have used a template HTML structure with inline CSS styles for demonstrational purposes shown below. The styles should ideally be placed in a separate CSS file.  The effects will be added onto the hover state on the div’s &lt;br&gt;&lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&amp;#x3C;!doctype html&amp;#x3E;&lt;br /&gt;&amp;#x3C;html&amp;#x3E;&lt;br /&gt;&amp;#x3C;head&amp;#x3E;&lt;br /&gt;    &amp;#x3C;meta charset=&amp;#x22;UTF-8&amp;#x22;&amp;#x3E;&lt;br /&gt;    &amp;#x3C;title&amp;#x3E;2D CSS3 transitions and transforms&amp;#x3C;/title&amp;#x3E;&lt;br /&gt;    &lt;br /&gt;    &amp;#x3C;style&amp;#x3E;&lt;br /&gt;    body{padding:0; margin:0;}&lt;br /&gt;    p{padding:0; margin:0; text-align: center; position: relative; top:110%;}&lt;br /&gt;    .box{width:150px; height:150px; background-color: #ff0000; display: inline-block; margin:0 50px 50px 0;}   &lt;br /&gt;    &amp;#x3C;/style&amp;#x3E;&lt;br /&gt;    &lt;br /&gt;&amp;#x3C;/head&amp;#x3E;&lt;br /&gt;&amp;#x3C;body&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box1&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Colour Change&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box2&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Opacity&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box3&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Scale&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box4&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Rotate&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;    &amp;#x3C;div class=&amp;#x22;box box5&amp;#x22;&amp;#x3E;&amp;#x3C;p&amp;#x3E;Colour and opacity&amp;#x3C;/p&amp;#x3E;&amp;#x3C;/div&amp;#x3E;&lt;br /&gt;&amp;#x3C;/body&amp;#x3E;&lt;br /&gt;&amp;#x3C;/html&amp;#x3E;&lt;br /&gt;&lt;/pre&gt; &lt;br&gt;To create a transition for changing the background colour, I have used the background-color property to smoothly change the colour.  &lt;br&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box1{&lt;br /&gt;    background-color: #ff0000;&lt;br /&gt;    -webkit-transition: background-color 1s ease;&lt;br /&gt;    -moz-transition: background-color 1s ease;&lt;br /&gt;    -ms-transition: background-color 1s ease;&lt;br /&gt;    -o-transition: background-color 1s ease;&lt;br /&gt;    transition: background-color 1s ease;&lt;br /&gt;}     &lt;br /&gt;&lt;br /&gt;.box1:hover{&lt;br /&gt;    background-color: #ffff00;&lt;br /&gt;    -webkit-transition: background-color 1s ease;&lt;br /&gt;    -moz-transition: background-color 1s ease;&lt;br /&gt;    -ms-transition: background-color 1s ease;&lt;br /&gt;    -o-transition: background-color 1s ease;&lt;br /&gt;    transition: background-color 1s ease;&lt;br /&gt;}   &lt;br /&gt;&lt;/pre&gt;The opacity can be transitioned in the same way as the background-color using the opacity value.   &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box2{&lt;br /&gt;   opacity: 1;&lt;br /&gt;    -webkit-transition: opacity 1s ease-out;&lt;br /&gt;    -moz-transition: opacity 1s ease-out;&lt;br /&gt;    -ms-transition: opacity 1s ease-out;&lt;br /&gt;    -o-transition:opacity 1s ease-out;&lt;br /&gt;    transition: opacity 1s ease-out;&lt;br /&gt;}     &lt;br /&gt;&lt;br /&gt;.box2:hover{&lt;br /&gt;   opacity:0.3;&lt;br /&gt;    -webkit-transition: opacity 1s ease-out;&lt;br /&gt;    -moz-transition: opacity 1s ease-out;&lt;br /&gt;    -ms-transition: opacity 1s ease-out;&lt;br /&gt;    -o-transition:opacity 1s ease-out;&lt;br /&gt;    transition: opacity 1s ease-out;&lt;br /&gt;}    &lt;br /&gt;&lt;/pre&gt;The scaling uses the transform property instead of the transition. This will increase the size upon hovering over the div. The webkit-backface-visibility property is added to remove any glitches with the webkit browsers.   &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box3{&lt;br /&gt;    -webkit-transition: all 1s ease-out;&lt;br /&gt;    -moz-transition: all 1s ease-out;&lt;br /&gt;    -ms-transition: all 1s ease-out;&lt;br /&gt;    -o-transition:all 1s ease-out;&lt;br /&gt;    transition: all 1s ease-out;&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;.box3:hover{&lt;br /&gt;    -webkit-transform: scale(1.25);&lt;br /&gt;    -moz-transform: scale(1.25);&lt;br /&gt;    -ms-transform: scale(1.25);&lt;br /&gt;    -o-transform: scale(1.25);&lt;br /&gt;    transform: scale(1.25);&lt;br /&gt;    -webkit-backface-visibility: hidden; &lt;br /&gt;}        &lt;br /&gt;&lt;br /&gt;.box4{&lt;br /&gt;    -webkit-transition: all 1s ease-out;&lt;br /&gt;    -moz-transition: all 1s ease-out;&lt;br /&gt;    -ms-transition: all 1s ease-out;&lt;br /&gt;    -o-transition:all 1s ease-out;&lt;br /&gt;    transition: all 1s ease-out;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.box4:hover{&lt;br /&gt;    -webkit-transform: rotate(360deg);&lt;br /&gt;    -moz-transform: rotate(360deg);&lt;br /&gt;    -ms-transform:rotate(360deg);&lt;br /&gt;    -o-transform:rotate(360deg);&lt;br /&gt;    transform: rotate(360deg);&lt;br /&gt;} &lt;br /&gt;&lt;/pre&gt;Multiple properties are added in the same way as single properties.  &lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;.box5{&lt;br /&gt;    background-color: #ff0000;&lt;br /&gt;    opacity: 1;&lt;br /&gt;    -webkit-transition: background-color 1s ease;&lt;br /&gt;    -moz-transition: background-color 1s ease;&lt;br /&gt;    -ms-transition: background-color 1s ease;&lt;br /&gt;    -o-transition: background-color 1s ease;&lt;br /&gt;    transition: background-color 1s ease;&lt;br /&gt;&lt;br /&gt;    -webkit-transition: opacity 1s ease-out;&lt;br /&gt;    -moz-transition: opacity 1s ease-out;&lt;br /&gt;    -ms-transition: opacity 1s ease-out;&lt;br /&gt;    -o-transition:opacity 1s ease-out;&lt;br /&gt;    transition: opacity 1s ease-out;&lt;br /&gt;}     &lt;br /&gt;&lt;br /&gt;.box5:hover{&lt;br /&gt;    background-color: #00ff00;&lt;br /&gt;    opacity:0.3;&lt;br /&gt;    -webkit-transition: background-color 1s ease;&lt;br /&gt;    -moz-transition: background-color 1s ease;&lt;br /&gt;    -ms-transition: background-color 1s ease;&lt;br /&gt;    -o-transition: background-color 1s ease;&lt;br /&gt;    transition: background-color 1s ease;&lt;br /&gt;&lt;br /&gt;    -webkit-transition: opacity 1s ease-out;&lt;br /&gt;    -moz-transition: opacity 1s ease-out;&lt;br /&gt;    -ms-transition: opacity 1s ease-out;&lt;br /&gt;    -o-transition:opacity 1s ease-out;&lt;br /&gt;    transition: opacity 1s ease-out;&lt;br /&gt;}  &lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/05/2d-css3-transitions-and-transforms.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-6192986658986894811</guid><pubDate>Sun, 27 Apr 2014 12:00:00 +0000</pubDate><atom:updated>2014-04-27T05:06:37.096-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>Simon Says game in EaselJS</title><description>I have ported over one of my older post, the &lt;a href=&quot;http://www.ilike2flash.com/2012/10/simons-says-game-in-actionscript-3.html&quot;&gt;Simon Says game in Actionscript 3&lt;/a&gt; to EaselJS. The code can be seen below and an example can been seen &lt;a href=&quot;http://codepen.io/ilike2/pen/ybovE&quot;&gt;here&lt;/a&gt;. &lt;br /&gt;&lt;br /&gt;&lt;pre class=&#39;source-code&#39;&gt;&amp;lt;!DOCTYPE html&amp;gt; &lt;br /&gt;&amp;lt;html&amp;gt; &lt;br /&gt; &amp;lt;head&amp;gt; &lt;br /&gt;  &amp;lt;style&amp;gt; &lt;br /&gt;  html,body{padding:0; margin:0;} &lt;br /&gt;  #canvas{background-color: black;} &lt;br /&gt;  &amp;lt;/style&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;script src=&amp;quot;http://code.createjs.com/easeljs-0.7.1.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;  &amp;lt;script src=&amp;quot;http://code.createjs.com/tweenjs-0.5.1.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;  &amp;lt;script src=&amp;quot;http://code.createjs.com/soundjs-0.5.2.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;  &amp;lt;script&amp;gt;&lt;br /&gt;   var stage,&lt;br /&gt;    coloursArray = [],&lt;br /&gt;    userArray,&lt;br /&gt;    computerArray,&lt;br /&gt;    sequenceEnd,&lt;br /&gt;    timer,&lt;br /&gt;    count,&lt;br /&gt;    score,&lt;br /&gt;    playText,&lt;br /&gt;    guessText,&lt;br /&gt;    st,&lt;br /&gt;    manifest;&lt;br /&gt;    &lt;br /&gt;   &lt;br /&gt;   function init()&lt;br /&gt;   {&lt;br /&gt;    stage = new createjs.Stage(&#39;canvas&#39;);&lt;br /&gt;    stage.enableMouseOver(10); &lt;br /&gt;    &lt;br /&gt;    createjs.Ticker.addEventListener(&amp;quot;tick&amp;quot;, stage);&lt;br /&gt;    createjs.Ticker.setFPS(30); &lt;br /&gt;    &lt;br /&gt;    //colour blocks&lt;br /&gt;    var b1 = createBlock( &#39;#ff0000&#39;, &#39;tl&#39;, 45, 18);&lt;br /&gt;    var b2 = createBlock( &#39;#00ff00&#39;, &#39;tr&#39;, 155, 18);&lt;br /&gt;    var b3 = createBlock( &#39;#FFFF00&#39;, &#39;bl&#39;, 45, 128);&lt;br /&gt;    var b4 = createBlock( &#39;#0000FF&#39;, &#39;br&#39;, 155, 128);&lt;br /&gt;    stage.addChild(b1, b2, b3, b4);&lt;br /&gt;  &lt;br /&gt;    coloursArray.push(b1, b2, b3, b4);&lt;br /&gt;    &lt;br /&gt;    for(var i = 0; i &amp;lt; coloursArray.length; i++){&lt;br /&gt;     coloursArray[i].id = i;&lt;br /&gt;     coloursArray[i].cursor = &#39;pointer&#39;;&lt;br /&gt;     coloursArray[i].addEventListener(&#39;click&#39;, buttonHandler);&lt;br /&gt;    }&lt;br /&gt;    &lt;br /&gt;    &lt;br /&gt;    //play text&lt;br /&gt;    playText = new createjs.Text();&lt;br /&gt;    playText.text = &#39;CLICKn TO PLAY&#39;;&lt;br /&gt;    playText.color = &#39;#ffffff&#39;;&lt;br /&gt;    playText.font =  &#39;bold 18px Arial&#39;;&lt;br /&gt;    playText.textAlign = &#39;center&#39;;&lt;br /&gt;    playText.x = stage.canvas.width/2;&lt;br /&gt;    playText.y = stage.canvas.height/2 - 20;&lt;br /&gt;    playText.hitArea  = new createjs.Shape(new createjs.Graphics()&lt;br /&gt;                       .beginFill(&amp;quot;#f00&amp;quot;)&lt;br /&gt;                       .drawRect(-stage.canvas.width/2,-stage.canvas.height/2 + 20,300,250)); &lt;br /&gt;    playText.addEventListener(&#39;click&#39;, playHandler);&lt;br /&gt;    stage.addChild(playText);&lt;br /&gt;    &lt;br /&gt;    //guess text&lt;br /&gt;    guessText = new createjs.Text();&lt;br /&gt;    guessText.text = &#39;&#39;;&lt;br /&gt;    guessText.color = &#39;#ffffff&#39;;&lt;br /&gt;    guessText.font =  &#39;bold 55px Arial&#39;;&lt;br /&gt;    guessText.x = stage.canvas.width/2;&lt;br /&gt;    guessText.y = stage.canvas.height/2 - 25;&lt;br /&gt;    guessText.textAlign = &#39;center&#39;;&lt;br /&gt;    guessText.visible = false;&lt;br /&gt;    stage.addChild(guessText);&lt;br /&gt;                &lt;br /&gt;    stage.update(); &lt;br /&gt;                &lt;br /&gt;                &lt;br /&gt;    //load sounds&lt;br /&gt;    if (!createjs.Sound.initializeDefaultPlugins()) { return; }&lt;br /&gt;        var audioPath = &#39;sounds/&#39;;&lt;br /&gt;        manifest = [&lt;br /&gt;        {id:&#39;chicken_sfx&#39;, src:&#39;chicken_sfx.ogg&#39;},&lt;br /&gt;        {id:&#39;cow_sfx&#39;    , src:&#39;cow_sfx.ogg&#39;},&lt;br /&gt;        {id:&#39;oink_sfx&#39;   , src:&#39;oink_sfx.ogg&#39;},&lt;br /&gt;        {id:&#39;sheep_sfx&#39;  , src:&#39;sheep_sfx.ogg&#39;}&lt;br /&gt;        ]&lt;br /&gt;        createjs.Sound.alternateExtensions = [&#39;mp3&#39;];&lt;br /&gt;        createjs.Sound.registerManifest(manifest, audioPath);&lt;br /&gt;                &lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;   function playHandler(e)&lt;br /&gt;   {&lt;br /&gt;    playText.visible = false;&lt;br /&gt;    start();&lt;br /&gt;               &lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt;&lt;br /&gt;   function start()&lt;br /&gt;   {&lt;br /&gt;    userArray = [];&lt;br /&gt;    computerArray = [];&lt;br /&gt;    guessText.text = &#39;0&#39;;&lt;br /&gt;    guessText.visible = true;&lt;br /&gt;    count = 0;&lt;br /&gt;    score = 0;&lt;br /&gt;    sequenceEnd = false;&lt;br /&gt;    newRound();&lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt;   function newRound()&lt;br /&gt;   {&lt;br /&gt;    var r = Math.floor(Math.random() * coloursArray.length);&lt;br /&gt;    userArray.push(r);&lt;br /&gt;    &lt;br /&gt;    st = setInterval(checkColours, 1000);&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;   &lt;br /&gt;   function checkColours()&lt;br /&gt;   {&lt;br /&gt;    if(count &amp;lt; userArray.length){&lt;br /&gt;     var value = userArray[count];&lt;br /&gt;     createjs.Tween.get(coloursArray[value]).to({alpha:0.5}, 300).to({alpha:1},300);        &lt;br /&gt;     createjs.Sound.play(manifest[value].id);&lt;br /&gt;     count++;&lt;br /&gt;     &lt;br /&gt;    }else{&lt;br /&gt;     clearInterval(st);&lt;br /&gt;     computerArray = userArray.concat();&lt;br /&gt;     sequenceEnd = true;&lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt;   function buttonHandler(e)&lt;br /&gt;   {&lt;br /&gt;    &lt;br /&gt;    if(sequenceEnd){&lt;br /&gt;     &lt;br /&gt;     var computerChoice = computerArray.shift();&lt;br /&gt;     var userChoice = e.target.id;&lt;br /&gt;     &lt;br /&gt;     if(userChoice == computerChoice){&lt;br /&gt;      &lt;br /&gt;      createjs.Tween.get(coloursArray[userChoice]).to({alpha:0.5}, 300).to({alpha:1},300);&lt;br /&gt;      createjs.Sound.play(manifest[userChoice].id);&lt;br /&gt;                        &lt;br /&gt;      if(computerArray.length == 0){&lt;br /&gt;       newRound();&lt;br /&gt;       count = 0;&lt;br /&gt;       sequenceEnd = false;&lt;br /&gt;       score++;&lt;br /&gt;       guessText.text = String(score);&lt;br /&gt;      }&lt;br /&gt;      &lt;br /&gt;     }else{&lt;br /&gt;      guessText.text = &#39;&#39;;&lt;br /&gt;      guessText.visible = false;&lt;br /&gt;      playText.visible = true;&lt;br /&gt;     }&lt;br /&gt;     &lt;br /&gt;    }&lt;br /&gt;   }&lt;br /&gt;   &lt;br /&gt;   &lt;br /&gt;   function createBlock(colour, direction, xpos, ypos)&lt;br /&gt;   {&lt;br /&gt;    var g = new createjs.Graphics();&lt;br /&gt;    g.beginFill(colour);&lt;br /&gt;    &lt;br /&gt;    switch(direction)&lt;br /&gt;    {&lt;br /&gt;     case &#39;tl&#39;:&lt;br /&gt;      g.lineTo(0, 0);&lt;br /&gt;      g.lineTo(100, 0);&lt;br /&gt;      g.lineTo(100, 60);&lt;br /&gt;      g.quadraticCurveTo(60, 60, 58, 100);&lt;br /&gt;      g.lineTo(0, 100);&lt;br /&gt;     break; &lt;br /&gt;     &lt;br /&gt;     case &#39;tr&#39;:&lt;br /&gt;      g.lineTo(0, 0);&lt;br /&gt;      g.lineTo(100, 0);&lt;br /&gt;      g.lineTo(100, 100);&lt;br /&gt;      g.lineTo(47, 100);&lt;br /&gt;      g.quadraticCurveTo(40, 60, 0, 58);&lt;br /&gt;     break;&lt;br /&gt;      &lt;br /&gt;     case &#39;bl&#39;:&lt;br /&gt;      g.lineTo(0, 0);&lt;br /&gt;      g.lineTo(57, 0);&lt;br /&gt;      g.quadraticCurveTo(60, 50, 100, 49);&lt;br /&gt;      g.lineTo(100, 100);&lt;br /&gt;      g.lineTo(0, 100);&lt;br /&gt;     break;&lt;br /&gt;     &lt;br /&gt;     case &#39;br&#39;:&lt;br /&gt;      g.moveTo(47,0);&lt;br /&gt;      g.lineTo(100,0);&lt;br /&gt;      g.lineTo(100,100);&lt;br /&gt;      g.lineTo(0, 100);&lt;br /&gt;      g.lineTo(0, 50);&lt;br /&gt;      g.quadraticCurveTo(40, 50, 47, 0);&lt;br /&gt;     break; &lt;br /&gt;    } &lt;br /&gt;&lt;br /&gt;    var s = new createjs.Shape(g);&lt;br /&gt;    s.x = xpos;&lt;br /&gt;    s.y = ypos;&lt;br /&gt;    return s;&lt;br /&gt;   }&lt;br /&gt;&lt;br /&gt;  &amp;lt;/script&amp;gt;&lt;br /&gt;  &lt;br /&gt; &amp;lt;/head&amp;gt;&lt;br /&gt; &lt;br /&gt; &amp;lt;body onload=&amp;quot;init()&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;canvas id=&amp;quot;canvas&amp;quot; width=&amp;quot;300&amp;quot; height=&amp;quot;250&amp;quot;&amp;gt;&amp;lt;/canvas&amp;gt; &lt;br /&gt; &amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/04/simon-says-game-in-easeljs.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-4936679048645236623.post-6087330438737902755</guid><pubDate>Mon, 03 Mar 2014 23:14:00 +0000</pubDate><atom:updated>2015-04-06T15:21:00.763-07:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Html5</category><title>SwipeJS example</title><description>I needed a quick and simple touch page slider for a project and decided to use to the SwipeJS library. This library is compatible with all browsers from IE 7+ and supports the usual left/right touch swipes as well as an automatic slideshow feature. &lt;br/&gt;&lt;br/&gt;The SwipeJS setup is straightforward. You need a two divs, one for each slide and one as a wrapper. Some minor CSS styling will be needed to display the slides inline. Finally, the Javascript swipe function needs to be called to start touch swipes. There are a number of additional parameters available to tweak the behaviour of the slider such as speed of transitions, auto slideshow and continuous slides.  &lt;br/&gt;&lt;br/&gt;&lt;pre class=&quot;source-code&quot;&gt;&amp;lt;!doctype html&amp;gt;&lt;br /&gt;&amp;lt;html&amp;gt;&lt;br /&gt;&amp;lt;head&amp;gt;&lt;br /&gt;    &amp;lt;meta charset=&amp;quot;UTF-8&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;SwipeJS Example&amp;lt;/title&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;style&amp;gt;&lt;br /&gt;    html,body{padding: 0; margin:0;}&lt;br /&gt;        &lt;br /&gt;    .swipe {&lt;br /&gt;      overflow: hidden;&lt;br /&gt;      visibility: hidden;&lt;br /&gt;      position: relative;&lt;br /&gt;    }&lt;br /&gt;    .swipe-wrap {&lt;br /&gt;      overflow: hidden;&lt;br /&gt;      position: relative;&lt;br /&gt;    }&lt;br /&gt;    .swipe-wrap &amp;gt; div {&lt;br /&gt;      float:left;&lt;br /&gt;      width:100%;&lt;br /&gt;      position: relative;&lt;br /&gt;    }&lt;br /&gt;    &amp;lt;/style&amp;gt;&lt;br /&gt;    &lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body onload=&amp;quot;init()&amp;quot;&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;div id=&amp;#39;mySlider&amp;#39; class=&amp;#39;swipe&amp;#39;&amp;gt;&lt;br /&gt;      &amp;lt;div class=&amp;#39;swipe-wrap&amp;#39;&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;img src=&amp;quot;images/pic1.jpg&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;img src=&amp;quot;images/pic2.jpg&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;img src=&amp;quot;images/pic3.jpg&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;img src=&amp;quot;images/pic4.jpg&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;        &amp;lt;div&amp;gt;&amp;lt;img src=&amp;quot;images/pic5.jpg&amp;quot;/&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;      &amp;lt;/div&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;    &amp;lt;script src=&amp;quot;swipe.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;    &amp;lt;script&amp;gt;&lt;br /&gt;    &lt;br /&gt;        function init(){&lt;br /&gt;            var mySwipe = Swipe(document.getElementById(&amp;#39;mySlider&amp;#39;), {&lt;br /&gt;               speed:400,&lt;br /&gt;               continuous: true,&lt;br /&gt;            }); &lt;br /&gt;        }&lt;br /&gt;        &lt;br /&gt;    &amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br/&gt;Currently, the slides are only swipe on mobile and tablet devices. To make this compatible with desktop, buttons will need to be added to navigate to the previous and next slides.   &lt;br/&gt;&lt;br/&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;left&amp;quot; onclick=&amp;quot;slideLeft()&amp;quot;&amp;gt;left&amp;lt;/span&amp;gt;&lt;br /&gt;&amp;lt;span id=&amp;quot;right&amp;quot; onclick=&amp;quot;slideRight()&amp;quot;&amp;gt;right&amp;lt;/span&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;&lt;br /&gt;    var mySwipe;&lt;br /&gt;&lt;br /&gt;    function init(){  &lt;br /&gt;        mySwipe = Swipe(document.getElementById(&amp;#39;mySlider&amp;#39;),{&lt;br /&gt;           speed:400,&lt;br /&gt;           continuous: true,&lt;br /&gt;        });   &lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function slideLeft(){&lt;br /&gt;        mySwipe.prev();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    function slideRight(){&lt;br /&gt;         mySwipe.next();&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br/&gt;The jquery version uses the following code.  &lt;br/&gt;&lt;br/&gt;&lt;pre class=&quot;source-code&quot;&gt;&lt;br /&gt;function init(){&lt;br /&gt;    $(document).ready(function(){&lt;br /&gt;&lt;br /&gt;        var slider = $(&amp;#39;#mySlider&amp;#39;).Swipe({&lt;br /&gt;            speed:400,&lt;br /&gt;            continuous: true,&lt;br /&gt;        }).data(&amp;#39;Swipe&amp;#39;);&lt;br /&gt;&lt;br /&gt;    });&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;Copyright © 2019 ilike2flash. This Feed is for personal non-commercial use only. If you are not reading this material in your news aggregator, the site you are looking at is guilty of copyright infringement. No unauthorized copying allowed.&lt;/div&gt;</description><link>http://www.ilike2flash.com/2014/03/swipejs-example.html</link><author>noreply@blogger.com (iliketo)</author><thr:total>0</thr:total></item></channel></rss>