<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-7767350526431700951</id><updated>2012-01-29T15:43:06.434Z</updated><category term='as3 logic xor'/><category term='callback function as3'/><category term='as3 Array erase'/><category term='as3 mouse hide show behaviour'/><category term='as3 class library name'/><category term='video as3'/><category term='video flvplayback time lapse'/><category term='instantiation swf external as3'/><category term='welcome'/><category term='string operation as3'/><category term='as3 class protected internal public private'/><category term='crossdomain xml php'/><category term='as3 flash Array'/><category term='datagrid as3 flash icon'/><category term='xml proxy php urlrequest urlloader'/><category term='text format'/><category term='actionscript flash as3 button cursor hand'/><category term='as3 fraction numbers'/><category term='text format textfield lines'/><category term='as3 fullscreen video'/><category term='as3 preloader Loader progress'/><title type='text'>AS3 snippets</title><subtitle type='html'>Personal blog were I will post as3 snippets that will help  all AS3 programmers to achieve small tasks, not always simple or straightforward.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>29</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-6956653797522847563</id><published>2012-01-17T10:01:00.000Z</published><updated>2012-01-17T10:01:36.699Z</updated><title type='text'>How to Format Text in Actionscript III</title><content type='html'>In the last article I've shown you a way to embed fonts in Actionscript. That process implies that you will have to embed the font on your compiled and final SWF file. This means that you final SWF will increase, and in some cases dramatically, because you are making the fonts you want to use available in your compiled code.&lt;br /&gt;&lt;br /&gt;At this project that I'm working on, this is something we can't do, due to limitation on the hardware we're using. And beacuse the skinning of the application can change, so the fonts can be changed also.&lt;br /&gt;&lt;br /&gt;For this purpose we use font embedding but, the fonts will be stored in external, and dedicated SWF files.&lt;br /&gt;&lt;br /&gt;To start this process, a first step is to make a SWF file just for the font:&lt;br /&gt;- Open a new FLA file in Flash;&lt;br /&gt;- Place the following code in the first and empty frame of the timeline:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;[Embed(source='ARIAL.TTF', fontName = 'Arial', mimeType="application/x-font", unicodeRange="U+0020-U+007E")]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var arial:Class;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;Font.registerFont(arial);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;i&gt;This code is explained in the &lt;a href="http://as3snippets.blogspot.com/2012/01/how-to-format-text-in-actionscript-2.html"&gt;previous article&lt;/a&gt;. So if you came here directly and don't understand what's in here, just go there and see what this means.&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;This SWF will only have the embed characters you tell on the unicodeRange. So if you use any other characters with this font, they won't appear. So make sure your character range is correct.&lt;br /&gt;&lt;br /&gt;Compile the file and place it on your local folder or in a "fonts" folder. In this case I will call it &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;arial.swf&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;To use this in your code just to simply something like this:&lt;br /&gt;- In your AS3 class define a new Loader variable to keep to load the font:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;private var fontLoader:Loader = new Loader();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- Load the font in the main constructor, or wherever it may suit your needs like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;fontLoader.load(new URLRequest("sections/swfs/fonts/arial.swf"));&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;- After this, whenever you want to use the font in a textField you need to use the TextFormat to assign this font and change text appearance, like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var myText:TextField=new TextField();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.defaultTextFormat = new TextFormat("Arial", 38, 0x2DAAFD, true);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.selectable = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.text = "Hello World!";&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;b&gt;NOTE: In the TextFormat, "Arial" is the name you gave the font in the Embed in the font SWF file.&lt;/b&gt;&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;This method makes easier to use and change fonts dynamically, for example defining a font to be used in a textField through an XML file.&lt;br /&gt;&lt;br /&gt;Happy coding!&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-6956653797522847563?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/6956653797522847563/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2012/01/how-to-format-text-in-actionscript-3.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6956653797522847563'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6956653797522847563'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2012/01/how-to-format-text-in-actionscript-3.html' title='How to Format Text in Actionscript III'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-9172909668419964952</id><published>2012-01-17T09:39:00.002Z</published><updated>2012-01-17T10:19:12.175Z</updated><title type='text'>How to Format Text in Actionscript II</title><content type='html'>Some time ago I posted a way to format text using the fonts available in your system that you should, in the first place, import to your library and then use it on your code.&lt;br /&gt;&lt;br /&gt;Meanwhile I had a new project where I was asked to come up with a way to use fonts. This project is to be embeded in a set top box, so there's a limitation about the fonts you can use. That's if the box has any available for you to use.&lt;br /&gt;&lt;br /&gt;In this case there's no font I can use, so I have to "install" my fonts on the box in order to Flash to recognize them.&lt;br /&gt;Another limitation is that the software can use a font, and I mean any font, that the Design department comes up with. This means that at some point I can have more or less fonts installed on the system. If we can't install fonts on the box, how can I use fonts as I please?&lt;br /&gt;&lt;br /&gt;There's two possible answers for this:&lt;br /&gt;&lt;br /&gt;One is using a Flex approach using the Embed tag. In you Actionscipt class, where you define your global variables put something like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;[Embed(source='ARIAL.TTF', fontName = 'Arial', mimeType="application/x-font", unicodeRange="U+0020-U+007E")]&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var arial:Class;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As a brief explanation:&lt;br /&gt;- The source must be a font file already in your local folder;&lt;br /&gt;- The fontName is the name you &amp;nbsp;will call in your code when you want to use the font;&lt;br /&gt;- The mimeType is just something you have to write in order for the compiler to know that this is a font file;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;- The unicodeRange is very important because it gives you the possibility of embedding just the characters you want in unicode. In this case "&lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;U+0020-U+007E&lt;/span&gt;&lt;span style="font-family: inherit;"&gt;" means a-Z (a to z in lower and uppercase).&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;For more details about the characters code to use, visit&amp;nbsp;&lt;a href="http://unicode.org/charts/"&gt;http://unicode.org/charts/&lt;/a&gt;&amp;nbsp;or&amp;nbsp;&lt;a href="http://www.rishida.net/tools/conversion/"&gt;http://www.rishida.net/tools/conversion/&lt;/a&gt;&amp;nbsp;that will make the conversion for you.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;The &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var arial:Class&lt;/span&gt; must come after the Embed tag so that this font instantiated and can be used in the code you make.&lt;br /&gt;&lt;br /&gt;For this you'll have to make a final step, which is: In the constructor of you class, register the font using this line of code&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;Font.registerFont(arial);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;After this whenever you want to use this font just to something like this:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var myTextBox:TextField = new TextField();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myTextBox.defaultTextFormat = new TextFormat("Arial", 38, 0x2DAAFD, true);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myTextBox.selectable = false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myTextBox.text = "My text in Arial";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;addChild(challenge);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;The &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;"Arial"&lt;/span&gt; in&amp;nbsp;new &lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;TextFormat("Arial", 38, 0x2DAAFD, true);&lt;/span&gt; is the name you gave to the font in the Embed tag, the rest is size, color and whether is bold or not.&lt;br /&gt;&lt;br /&gt;The downside of this method is that if you want to use several fonts, you will have to embed them in the code, which mean that you will have to compile each time you change, add or delete a font from the code.&lt;br /&gt;&lt;br /&gt;In my case this has to be more dynamic.&lt;br /&gt;&lt;br /&gt;The &lt;a href="http://as3snippets.blogspot.com/2012/01/how-to-format-text-in-actionscript-3.html"&gt;next article&lt;/a&gt; will show how you can embed the font through a separate SWF file with the font in it. Just click here to go there.&lt;br /&gt;&lt;br /&gt;Happy coding!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-9172909668419964952?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/9172909668419964952/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2012/01/how-to-format-text-in-actionscript-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/9172909668419964952'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/9172909668419964952'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2012/01/how-to-format-text-in-actionscript-2.html' title='How to Format Text in Actionscript II'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-6773899151687298945</id><published>2011-08-25T09:30:00.000+01:00</published><updated>2011-08-25T09:30:53.921+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 class protected internal public private'/><title type='text'>Access modifiers</title><content type='html'>Hello everyone,&lt;br /&gt;&lt;br /&gt;This post is somehow a way to remember some things that might pass you by, specially if you don't use them very often.&lt;br /&gt;&lt;br /&gt;Normally when I define my classes, everything is private unless some method or variable must provide values to another class. Even at this point I consider on putting a callback instead of a public value.&lt;br /&gt;&lt;br /&gt;But recently I had the need to explain what a "protected" class was.&lt;br /&gt;&lt;br /&gt;Well first of all, in AS3, all classes must be declared public, but their methods or variables can be public, private, internal and protected.&lt;br /&gt;&lt;br /&gt;So what's the difference between them?&lt;br /&gt;&lt;br /&gt;I'll make a brief description of each one. Then you have&amp;nbsp;useful&amp;nbsp;links if you want further explanations.&lt;br /&gt;&lt;br /&gt;Public - These are accessible by everyone. Other classes in the same or another package can access these methods or variables.&lt;br /&gt;&lt;br /&gt;Private - Only the class can access them. External class can't see them&lt;br /&gt;&lt;br /&gt;Protected - These methods and variables are only accessible for subclasses. If you declare a class by inheriting from another with protected methods or variables, this children class can access these. If it's not a children class these methods or variables are inaccessible.&lt;br /&gt;&lt;br /&gt;Internal - All methods and variables declared as "internal" are only shared across the same package.&lt;br /&gt;&lt;br /&gt;I think is very straightforward, and only depends of what you're doing and how you plan to do things.&lt;br /&gt;&lt;br /&gt;The following links can enlighten you a bit more:&lt;br /&gt;&lt;a href="http://greenethumb.com/article/27/public-private-protected-internal-access-modifiers-in-as3"&gt;Greenthumb&lt;/a&gt;&lt;br /&gt;&lt;a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7f32.html"&gt;Adobe&lt;/a&gt;&lt;br /&gt;&lt;a href="http://www.kirupa.com/forum/showthread.php?223798-ActionScript-3-Tip-of-the-Day&amp;amp;p=1890503&amp;amp;viewfull=1#post1890503"&gt;Article on Kirupa.com from Senocular&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps... it did for me ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-6773899151687298945?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/6773899151687298945/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2011/08/access-modifiers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6773899151687298945'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6773899151687298945'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2011/08/access-modifiers.html' title='Access modifiers'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-2153071259074195325</id><published>2011-06-17T17:38:00.000+01:00</published><updated>2011-06-17T17:38:19.834+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 preloader Loader progress'/><title type='text'>Simple preloader for the Loader Class</title><content type='html'>I use the Loader class mainly to... well, load an image. It's also used to load external SWF, but at this time, I didn't had the need to use it like that.&lt;br /&gt;&lt;br /&gt;My main job, at this point, as an AS3 developer is to produce infographies for a news agency. Some processes ahve change in the way I must now deliver the work, and one big change is that all the assets like images, videos, sounds and xml files, must be in a remote server.&lt;br /&gt;&lt;br /&gt;This carries a problem which is a possible lag in time while the SWF tries and loads the assets remotely. You have to take care of this, because the web readers of these infos must have some sort of feedback, or else, nothing happens, and they may think something is broken.&lt;br /&gt;&lt;br /&gt;So this time I'll tell you a simple way of making a preloader bar for the Loader class.&lt;br /&gt;&lt;br /&gt;Make a simple class to load the image:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;package{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.MovieClip;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.Loader;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.URLRequest;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public class LoadPhoto extends MovieClip{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private var photoURL:URLRequest;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private var photoLoader:Loader;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public function LoadPhoto(url:String){&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; photoURL=new URLRequest(url);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; photoLoader=new Loader();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; photoLoader.load(photoURL);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addChild(photoLoader);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This is the minimum to load an image or SWF with the Loader.&lt;br /&gt;&lt;br /&gt;If you want to show a progress bar while the data is accessed, you have to draw it. You can add a text field to show the percentage value, but that it's a natural evolution from this progress bar.&lt;br /&gt;&lt;br /&gt;Inside the the LoadPhoto function add the necessary code to make a simple line using a Sprite:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;progressBar=new Sprite();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;progressBar.graphics.lineStyle(3, 0x0000CC); //define thickness and color&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;progressBar.graphics.moveTo(0,0); //initial point of the line&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;progressBar.graphics.lineTo(imageWidth, 0); //the line will be on top&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;progressBar.scaleX=0; //in the beggining the progressBar will be a dot&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;addChild(progressBar);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then we have to catch the size of the data that is been received, and of course it's total amount. We have to associate an event to the Loader to catch these values. For that we have to use the ProgressEvent class. So First of all add to the imports block &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import.events.ProgressEvent&lt;/span&gt;.&lt;br /&gt;Then add this line after the end of the LoadPhoto function:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;photoLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then define a new function that handles this event:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;private function progressHandler(evt:ProgressEvent):void{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;progressBar.scaleX=(evt.bytesLoaded/evt.bytesTotal);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This last function will receive the loaded bytes and the total byte size, and turn them into a value between 0 and 1, which is what we need to define the scaleX of the Bar. You can later add an event listener to remove the progressBar and show the asset.&lt;br /&gt;&lt;br /&gt;In the end the Class with the Loader and a progress bar, will be something like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;package{&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.MovieClip;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.Sprite;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.Loader;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.display.URLRequest;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;import flash.events.ProgressEvent;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;public class LoadPhoto extends MovieClip{&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private var photoURL:URLRequest;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private var photoLoader:Loader;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; private var progressBar:Sprite;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; public function LoadPhoto(url:String){&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;progressBar=new Sprite();&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; progressBar.graphics.lineStyle(3, 0x0000CC); //define thickness and color&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; progressBar.graphics.moveTo(0,0); //initial point of the line&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; progressBar.graphics.lineTo(imageWidth, 0); //the line will be on top&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; progressBar.scaleX=0; //in the beggining the progressBar will be a dot&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addChild(progressBar);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; photoURL=new URLRequest(url);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; photoLoader=new Loader();&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; photoLoader.load(photoURL);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addChild(photoLoader);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;photoLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;private function progressHandler(evt:ProgressEvent):void{&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; progressBar.scaleX=(evt.bytesLoaded/evt.bytesTotal);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-2153071259074195325?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/2153071259074195325/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2011/06/simple-preloader-for-loader-class.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/2153071259074195325'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/2153071259074195325'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2011/06/simple-preloader-for-loader-class.html' title='Simple preloader for the Loader Class'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-986372075548439883</id><published>2011-06-06T12:55:00.000+01:00</published><updated>2011-06-06T12:55:49.178+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='xml proxy php urlrequest urlloader'/><title type='text'>Proxy to read information</title><content type='html'>Hi,&lt;br /&gt;&lt;br /&gt;In a situation where Flash needs to get information from another server, normally a text based information, like XML, there are security issues that need to be overcomed.&lt;br /&gt;&lt;br /&gt;If you try to load a URLRequest using a URLLoader object, it will run normally&amp;nbsp;locally, but if you publish it on the net, it won't work. That's because on network the Flash player request a security file to catch the information, from the server it wants to access.&lt;br /&gt;&lt;br /&gt;That file is called crossdomain.xml (Maybe I'll do a article about this later), which has to be on the root of the accessed server.&lt;br /&gt;&lt;br /&gt;But what if you don't have&amp;nbsp;privileged access to the server and the administrator doesn't want to put that file for you? Probably yesterday I could ask that, but at the time it would involve a lot of people and too much time spent.&lt;br /&gt;&lt;br /&gt;So I had to come up with an alternative solution. That solution is by making this request through a PHP (or ASP) script. In my case I'm more&amp;nbsp;comfortable&amp;nbsp;with PHP, and that's what I'm presenting.&lt;br /&gt;&lt;br /&gt;It works this way:&lt;br /&gt;&lt;b&gt;1- Flash will make the request, including the url that it wants to access to the PHP file;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;2- The PHP file will ask the url given for the information we want to read;&lt;/b&gt;&lt;br /&gt;&lt;b&gt;3- Once it gets to the PHP, it will return the information to the Flash.&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;The PHP won't ask for any crossdomain.xml, so is like someone making the request directly through the address bar of the browser. I read also that there maybe some servers that prevent this mechanism to work, but usually, no. In this case, there's no chance (not that I know of) to get the data unless you can get a&amp;nbsp;privilege&amp;nbsp;to that.&lt;br /&gt;&lt;br /&gt;I know that Adobe has a web page with several proxy script for PHP and ASP, but yesterday I couldn't find it, but another did... and I think it's a much better script that the one of Adobe.&lt;br /&gt;&lt;br /&gt;So here it is. This code is in&amp;nbsp;&lt;a href="http://xmlrpcflash.mattism.com/proxy_info.php"&gt;http://xmlrpcflash.mattism.com/proxy_info.php&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Just copy and paste to a PHP file. Call it "proxy.php" for example.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre class="normal" style="border-bottom-color: grey; border-bottom-style: solid; border-bottom-width: 1px; border-left-color: grey; border-left-style: solid; border-left-width: 1px; border-right-color: grey; border-right-style: solid; border-right-width: 1px; border-top-color: grey; border-top-style: solid; border-top-width: 1px; font-family: Georgia; font-size: 10pt; padding-bottom: 10px; padding-left: 10px; padding-right: 10px; padding-top: 10px; width: 430px;"&gt;&lt;span class="xlang" style="font-family: 'Courier New'; font-size: 9pt;"&gt;&lt;!--?php&lt;/span--&gt;&lt;br /&gt; &lt;br /&gt;&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$post_data&lt;/span&gt; = &lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$HTTP_RAW_POST_DATA&lt;/span&gt;;&lt;br /&gt;&lt;br /&gt;&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$header&lt;/span&gt;[] = &lt;span class="php-quote" style="color: #884433; font-family: 'Courier New'; font-size: 9pt;"&gt;"Content-type: text/xml"&lt;/span&gt;;&lt;br /&gt;&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$header&lt;/span&gt;[] = &lt;span class="php-quote" style="color: #884433; font-family: 'Courier New'; font-size: 9pt;"&gt;"Content-length: "&lt;/span&gt;.&lt;span class="php-keyword2" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;strlen&lt;/span&gt;(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$post_data&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt; = curl_init( &lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$_GET&lt;/span&gt;[&lt;span class="php-quote" style="color: #884433; font-family: 'Courier New'; font-size: 9pt;"&gt;'url'&lt;/span&gt;] ); &lt;br /&gt;curl_setopt(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;, CURLOPT_RETURNTRANSFER, &lt;span class="php-num" style="color: red; font-family: 'Courier New'; font-size: 9pt;"&gt;1&lt;/span&gt;);&lt;br /&gt;curl_setopt(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;, CURLOPT_TIMEOUT, &lt;span class="php-num" style="color: red; font-family: 'Courier New'; font-size: 9pt;"&gt;10&lt;/span&gt;);&lt;br /&gt;curl_setopt(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;, CURLOPT_HTTPHEADER, &lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$header&lt;/span&gt;);&lt;br /&gt;&lt;br /&gt;&lt;span class="php-keyword1" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;if&lt;/span&gt; ( &lt;span class="php-keyword2" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;strlen&lt;/span&gt;(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$post_data&lt;/span&gt;)&amp;gt;&lt;span class="php-num" style="color: red; font-family: 'Courier New'; font-size: 9pt;"&gt;0&lt;/span&gt; ){&lt;br /&gt;    curl_setopt(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;, CURLOPT_POST, &lt;span class="php-num" style="color: red; font-family: 'Courier New'; font-size: 9pt;"&gt;1&lt;/span&gt;);&lt;br /&gt;    curl_setopt(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;, CURLOPT_POSTFIELDS, &lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$post_data&lt;/span&gt;);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$response&lt;/span&gt; = curl_exec(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;);     &lt;br /&gt;&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$response_headers&lt;/span&gt; = curl_getinfo(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;);     &lt;br /&gt;&lt;br /&gt;&lt;span class="php-keyword1" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;if&lt;/span&gt; (curl_errno(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;)) {&lt;br /&gt;    &lt;span class="php-keyword2" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;print&lt;/span&gt; curl_error(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;);&lt;br /&gt;} &lt;span class="php-keyword1" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;else&lt;/span&gt; {&lt;br /&gt;    curl_close(&lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$ch&lt;/span&gt;);&lt;br /&gt;    &lt;span class="php-keyword2" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;header(&lt;/span&gt; &lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;'Content-type: ' . $response_headers['content-type']&lt;/span&gt;);&lt;br /&gt;    &lt;span class="php-keyword2" style="color: #dd2244; font-family: 'Courier New'; font-size: 9pt;"&gt;print&lt;/span&gt; &lt;span class="php-var" style="color: #000077; font-family: 'Courier New'; font-size: 9pt;"&gt;$response&lt;/span&gt;;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="xlang" style="font-family: 'Courier New'; font-size: 9pt;"&gt;?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;On the Flash side, just make the call has you would normally, like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="kASHkwrd"&gt;var&lt;/span&gt;&amp;nbsp;&lt;span class="kASHwrd"&gt;xmlLoader&lt;/span&gt;&lt;span class="kASHop"&gt;:&lt;/span&gt;&lt;span class="kASHidn"&gt;URLLoader&lt;/span&gt;&amp;nbsp;&lt;span class="kASHop"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kASHkwrd"&gt;new&lt;/span&gt;&amp;nbsp;&lt;span class="kASHidn"&gt;URLLoader&lt;/span&gt;&lt;span class="kASHop"&gt;()&lt;/span&gt;;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="kASHkwrd"&gt;var&lt;/span&gt;&amp;nbsp;&lt;span class="kASHwrd"&gt;xmlData&lt;/span&gt;&lt;span class="kASHop"&gt;:&lt;/span&gt;&lt;span class="kASHidn"&gt;XML&lt;/span&gt;&amp;nbsp;&lt;span class="kASHop"&gt;=&lt;/span&gt;&amp;nbsp;&lt;span class="kASHkwrd"&gt;new&lt;/span&gt;&amp;nbsp;&lt;span class="kASHidn"&gt;XML&lt;/span&gt;&lt;span class="kASHop"&gt;()&lt;/span&gt;;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="kASHwrd"&gt;xmlLoader&lt;/span&gt;.&lt;span class="kASHidn"&gt;addEventListener&lt;/span&gt;&lt;span class="kASHop"&gt;(&lt;/span&gt;&lt;span class="kASHidn"&gt;Event&lt;/span&gt;.&lt;span class="kASHidn"&gt;COMPLETE&lt;/span&gt;,&amp;nbsp;&lt;span class="kASHwrd"&gt;LoadXML&lt;/span&gt;&lt;span class="kASHop"&gt;)&lt;/span&gt;;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="color: white; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="kASHwrd"&gt;xmlLoader&lt;/span&gt;.&lt;span class="kASHidn"&gt;load&lt;/span&gt;&lt;span class="kASHop"&gt;(&lt;/span&gt;&lt;span class="kASHkwrd"&gt;new&lt;/span&gt;&lt;span class="kASHidn"&gt;URLRequest&lt;/span&gt;&lt;span class="kASHop"&gt;(&lt;/span&gt;&lt;span class="kASHqt"&gt;"proxy.php?url=http://www.infoimafter.com/net/files/xmlinfo.xml"&lt;/span&gt;&lt;span class="kASHop"&gt;))&lt;/span&gt;;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="color: #003366; line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;In the last line please regard "proxy.php?url=" followed by the url of the data you want to fetch.&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="line-height: 18px; margin-left: 15px; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="margin-left: 15px; text-align: left; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;After all this it worked very well. I thisnk this also insures that the data will be forced to refresh. I don't know if is that some servers I use, but it seems that sometimes cleaning the browser cache it's not enough to refresh data,&amp;nbsp;being&amp;nbsp;requested the normal way.&lt;/span&gt;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="margin-left: 15px; text-align: left; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/dt&gt;&lt;br /&gt;&lt;dt style="margin-left: 15px; text-align: left; text-indent: -15px;"&gt;&lt;span class="Apple-style-span" style="line-height: 18px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Cheers.&lt;/span&gt;&lt;/span&gt;&lt;/dt&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-986372075548439883?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/986372075548439883/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2011/06/proxy-to-read-information.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/986372075548439883'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/986372075548439883'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2011/06/proxy-to-read-information.html' title='Proxy to read information'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-4870487704460759968</id><published>2011-05-12T14:46:00.000+01:00</published><updated>2011-05-13T21:36:15.057+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 resize image loader urlrequest'/><title type='text'>Loading and resizing image</title><content type='html'>This is a simple task to achieve. The AS3 has already a component that does this, but if you want to keep your SWF footprint to a minimum, you must consider this solution.&lt;br /&gt;&lt;br /&gt;Nothing to it, but I seem to keep always forgetting, since I don't deal with this problem very often.&lt;br /&gt;&lt;br /&gt;But here it is for future reference.&lt;br /&gt;&lt;br /&gt;First of all we will be using two classes. One is URLRequest, that will capture the HTTP request for a file with its url. The other is the Loader which is used to load external SWF or image files (PNG, JPG or GIF).&lt;br /&gt;&lt;br /&gt;First of all import these two classes:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import flash.display.Loader;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;import flash.net.URLRequest;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Then instantiate the Loader class outside any function, because we will need it to resize later on.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;private var myLoader:Loader;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia;"&gt;Inside the loadImage function instantiate the URLRequest class by giving it the file url you which (the url can be a relative path. In this case there's no need to place the HTTP protocol).&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia;"&gt;Associate the Loader with this URLRequest, and finally add it to the DisplayList.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;private function loadImage(file:String):void{&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var myRequest:URLRequest = new URLRequest(file);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;myLoader = new Loader();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;myLoader.load(myRequest);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;addChild(myLoader);&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;loadImage("mypicture.jpg");&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you run this, you will see the image "mypicture.jpg" in the stage.&lt;br /&gt;&lt;br /&gt;The next step is to scale the image. Try and write the following lines inside the previous function:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myLoader.width=20;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myLoader.height=40;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;What happens? The image doesn't appear. So what's going on?&lt;br /&gt;&lt;br /&gt;We are trying to scale an object when the object does not have any contents yet.&lt;br /&gt;&lt;br /&gt;We have to listen to the myLoader object to see if it has already load the picture and then we can scale.&lt;br /&gt;&lt;br /&gt;Write the previous function like this adding the line in red:&lt;br /&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;private function loadImage(file:String):void{&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var myRequest:URLRequest = new URLRequest(file);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;var myLoader:Loader = new Loader();&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class="Apple-style-span" style="color: red;"&gt;myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, resizeImage);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;myLoader.load(myRequest);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;addChild(myLoader);&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Don't forget to add the Event class on the import statements.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;The function for resizing by now you should have guessed it:&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;private function resizeImage(evt:Event):void {&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;myLoader.width = 45;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;myLoader.height = 40;&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Simple, right?&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Happy resizing.&lt;/div&gt;&lt;br /&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-4870487704460759968?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/4870487704460759968/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2011/05/loading-and-resizing-image.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4870487704460759968'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4870487704460759968'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2011/05/loading-and-resizing-image.html' title='Loading and resizing image'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-3997620617240053721</id><published>2011-01-06T12:39:00.001Z</published><updated>2011-01-06T12:39:53.576Z</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 mouse hide show behaviour'/><title type='text'>Usability: Click and Drag cursor</title><content type='html'>Although it's a common feature in many flash applications a little feedback for users is always welcome... specially when you have a "click and drag" situation.&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Recently I came across this request for an infography for a client. I make the infography, but the application didn't have a feedback for the user that that area was meant to be draggable, only a small phrase stating that.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I agreed that this would make sense and made the change.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;To substitute the regular Windows mouse icon with one of your own, you must first import the class that controls the mouse UI options, like this:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;import flash.ui.Mouse;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This class let's you use two important features for mouse icon... the hide and show options.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;If you put it like this:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;Mouse.hide();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The mouse icon will&amp;nbsp;disappear,&amp;nbsp;although&amp;nbsp;the mouse still works, but you don't know where it is.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The reverse option will be the show option, like this:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;Mouse.show();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You must import also the MouseEvent class, to set the listeners later:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;import flash.events.MouseEvent;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Now that we have our hide and show options, how can you make a custom icon and make it follow the mouse position?&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Making it simple you have to add a listener for the mouse position, but this is made indirectly, since we are going to listen for any mouse move, and then see where it is.&lt;/div&gt;&lt;div&gt;Making an EnterFrame event can be costly specially if you're application has many pictures or video, like the one I had to make, so we're listening for any mouse move,&amp;nbsp;which&amp;nbsp;is triggered when... you guessed it... the mouse is moved.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;First of all, make a movieclip with the icon you wish to appear, and place it in the library with a export actionscript name. I will call it MyLibraryCursor (remember that when making the movieclip, the "plus" sign indicates where will be the click spot for the mouse).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Make a new object with this Library Class:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;public var myCursor:MyLibraryCursor;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Then on the init() function of your main class, define your new object, along with two important options:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;myCursor = new MyLibraryCursor();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;myCursor.mouseEnabled = false;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;myCursor.mouseChildren = false;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;mouseEnable tells flash if this object receives mouse behaviours. Usually that's a problem when you have many movieclips on the stage, where you can have problems with object focus (this will not disable mouse events).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;mouseChildren is put there to prevent event bubbling. Has you know AS3 has a great feature, but sometimes difficult to control and understand, which is the propagation of events between children of a display object (bubbling). This prevents it from happening (a&amp;nbsp;typical&amp;nbsp;case of this is when you have a text box with text, and the mouse is only active when you pass by the line of a letter).&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Next we will add the mouse movieclip to the stage:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;addChild(Global.myCursor);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Make the "windows" mouse disappear:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;Mouse.hide();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And then listen to the MOUSE_MOVE to make it follow the mouse:&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;this.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This calls the mouseMoveHandler function which will move the custom icon to the mouse position:&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;public function mouseMoveHandler(evt:MouseEvent):void&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;{&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;myCursor.x = evt.stageX;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;myCursor.y = evt.stageY;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span" style="color: orange; font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;And that's it, the basics for replacing the windows cursor, for one of you're own.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Possibly in a future post I will explain other option for this, cleaning a bit the behaviours about this.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;You can make a Global class to easy the control of the mouse behaviour if you have to hide, show and turning off and on, between different display objects across your application... this maybe will to go for a later post.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Cheers.&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-3997620617240053721?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/3997620617240053721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2011/01/usability-click-and-drag-cursor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3997620617240053721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3997620617240053721'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2011/01/usability-click-and-drag-cursor.html' title='Usability: Click and Drag cursor'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-6972580511264488283</id><published>2010-12-19T15:09:00.002Z</published><updated>2011-07-20T18:47:06.523+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='actionscript flash as3 button cursor hand'/><title type='text'>MouseButton and HandCursor</title><content type='html'>Every now and then you may need to use a Sprite or MovieClip with a EventListener. And chances are that 99% of these times it will be a MouseEvent, since these objects are easy to place in custom classes and build an entire interface with Actionscript... at least that will be 100% of the times for me ;)&lt;br /&gt;&lt;br /&gt;So in these cases you don't want to make Button objects, but still be able to feedback the user that in "this" object contains an action with the mouse.&lt;br /&gt;&lt;br /&gt;Well simply placing three lines of code you can show your user the hand cursor (like it appears in a web page), and have the behaviour of a button. Furthermore the third line prevents the hand cursor not to be active if the button has text in it. Those lines go like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;var button:MovieClip = new MovieClip();&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;button.buttonMode &amp;nbsp;= true;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;button.useHandCursor = true;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;button.mouseChildren=false;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;addChild(button);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Cheers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-6972580511264488283?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/6972580511264488283/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/12/mousebutton-and-handcursor.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6972580511264488283'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6972580511264488283'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/12/mousebutton-and-handcursor.html' title='MouseButton and HandCursor'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-5115995232621629981</id><published>2010-10-12T15:18:00.001+01:00</published><updated>2010-10-12T15:19:04.305+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='text format textfield lines'/><title type='text'>How to count number of lines in a TextField</title><content type='html'>I was facing this dilema to correct a game were in the textfields the text can have 1, 2 or 3 lines. Depending on the number of lines I wanted to center the text vertically so that when it had only 1 line, it would append a new line "\n" before the text.&lt;br /&gt;&lt;br /&gt;This only applies to normal dynamic textfields, not TFL. These have their own methods to center text both horizontally and vertically... much easier.&lt;br /&gt;&lt;br /&gt;There's a property called numLines, but this only states that the chosen TextField will have an x number of lines that you specify, you can't use it to return the number of text lines that you see.&lt;br /&gt;&lt;br /&gt;So you have to make another type of calculation, and the textfield must be multiline.&lt;br /&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;var myHeight:Number = myText.height; //store the height of the textfield&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;myText.multiline = true; //don't need to do this, if it is in the properties panel&lt;br /&gt;myText.wordWrap = true; //same as above&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;myText.height = myHeight; // here is the trick, try removing this line&lt;br /&gt;trace("DYNAMIC TEXTFIELD HAVE "+myText.maxScrollV+" LINES");&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;Cheers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-5115995232621629981?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/5115995232621629981/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/10/how-to-count-number-of-lines-in.html#comment-form' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5115995232621629981'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5115995232621629981'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/10/how-to-count-number-of-lines-in.html' title='How to count number of lines in a TextField'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-2387518484806628804</id><published>2010-10-12T00:42:00.000+01:00</published><updated>2010-10-12T00:42:01.528+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video flvplayback time lapse'/><title type='text'>Time lapse for FLVPlayback</title><content type='html'>This is one of those cases when the Adobe documentation is rare, or doesn't help much.&lt;br /&gt;&lt;br /&gt;I had a hard time figuring out how to place a bar that would grow along with the playback of a movie in the FLVPlayback component.&lt;br /&gt;&lt;br /&gt;First make a custom MovieClip with a rectangle (it can be another shape, but usually rectangles are best for these) and give it a name: myPlayhead&lt;br /&gt;&lt;br /&gt;You must have already the FLVPlayback component on stage, with a given name. I will name it: myFLVplayback&lt;br /&gt;&lt;br /&gt;For the script we will need to import a class to do this: VideoEvent. This class has several events you can use to get info from the FLVplayback when playing video (http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/fl/video/VideoEvent.html)&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;import flash.video.VideoEvent;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;//The movie doesn't start&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;myFLVPlayback.stop();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;//Rewinds automatically if the video is stopped or it reaches the end.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;//By default it's false&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;myFLVPlayback.autoRewind=true;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;//Adds the listener for each time the playhead updates it's position&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;myFLVPlayback.addEventListener(VideoEvent.PLAYHEAD_UPDATE, videoHandler);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function videoHandler(evt:VideoEvent):void{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var totalSeconds:Number =&amp;nbsp;myFLVPlayback.totalTime;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var elapsedSeconds:Number =&amp;nbsp;myFLVPlayback.playheadTime;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var percent:Number=Math.round((elapsedSeconds/totalSeconds)*100);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//The custom seekBar will change it's size according the the percentage&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//of the played movie&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;seekBt.progressMc.scaleX=percent;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Cheers&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-2387518484806628804?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/2387518484806628804/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/10/time-lapse-for-flvplayback.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/2387518484806628804'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/2387518484806628804'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/10/time-lapse-for-flvplayback.html' title='Time lapse for FLVPlayback'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-6812389012673876599</id><published>2010-10-12T00:09:00.000+01:00</published><updated>2010-10-12T00:09:29.650+01:00</updated><title type='text'>Custom controls for the FLVPlayback video component</title><content type='html'>This time I had to help a friend that needed to play some videos in a fancy interface.&lt;br /&gt;&lt;br /&gt;The problem was that he didn't want the buttons that Flash provides for video playback, and wanted some flexibility towards mouse events, i.e., beeing able to hide or show the buttons with custom events or mouse events.&lt;br /&gt;&lt;br /&gt;For now I will tell how I changed the controls.&lt;br /&gt;&lt;br /&gt;First of all you need to make some custom MovieClips for the buttons. One MovieClip per button.&lt;br /&gt;&lt;br /&gt;(this is valid for actionscripting the interface, or placing the components directly on stage)&lt;br /&gt;&lt;br /&gt;Place the FLVplayback component in the stage and give it a name: &lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myFlvplayback&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Place the buttons where you want on the interface, and give them a name: playBt, pauseBt, stopBt,... and so on.&lt;br /&gt;&lt;br /&gt;Now the script. You have to associate the buttons to the video component, stating what each button will do, like this:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myFlvplayback.playButton=playBt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myFlvplayback.stopButton=stopBt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myFlvplayback.seekBar=seekBt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;myFlvplayback.pauseButton=pauseBt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;That's it. If you run the movie, you'll see that this is enough to custom controls for this video component.&lt;br /&gt;&lt;br /&gt;A further step is to make a custom interface with the all buttons inside a single MovieClip. Then you can make your custom autohide function with some MouseEvents.&lt;br /&gt;&lt;br /&gt;Cheers&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-6812389012673876599?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/6812389012673876599/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/10/custom-controls-for-flvplayback-video.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6812389012673876599'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6812389012673876599'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/10/custom-controls-for-flvplayback-video.html' title='Custom controls for the FLVPlayback video component'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-5726768399794562525</id><published>2010-09-02T17:53:00.001+01:00</published><updated>2010-09-02T17:56:37.224+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 logic xor'/><title type='text'>Logical XOR</title><content type='html'>Flash doesn't have a logical XOR, only a bitwise XOR. That means that you can only do bitwise operations, or swap number and attribute the result to a variable.&lt;br /&gt;&lt;br /&gt;Well I needed a Boolean XOR, like the one with Truth Tables that we know from logical programming. Well this little function takes care of this:&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;public function xor(lhs:Boolean, rhs:Boolean):Boolean {&lt;p&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;return !( lhs &amp;amp;&amp;amp; rhs ) &amp;amp;&amp;amp; ( lhs || rhs );&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;p&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Leonel&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-5726768399794562525?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/5726768399794562525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/09/logical-xor.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5726768399794562525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5726768399794562525'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/09/logical-xor.html' title='Logical XOR'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-1653515772033427474</id><published>2010-09-01T17:10:00.000+01:00</published><updated>2010-09-01T17:10:52.313+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 fullscreen video'/><title type='text'>Fullscreen... and back</title><content type='html'>To get your stage into full screen you must do in two steps. The first is to set your stage display state in ActionScript. The other is to allow this scaling in the HTML page.&lt;br /&gt;&lt;br /&gt;First of all, place a MovieClip in the stage, by code, or directly in the stage. Give it a instance name.&lt;br /&gt;I will cal mine: fullScr&lt;br /&gt;&lt;br /&gt;Associate with fullScr an event listener to catch a mouse event to execute the full screen:&lt;br /&gt;&lt;br /&gt;fullScr.addEventListener(MouseEvent.CLICK, handleMouseClick);&lt;br /&gt;&lt;br /&gt;Write the handleMouseClick function that will set the display state of the stage. This function will detect the current display state, and change it accordingly. If the display state is NORMAL, it will set it to FULLSCREEN. Otherwise it will be NORMAL again:&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;private function handleMouseClick(me:MouseEvent):void&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; if (stage.displayState == StageDisplayState.NORMAL) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; try{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;stage.displayState=StageDisplayState.FULL_SCREEN;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; catch (e:SecurityError){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;//if you don't complete STEP TWO below, you will get this SecurityError&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; trace("an error has occured. please modify the html file to allow &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; fullscreen mode");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; }else {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&amp;nbsp;    &lt;/span&gt;try{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; stage.displayState=StageDisplayState.NORMAL;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; catch (e:SecurityError){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; //if you don't complete STEP TWO below, you will get this SecurityError&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; trace("an error has occured. please modify the html file to allow&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; fullscreen mode");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="white-space: pre;"&gt;&amp;nbsp;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;If you have a video component like FLVPlayback, when you hit fullscreen, this component will take over the screen because it is on top of everything else. To prevent this add this line:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;myPlayer.fullScreenTakeOver=false;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;Leonel&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-1653515772033427474?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/1653515772033427474/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/09/fullscreen-and-back.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1653515772033427474'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1653515772033427474'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/09/fullscreen-and-back.html' title='Fullscreen... and back'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-4839215620147590093</id><published>2010-08-18T11:15:00.000+01:00</published><updated>2010-08-18T11:15:01.469+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='datagrid as3 flash icon'/><title type='text'>Datagrid with image and events</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;At my company I'm making an application that has many datagrids to manage information that comes from external XML files. Many are related to one another, and some of them are meant to choose online documents, that will be used by chosen users (also in datagrids). One of the requests was to be able to choose a document in the dataGrid and preview the document.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;The first question was, what type of visual aid would there be for the user to see that "you can click here to preview the document"?&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Since this is a Flash application, there was not much sense to use text aids, like a link in HTML, so I wanted to place an icon for the user to click.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;The next question is: How do you place an image in a dataGrid cell?&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Not a trivial one to answer, since the Adobe documentation is not very clear in some aspects, and is incomplete in most cases, and this is one of them.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;You can change the cell rendering option using the cellRenderer class. But how do you do it?&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;After long research over the internet, most users and cases are documented in AS2 using the mx.core.UIComponent. In AS3 is the fl.core.UIComponent, but I stumbled in poor documentation.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;So searching a bit further I discovered an example from Adobe itself, and it's in this webpage:&lt;/span&gt;&lt;br /&gt;&lt;a href="http://www.adobe.com/devnet/flash/quickstart/datagrid_pt3/"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;http://www.adobe.com/devnet/flash/quickstart/datagrid_pt3/&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;I tried to adapt this solution to my problem, and it looked promising, since it was in AS3, and it was exactly what I wanted. Guess what? No errors, but it didn't work either. I changed all variables, made the associations right, but some new classes, new MovieClips in the library... but nothing worked.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Adobe forums... nothing!&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Finnaly, I found forum entry in Kirupa.com, and the user EssencLord, presented a simple solution to overcome this problem. His solution was exactly whath I was looking for.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 12px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;1. Make a separate class and give it a name that will identify it has a cell renderer class. I called it MCCellRenderer, because it will use a MovieClip with an icon inside, to be displayed in the dataGrid:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-size: 1.083em; height: 8pt; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 8pt; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;package src{&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;import fl.controls.listClasses.CellRenderer;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;import flash.utils.getDefinitionByName;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;public class MCCellRenderer extends CellRenderer {&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; public function MCCellRenderer():void {&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="height: 8pt; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 8pt; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var instance = new (getDefinitionByName("eye")); // Create Instance of "eye"&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.addChild(instance);&amp;nbsp;&amp;nbsp;&amp;nbsp; // Add this instance to the CellRenderer&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance.name = "eye";&amp;nbsp;&amp;nbsp;&amp;nbsp; // Name this new instance&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Position Movie in Cell&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance.x += 18;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; instance.y += 10;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-size: 1.083em; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;span class="Apple-style-span" style="color: #333333; font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 12px;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;2. Then in the main class, associate this class with the cell you want in the dataGrid:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-size: 1.083em; height: 8pt; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 8pt; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-size: 1.083em; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;var verCol:DataGridColumn = new DataGridColumn("Ver");&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;verCol.cellRenderer = MCCellRenderer;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-size: 1.083em; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'andale mono', times;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;If you want to associate a MouseEvent with that particular cell, you can do it like this:&lt;/span&gt;&lt;/div&gt;&lt;div style="font-size: 1.083em; line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="font-family: 'andale mono', times; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;1.Add an event listener do the datagrid:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;MyDataGrid.addEventListener(MouseEvent.CLICK, onClickCell);&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px;"&gt;2. And here's and function that will detect which cell was clicked, and react accordingly:&lt;/span&gt;&lt;/div&gt;&lt;div style="line-height: 1.462; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: 17px; line-height: 25px;"&gt;&lt;span class="Apple-style-span" style="color: black; line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: black; font-family: Georgia, 'Times New Roman', serif; line-height: 19px;"&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 25px;"&gt;&lt;span class="Apple-style-span" style="color: black; line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;function onClickEvent (E:Event)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black; line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;{&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 25px;"&gt;&lt;span class="Apple-style-span" style="color: black; line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;   // if a record is selected&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 25px;"&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;   if (eventGrid.selectedIndex != -1)&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: black; line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;   {&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: black; line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;      // Check if user clicked on the Info Icon CellRender of the selected Row&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;      var Row = eventGrid.selectedIndex;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif; font-weight: normal;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;      // get selected row&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;      var Col = eventGrid.getColumnIndex("Ver");&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;      // the column of cells with MCCellRenderer&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;      if (E.target == eventGrid.getCellRendererAt(Row, Col))&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;         MyFunction ();&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;         &lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;   }&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="line-height: 19px; white-space: pre;"&gt;&lt;b&gt;Keep it simple&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-4839215620147590093?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/4839215620147590093/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/08/datagrid-with-image-and-events.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4839215620147590093'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4839215620147590093'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/08/datagrid-with-image-and-events.html' title='Datagrid with image and events'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-5511269363758080556</id><published>2010-08-13T11:42:00.003+01:00</published><updated>2010-08-13T11:47:08.541+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='callback function as3'/><title type='text'>Function Call Back</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;This is very handy feature when programming in AS3.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Imagine that you make a AlertBox class, that when called, it makes a custom Alert message. Imagine then, that you can put 1, 2 or 3 buttons, according to the message type.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;If you want to reuse this class in several projects, it's a good idea to tell the&amp;nbsp;different&amp;nbsp;buttons what or where to return when it's pressed.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;That's were the Function Call Back enters. After a couple of hours and some search in the web, I came up with a solution, which I want to share.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;It's very simple.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;First declare in your class a variable that will keep the function reference later on, like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;private var callBack:Function;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Then when you instantiate the Class, one of the arguments, of the constructor or function, will keep the function name, like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;createAlert(..., callback){&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;...&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;}&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Finally inside the constructor or function, you have to attribute the argument to the variable you defined earlier, like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;callBack=callback;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Then place this variable as a call of some event, like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;button1.addEventListener(MouseEvent.CLICK, callBack);&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;... and that's it.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;If you want to call the call back function with arguments, instead of a event, just call this way:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;typeOfMessage=1;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;&lt;br /&gt;&lt;/i&gt;&lt;/b&gt;&lt;/span&gt; &lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;&lt;i&gt;callback(typeOfMessage);&lt;/i&gt;&lt;/b&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-5511269363758080556?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/5511269363758080556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/08/function-call-back.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5511269363758080556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5511269363758080556'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/08/function-call-back.html' title='Function Call Back'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-3336394447475295610</id><published>2010-05-30T15:42:00.001+01:00</published><updated>2010-05-30T15:43:21.299+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 flash Array'/><title type='text'>Cloning arrays</title><content type='html'>On the other day I had the need to copy an Array. It was not the first time, but this time I had to make a temporary copy of another array, and put some new data in it and make some calculations.&lt;br /&gt;&lt;br /&gt;In this process my need to change the original Array, was none.&lt;br /&gt;&lt;br /&gt;The problem is that if you make something like this:&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var myArray:Array=new Array("Blue", "Yellow");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;var myCopyArray:Array=new Array();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;myCopyArray=myArray;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;... it works to some extent. You can also do this with concat or slice commands.&lt;br /&gt;This method makes a &lt;i&gt;shallow copy&lt;/i&gt;, which means that the copy only stores the reference to the original values, that is, it only stores the memory reference where the values are stored. This means that if you change one of the arrays, the other will change also... This was not what I meant.&lt;br /&gt;&lt;br /&gt;I needed to make a &lt;i&gt;hard copy&lt;/i&gt; of the array, change it, without changing the original. During the research, I found this generic solution presented in a webpage by Adobe at the following link:&lt;br /&gt;&lt;a href="https://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;amp;file=00000092.html"&gt;https://www.adobe.com/livedocs/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&amp;amp;file=00000092.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As always I transcript the code to here and make a brief explanation.&lt;br /&gt;&lt;br /&gt;So the function looks like this:&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;pre style="font-family: Courier, mono; font-size: 13px; margin-bottom: 0px; margin-top: 0px;"&gt;import flash.utils.ByteArray;&lt;br /&gt;&lt;br /&gt;function clone(source:Object):*&lt;br /&gt;{&lt;br /&gt;    var myBA:ByteArray = new ByteArray();&lt;br /&gt;    myBA.writeObject(source);&lt;br /&gt;    myBA.position = 0;&lt;br /&gt;    return(myBA.readObject());&lt;br /&gt;}&lt;/pre&gt;&lt;pre style="font-family: Courier, mono; font-size: 13px; margin-bottom: 0px; margin-top: 0px;"&gt;&lt;/pre&gt;&lt;pre style="font-size: 13px; margin-bottom: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Basically what this does is it goes to the memory and gets what is stored in the place where the original Array is referenced. To get the original data and not the reference, it uses the ByteArray class and stores the data in the myBA:ByteArray object. The ByteArray class insures that it copies whatever is stored in the original Array, i.e, Numbers, String, DisplayObjects, whatever...&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-size: 13px; margin-bottom: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-size: 13px; margin-bottom: 0px; margin-top: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Pretty handy...&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-3336394447475295610?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/3336394447475295610/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/05/cloning-arrays.html#comment-form' title='9 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3336394447475295610'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3336394447475295610'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/05/cloning-arrays.html' title='Cloning arrays'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>9</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-4543525520498485087</id><published>2010-05-21T16:06:00.001+01:00</published><updated>2010-08-25T15:45:07.542+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 Array erase'/><title type='text'>How to erase a element in a Array</title><content type='html'>&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;I came across this problem recently.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;The Array has some methods, and the most common are PUSH, that lets you put an element in a Array. This element will go to the end.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;And then you have the POP method, but this only gets the last element in a Array.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;Now the question is "How do I delete an element giving the position for that element"?&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;It's a bit trickier, and it's done using another method called SPLICE. &lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;The syntax is:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;splice(startIndex:&lt;/span&gt;&lt;a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/int.html" style="color: #0000cc; text-decoration: none;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;int&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;, deleteCount:&lt;/span&gt;&lt;a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/uint.html" style="color: #0000cc; text-decoration: none;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;uint&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;,&amp;nbsp;&lt;/span&gt;&lt;a href="http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/statements.html#..._(rest)_parameter" style="color: #0000cc; text-decoration: none;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;...&lt;/span&gt;&lt;/a&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&amp;nbsp;values)&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;This means:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;- startIndex -&amp;gt; Initial position were you want to delete. It's the index position of the Array;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;- deleteCount -&amp;gt;This is how many elements you want to delete, that includes the index position you specified in startIndex. If you say 1, then it will delete the index position that you've specified. If you say 2, then it's the index position, and the next element... and so on.&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;As an example:&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;var myList:Array=new Array("Blue", "Red", "Green", "Black,"White");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;myList.splice(2,2);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;trace(myList); //Blue, Red, White&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Lucida Console', 'Courier New', Courier, monospace; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 12px;"&gt;//Green is Index number 2, and then deletes two elements including Green, which are Green and Black&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-4543525520498485087?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/4543525520498485087/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/05/how-to-erase-element-in-array.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4543525520498485087'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4543525520498485087'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/05/how-to-erase-element-in-array.html' title='How to erase a element in a Array'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-3568964597978760309</id><published>2010-05-04T10:26:00.000+01:00</published><updated>2010-05-04T10:26:35.439+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='instantiation swf external as3'/><title type='text'>Instantiate an SWF as a Class</title><content type='html'>&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;At the company where I work we add the need to make several SWF that needed to come up, in different timings and according to user navigation. But since we wanted to keep the final application as light as possible, we had the need not to instantiate all the external swf at once.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', serif;"&gt;After some research we found and implemented the following solution: instantiate external swf's as separate classes:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: Arial; font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-size: 13px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-size: medium;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;package{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;import flash.display.MovieClip;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;import flash.events.Event;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;import flash.net.URLRequest;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;import flash.display.Loader;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;public class Load extends MovieClip&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; var storeLoadedObject:Class; //Self explained ;)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; var loader:Loader;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; public function Load():void{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; loader=new Loader();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; loader.load(new URLRequest("example.swf"));&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeObjForEdit);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; public function completeObjForEdit(evt:Event):void{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var className:String="com.gameRoot"; //Document class of loaded file&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;storeLoadedObject=loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;makeLotsOfCopies();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; public function makeLotsOfCopies():void{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;for(var i:uint=0; i&amp;lt;20;i++){&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var copy:MovieClip=new storeLoadedObject();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addChild(copy);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; copy.x=i*5;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; copy.y=i*5;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;And that's it.&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-3568964597978760309?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/3568964597978760309/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/05/instantiate-swf-as-class.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3568964597978760309'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3568964597978760309'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/05/instantiate-swf-as-class.html' title='Instantiate an SWF as a Class'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-3858430202287801409</id><published>2010-04-25T23:33:00.002+01:00</published><updated>2010-08-25T15:47:25.470+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='video as3'/><title type='text'>Video smoothing in AS3</title><content type='html'>&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;This is an issue I found that has made serious difficulties to developers&amp;nbsp; about video playback. If you have a video file in flv format, and it has a size that is smaller than the stage where you want to show it in, Flash pixelizes the video. This is the default behaviour of Flash when playing video.&amp;nbsp;&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;There's a workaround but it's a direct one, as it was in AS2.&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;In AS2 you would do like this:&lt;/div&gt;&lt;br /&gt;&lt;pre&gt;&lt;code&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;myVideoObject&lt;/b&gt;&lt;/span&gt;&lt;/code&gt;&lt;span class="mmbody"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;.smoothing = true | false&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-size: small;"&gt;&lt;span class="mmbody"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-size: small;"&gt;&lt;span class="mmbody"&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;In AS3 you have to get to the "smoothing" in other way. Like this:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="mmbody"&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="mmbody"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;b&gt;videoLoader.getVideoPlayer(videoLoader.activeVideoPlayerIndex).smoothing = true;&amp;nbsp;&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="mmbody"&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span class="mmbody"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&amp;nbsp;Where&lt;i&gt; videoLoader&lt;/i&gt; is the FLVPlayback component that you insert with ActionScript.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-3858430202287801409?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/3858430202287801409/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/04/video-smoothing-in-as3.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3858430202287801409'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3858430202287801409'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/04/video-smoothing-in-as3.html' title='Video smoothing in AS3'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-7760517738001098769</id><published>2010-04-12T11:48:00.002+01:00</published><updated>2011-06-03T22:59:27.328+01:00</updated><title type='text'>How to load an external SWF</title><content type='html'>This is how you can load an external SWF, using the progress event to make some sort of preloader.&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="color: #080808; font-family: monospace; white-space: pre;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;div class="codesnip" style="color: white; direction: ltr; margin: 0px; padding: 0px; text-align: left;"&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; flash.&lt;/span&gt;&lt;/span&gt;&lt;span class="me1" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;net&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;URLRequest&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; flash.&lt;/span&gt;&lt;/span&gt;&lt;span class="me1" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;display&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Loader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; flash.&lt;/span&gt;&lt;/span&gt;&lt;span class="me1" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;events&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;import&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; flash.&lt;/span&gt;&lt;/span&gt;&lt;span class="me1" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;events&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ProgressEvent&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; startLoad&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; mLoader:&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Loader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; = &lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Loader&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; mRequest:&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;URLRequest&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; = &lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;new&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;URLRequest&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="st0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;“MouseActions.swf”&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; mLoader.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;contentLoaderInfo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;addEventListener&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;COMPLETE&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;,&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;onCompleteHandler&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; mLoader.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;contentLoaderInfo&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;addEventListener&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ProgressEvent&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;PROGRESS&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;,onProgressHandler&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; mLoader.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;load&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;mRequest&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; onCompleteHandler&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;loadEvent:&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Event&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;addChild&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;loadEvent.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;currentTarget&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;content&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Times New Roman';"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;function&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; onProgressHandler&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;mProgress:&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;ProgressEvent&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;{&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw2" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; var&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; percent:&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;Number&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt; = mProgress.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bytesLoaded&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;/mProgress.&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;bytesTotal&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="kw3" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&amp;nbsp;&amp;nbsp; trace&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;percent&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="codesnip" style="color: white; direction: ltr; margin: 0px; padding: 0px; text-align: left;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;/span&gt; startLoad&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;(&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="br0" style="margin: 0px; padding: 0px;"&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="font-family: 'Courier New',Courier,monospace;"&gt;&lt;span class="Apple-style-span" style="font-size: small;"&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-7760517738001098769?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/7760517738001098769/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/04/how-to-load-external-swf.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/7760517738001098769'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/7760517738001098769'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/04/how-to-load-external-swf.html' title='How to load an external SWF'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-1337125228562751126</id><published>2010-01-19T19:11:00.000Z</published><updated>2010-01-19T19:11:34.944Z</updated><title type='text'>XML loading class</title><content type='html'>This article is about loading xml data, on files or webservices. Sometimes, some projects require that you must read lots of information that are scattered throught many xml files or webservice. This class will help you not to recode every time you must read such type of information. Instead you only have to read the data acording to the response you receive.&lt;br /&gt;&lt;br /&gt;So if you use this class, you just need to instatiate an object and call the file/webservice. Instantiate a new object for each file/webservice.&lt;br /&gt;&lt;br /&gt;This code was copied from the website: http://www.mediareason.com/blog/?p=20&lt;br /&gt;&lt;br /&gt;&lt;pre class="actionscript"&gt;package com.&lt;span style="color: #006600;"&gt;func&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;import&lt;/span&gt; flash.&lt;span style="color: #006600;"&gt;net&lt;/span&gt;.&lt;span style="color: #006600;"&gt;URLLoader&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;import&lt;/span&gt; flash.&lt;span style="color: #006600;"&gt;net&lt;/span&gt;.&lt;span style="color: #006600;"&gt;URLRequest&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;import&lt;/span&gt; flash.&lt;span style="color: #0066cc;"&gt;xml&lt;/span&gt;.&lt;span style="color: #006600;"&gt;XMLDocument&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;import&lt;/span&gt; flash.&lt;span style="color: #006600;"&gt;errors&lt;/span&gt;.&lt;span style="color: #006600;"&gt;*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;import&lt;/span&gt; flash.&lt;span style="color: #006600;"&gt;events&lt;/span&gt;.&lt;span style="color: #006600;"&gt;*&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;public&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;class&lt;/span&gt; LoadXML&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;private&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;var&lt;/span&gt; loader : URLLoader;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;private&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;var&lt;/span&gt; mainXML : &lt;span style="color: #0066cc;"&gt;XML&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;public&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;function&lt;/span&gt; LoadXML&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt; &lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;loader = &lt;span style="color: black; font-weight: bold;"&gt;new&lt;/span&gt; URLLoader&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;loader.&lt;span style="color: #006600;"&gt;addEventListener&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;Event.&lt;span style="color: #006600;"&gt;COMPLETE&lt;/span&gt;, onComplete&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;loader.&lt;span style="color: #0066cc;"&gt;load&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: black; font-weight: bold;"&gt;new&lt;/span&gt; URLRequest&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;"http://.../test.xml"&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;private&lt;/span&gt; &lt;span style="color: black; font-weight: bold;"&gt;function&lt;/span&gt; onComplete&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;evt:Event&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;try&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;mainXML = &lt;span style="color: black; font-weight: bold;"&gt;new&lt;/span&gt; &lt;span style="color: #0066cc;"&gt;XML&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;loader.&lt;span style="color: #0066cc;"&gt;data&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;trace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;mainXML&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt; &lt;span style="color: #0066cc;"&gt;catch&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: #0066cc;"&gt;e&lt;/span&gt;:&lt;span style="color: #0066cc;"&gt;Error&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #0066cc;"&gt;trace&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;(&lt;/span&gt;&lt;span style="color: red;"&gt;"Error: "&lt;/span&gt; + &lt;span style="color: #0066cc;"&gt;e&lt;/span&gt;.&lt;span style="color: #0066cc;"&gt;message&lt;/span&gt;&lt;span style="color: #66cc66;"&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #b1b100;"&gt;return&lt;/span&gt;;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: #66cc66;"&gt;} &lt;br /&gt;&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-1337125228562751126?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/1337125228562751126/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2010/01/xml-loading-class.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1337125228562751126'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1337125228562751126'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2010/01/xml-loading-class.html' title='XML loading class'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-2453026504079229005</id><published>2009-11-05T17:13:00.001Z</published><updated>2010-08-25T15:49:17.310+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 fraction numbers'/><title type='text'>Decimal to Fraction</title><content type='html'>This class will be very handy to transform a decimal number to a fraccion. This was taken from forum entry in Actionscript.org and the user "rondog" converted a AS2 class to AS3. This is one more place where you can get it.&lt;br /&gt;&lt;br /&gt;&lt;pre class="alt2" style="border: 1px inset; height: 516px; margin: 0px; overflow: auto; padding: 6px; width: 100%;"&gt;package com.&lt;span style="color: black;"&gt;lookmum&lt;/span&gt;.&lt;span style="color: black;"&gt;util&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;public&lt;/span&gt; &lt;span style="color: #993300;"&gt;class&lt;/span&gt; Fraction&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;private&lt;/span&gt; &lt;span style="color: #993300;"&gt;static&lt;/span&gt; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; it&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt; = &lt;span style="color: black;"&gt;0&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;public&lt;/span&gt; &lt;span style="color: #993300;"&gt;static&lt;/span&gt; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; iterationLimit:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt; = &lt;span style="color: black;"&gt;10000&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;public&lt;/span&gt; &lt;span style="color: #993300;"&gt;static&lt;/span&gt; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; accuracy&amp;nbsp; &amp;nbsp; :&lt;span style="color: #993300;"&gt;Number&lt;/span&gt; = &lt;span style="color: black;"&gt;0&lt;/span&gt;.&lt;span style="color: black;"&gt;00001&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;public&lt;/span&gt; &lt;span style="color: #993300;"&gt;function&lt;/span&gt; Fraction&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;private&lt;/span&gt; &lt;span style="color: #993300;"&gt;static&lt;/span&gt;&amp;nbsp; &lt;span style="color: #993300;"&gt;function&lt;/span&gt; resetIt&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;span style="color: #993300;"&gt;void&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; it = &lt;span style="color: black;"&gt;0&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;private&lt;/span&gt; &lt;span style="color: #993300;"&gt;static&lt;/span&gt;&amp;nbsp; &lt;span style="color: #993300;"&gt;function&lt;/span&gt; addIt&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;span style="color: #993300;"&gt;Boolean&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; it++;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;it == iterationLimit&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;trace&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: blue;"&gt;'error : too many iterations'&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;return&lt;/span&gt; &lt;span style="color: #993300;"&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;else&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;return&lt;/span&gt; &lt;span style="color: #993300;"&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;public&lt;/span&gt; &lt;span style="color: #993300;"&gt;function&lt;/span&gt; getFractionString&lt;span style="color: black;"&gt;(&lt;/span&gt;num:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;span style="color: #993300;"&gt;String&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; fracString:&lt;span style="color: #993300;"&gt;String&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; fracArray:&lt;span style="color: #993300;"&gt;Array&lt;/span&gt; = getFraction&lt;span style="color: black;"&gt;(&lt;/span&gt;num&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;switch&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;fracArray.&lt;span style="color: #993300;"&gt;length&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;case&lt;/span&gt; &lt;span style="color: black;"&gt;1&lt;/span&gt; :&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fracString = num.&lt;span style="color: #993300;"&gt;toString&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;case&lt;/span&gt; &lt;span style="color: black;"&gt;2&lt;/span&gt; :&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fracString = fracArray&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;.&lt;span style="color: #993300;"&gt;toString&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt; + &lt;span style="color: blue;"&gt;'/'&lt;/span&gt; + fracArray&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;.&lt;span style="color: #993300;"&gt;toString&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;case&lt;/span&gt; &lt;span style="color: black;"&gt;3&lt;/span&gt; :&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fracString = fracArray&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;.&lt;span style="color: #993300;"&gt;toString&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt; + &lt;span style="color: blue;"&gt;' '&lt;/span&gt; + fracArray&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;.&lt;span style="color: #993300;"&gt;toString&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt; + &lt;span style="color: blue;"&gt;'/'&lt;/span&gt; + fracArray&lt;span style="color: black;"&gt;[&lt;/span&gt;&lt;span style="color: black;"&gt;2&lt;/span&gt;&lt;span style="color: black;"&gt;]&lt;/span&gt;.&lt;span style="color: #993300;"&gt;toString&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;break&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;return&lt;/span&gt; fracString;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;public&lt;/span&gt; &lt;span style="color: #993300;"&gt;function&lt;/span&gt; getFraction&lt;span style="color: black;"&gt;(&lt;/span&gt;num:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;:&lt;span style="color: #993300;"&gt;Array&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; fracArray:&lt;span style="color: #993300;"&gt;Array&lt;/span&gt; = &lt;span style="color: #993300;"&gt;new&lt;/span&gt; &lt;span style="color: #993300;"&gt;Array&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; hasWhole:&lt;span style="color: #993300;"&gt;Boolean&lt;/span&gt; = &lt;span style="color: #993300;"&gt;false&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;num &amp;gt;= &lt;span style="color: black;"&gt;1&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; hasWhole = &lt;span style="color: #993300;"&gt;true&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fracArray.&lt;span style="color: #993300;"&gt;push&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;floor&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;num&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;num - &lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;floor&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;num&lt;span style="color: black;"&gt;)&lt;/span&gt; == &lt;span style="color: black;"&gt;0&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;return&lt;/span&gt; fracArray;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;if&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;hasWhole&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; num = num - &lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;floor&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;num&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; a:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt; = num - &lt;span style="color: #993300;"&gt;int&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;num&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; p:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt; = &lt;span style="color: black;"&gt;0&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;var&lt;/span&gt; q:&lt;span style="color: #993300;"&gt;Number&lt;/span&gt; = a;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resetIt&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;while&lt;/span&gt; &lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;abs&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;q - &lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;round&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;q&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt; &amp;gt; accuracy&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;{&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; addIt&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; p++;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; q = p / a;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fracArray.&lt;span style="color: #993300;"&gt;push&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;round&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;q * num&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fracArray.&lt;span style="color: #993300;"&gt;push&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;&lt;span style="color: #993300;"&gt;Math&lt;/span&gt;.&lt;span style="color: #993300;"&gt;round&lt;/span&gt;&lt;span style="color: black;"&gt;(&lt;/span&gt;q&lt;span style="color: black;"&gt;)&lt;/span&gt;&lt;span style="color: black;"&gt;)&lt;/span&gt;;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: #993300;"&gt;return&lt;/span&gt; fracArray;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: black;"&gt;}&lt;/span&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-2453026504079229005?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/2453026504079229005/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/11/decimal-to-fraction.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/2453026504079229005'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/2453026504079229005'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/11/decimal-to-fraction.html' title='Decimal to Fraction'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-6542281689270690944</id><published>2009-10-26T18:52:00.001Z</published><updated>2010-08-25T15:50:36.145+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='as3 class library name'/><title type='text'>Instantiate from library by class name</title><content type='html'>&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;This maybe is one of the best hints for any as3 developer.&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;You have several objects in the Library, and some of them have sequenciall names, like "obj1", "obj2", "obj3"... and so on.&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Normally if you want to instanciate an object from the library you would do like this:&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var obj1:obj1=new obj1();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;var obj2:obj2=new obj2();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;...&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;What do you think... tedious, right? and not eficient, at all.&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;One of the solutions is to use the &lt;b&gt;flash.util&lt;/b&gt; class that as a method called &lt;b&gt;getDefinitionByName&lt;/b&gt;, wich can help a lot on this sort of thing.&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;By the upper example you just need a &lt;b&gt;FOR&lt;/b&gt; cycle to instantiate all the objects. Imagine that I have from obj1 to obj5, this is how I would do it:&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;import flash.util.*;&lt;/div&gt;&lt;br /&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;private function instObj():void{&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; for(var i:Number=1; i&amp;lt;6; i++){&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; &amp;nbsp; var name:String="obj"+i;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var object = new (getDefinitionByName(name) as Class)();&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; addChild(object);&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; } &lt;/div&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-6542281689270690944?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/6542281689270690944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/10/instantiate-from-library-by-class-name.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6542281689270690944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/6542281689270690944'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/10/instantiate-from-library-by-class-name.html' title='Instantiate from library by class name'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-1512082863153110130</id><published>2009-10-25T00:12:00.001+01:00</published><updated>2009-10-25T00:16:20.314+01:00</updated><title type='text'>Generalize Methods</title><content type='html'>&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;This one I saw in the "Actionscript 3 Cookbook" by Joey Lott, Darron Schall, Keith Peters and published by O'Reilly. Although it's on the first chapter of the book, it may come handy most of the times.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;This recipe applies when you have a method and you want to use it several times, but with slightly different numbers of arguments, like calculating the average number. You can calculate the average between 2 numbers, or maybe, 7.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Lets &amp;nbsp;make a example:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;public function average (num1:Number, num2:Number):void{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; trace("The average number is: "+(num1+num2)/2;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;You call this method like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;average(3,6);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;The answer will be:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;The average number is: 4.5&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;So how can I call the average method with a different number of arguments?&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;In the first place, you don't specify the number of arguments you put in the method, when you define it.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&amp;nbsp;Then, you must have a cycle inside the method, that will read all the arguments when you call it.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Do it like this:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;public function average():Number{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;var sum:Number=0;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;for(var i:Number=0; i&lt;arguments.length; i++){=""&gt;&lt;/arguments.length;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; sum+=arguments[i];&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;return sum/arguments.length;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;The keyword arguments will retrieve the number and the value of the arguments that you place when you call a method.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;then call the function like this:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var value:Number=average(2,3,4);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;or&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var value:Number=average(5,6,7,8,9,10);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;This is a nice feature&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-1512082863153110130?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/1512082863153110130/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/10/generalize-methods.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1512082863153110130'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1512082863153110130'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/10/generalize-methods.html' title='Generalize Methods'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-4025184443323451190</id><published>2009-10-16T15:22:00.006+01:00</published><updated>2009-10-16T15:35:24.204+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='text format'/><title type='text'>How to Format Text in Actionscript</title><content type='html'>&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;This time I will post a snippet about how to format text in a textfield that is placed dynamicaly in the Stage.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Firstly you must insert the TextField on the stage. For that you need to place these two line in order to import the class that controls the TextField object in AS3. The second import, will import the class that control the appearence of TextFields:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;import flash.text.TextField;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;import flash.text.TextFormat;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Next you need to create the TextField and place it in the DisplayObject list:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var myText:TextField = new TextField();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;addChild(myText);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Next you can tell Flash if the user can select the text, and if you want some border around the TextField:&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.selectable = false;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.border = false;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Next you can tell if the TextField is autosizable, that is, if the text inside is to be dynamic, maybe you need the TextField to stretch or shrink, according to the text value. You can even tell if the autosize is to the right, center or left:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.autoSize = "center";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Now we're ready to format the contents of the TextField. For that you need to create a TextFormat object that will be associated to the TextField later on.&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Create the TextFormat object:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;var myFormat:TextFormat = new TextFormat();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Define the font face you want to use. Then you can define if the text is to bold, underline or italic:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myFormat.font = "Myriad Pro";&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myFormat.bold = true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Give it some colour:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myFormat.color = 0xFF0000;   &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Change the size:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myFormat.size = 12;  &lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Finally associate the TextFormat to the TextField:&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;myText.setTextFormat(myFormat);&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Georgia, 'Times New Roman', serif;"&gt;Happy Texting...&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-4025184443323451190?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/4025184443323451190/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/10/how-to-format-text-in-actionscript.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4025184443323451190'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/4025184443323451190'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/10/how-to-format-text-in-actionscript.html' title='How to Format Text in Actionscript'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-8254611946804824741</id><published>2009-10-06T16:48:00.020+01:00</published><updated>2011-04-27T15:08:02.159+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='crossdomain xml php'/><title type='text'>AS3 Sandbox</title><content type='html'>&lt;span style="font-size: 85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: georgia;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Flash has some issues towards using foreign information, that is, you have an SWF file that has to access an external XML file, or other type of file. When this type of error occurs, you will get (if you have the Flash Player Debugger) a sandbox violation.&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; You have two ways to solve this... one that requires PHP or ASP, or any other script language knowledge, and the other requires that you have access to the source server (the one that has the information that you require).&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; This example will be to retrieve XML data, for example, a WebService.&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; 1. By PHP, ASP or other script language (I will focus on PHP)&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; In order to do this you have to establish a "proxy" file, wich is, a file that will retrieve the data for you.&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; It works this way: In the same directory where the SWF file is you have to put a PHP (or ASP, or...) file that has a command to get the information. This is very simple.&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; In the SWF side:&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: georgia;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;function loadNews():void {&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; var loader:Loader = new Loader();&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; xml_NwsLoader.addEventListener(Event.COMPLETE, loadXMLNews, false, 0, true);&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt;&amp;nbsp;&amp;nbsp; xml_NwsLoader.load(new URLRequest("http://example.com/proxy.php"));&lt;/span&gt;&lt;br style="font-family: Arial,Helvetica,sans-serif;" /&gt;&lt;span style="font-family: Arial,Helvetica,sans-serif;"&gt; }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Notice that I will not call the XML file but a PHP one.&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; In the PHP side you must put a simple address call to get the data you want.&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: georgia;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&amp;nbsp;&lt;/span&gt; &lt;br /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;You can always look for a example and download files for Coldfusion, PHP, ASP and Java Servlet at this URL&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; http://kb2.adobe.com/cps/165/tn_16520.html&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; 2. Using crossdomain&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; For this technique is supposed that you have access to the server where the XML file, or webservice is.&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; You must put a file at the server root called crossdomain.xml&lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; &lt;/span&gt;&lt;br style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt; You can see examples of this in detail in the Adobe site&lt;/span&gt; &lt;br /&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;http://kb2.adobe.com/cps/142/tn_14213.html&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-size: 85%;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-size: 100%;"&gt;&lt;span style="font-family: georgia;"&gt;&lt;span style="font-family: courier new;"&gt;&lt;span style="font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Cheers. &lt;/span&gt;&lt;cross-domain-policy&gt;&lt;allow-access-from domain="www.company.com"&gt;&lt;br /&gt;&lt;/allow-access-from&gt;&lt;/cross-domain-policy&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-8254611946804824741?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/8254611946804824741/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/10/as3-sandbox.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/8254611946804824741'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/8254611946804824741'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/10/as3-sandbox.html' title='AS3 Sandbox'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-5398205140963905855</id><published>2009-08-17T10:57:00.004+01:00</published><updated>2009-08-17T11:18:31.511+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='string operation as3'/><title type='text'>Strings and Arrays</title><content type='html'>Continuing my last message about "String operations" some more usefull functions to use with strings. These allow you to receive a all string and separate them into data chunks that you can put in a array. It's usefull if get data like a cvs file, where all data is separated with a comma, ou semicollom(;)&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var rainbow:String="red;orange;yellow;green;cyan;blue;violet";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Split string into an array using the (;)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;trace(rainbow.split(";"));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;or&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var colourArray:Array=rainbow.split(";");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This will split the string in all the colors that are separated by the ";" symbol, and put them in a array&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. Split string a few times only&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;trace(rainbow.split(";",3));&lt;/span&gt;&lt;/div&gt;&lt;div&gt;or&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var colourArray:Array=rainbow.split(";",3);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;This will do the same as above, but limited to three splits&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;========================================&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;There's another operation that is even more powerfull... the combination of Split with Join.&lt;/div&gt;&lt;div&gt;This allow you to search for a word in text and replace it with another&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. To remove a repeating word in text&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;var rainbow:String="red then comes orange then comes yellow then comes green then comes cyan then comes blue then comes violet";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;rainbow=rainbow.split(" then comes ").join("");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;trace(rainbow);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;2. Replacing words&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;span class="Apple-style-span"  style=" ;font-family:Georgia;"&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;var rainbow:String="red then comes orange then comes yellow then comes green then comes cyan then comes blue then comes violet";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style=" ;font-family:'courier new';"&gt;rainbow=rainbow.split(" then comes ").join(";");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;trace(rainbow);&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-5398205140963905855?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/5398205140963905855/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/08/strings-and-arrays.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5398205140963905855'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/5398205140963905855'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/08/strings-and-arrays.html' title='Strings and Arrays'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-3595566038574233587</id><published>2009-08-17T10:25:00.004+01:00</published><updated>2009-08-17T10:56:25.974+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='string operation as3'/><title type='text'>String operations</title><content type='html'>Dealing with String sometimes gets you wonder "How can I split this?", "Can I extract that?".&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Well, AS3 has some pretty function that manage to do this, but sometimes, the documentation gets you wonder how practical it is.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So here are some examples for common operations with Strings:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;My string: &lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var myString:String="Always speak the truth, think before you speak, and write it down afterwards.";&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;==============================================&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;1. Show the first character&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var fstChar:String=myString.charAt(0);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;2. Output the first 6 characters&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var sixChar:String=myString.substring(0,6);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;3.  Output from the sixth character&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var fromSixth:String=myString.substring(6);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;4. Slice the string from the 8th to the 12th character (basically will to the same has the substring)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var eigthToTwelve:String=myString.slice(8,12);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;5. Search for a word and output it's position&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var search:String=myString.search("truth");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;6. Convert all letters to lower case&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var lowerCase:String=myString.toLowerCase();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;7. Convert all letters to upper case&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var upperCase:String=myString.toUpperCase();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;8. Length of a string&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var howBig:Number=myString.length;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;9. Concatenation... or adding something to the string (String are not like numbers, you can't add an "a" to a "b", so the operation "a"+"b" will result in "ab")&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;10. Replacing text with other text (this might get trickier)&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-style-span"  style="font-family:'courier new';"&gt;var rplcText:String=myString.replace(myString.substring(0,6),"sometimes");&lt;/span&gt;&lt;/div&gt;&lt;div&gt;(this will replace the word "Always", wich is between character 0 and 6, and replace it with the word "sometimes")&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Hope it helps someone.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-3595566038574233587?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/3595566038574233587/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/08/string-operations.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3595566038574233587'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/3595566038574233587'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/08/string-operations.html' title='String operations'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-7767350526431700951.post-1631510153415615547</id><published>2009-08-17T10:09:00.000+01:00</published><updated>2009-08-17T10:18:32.333+01:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='welcome'/><title type='text'>Welcome</title><content type='html'>Hi everybody,&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I thought of creating this blog, mostly because there are small pieces of code, that can be recycled to different situations.&lt;/div&gt;&lt;div&gt;We all can find some pieces of code and keep a bookmark for the web page that contains it, but sometimes it's not praticall to have scattered pages with the code we need, and some pages, will eventually, be offline or disappear.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So with this in mind I'me creating this blog to help me, and all of you that will find some of the snippets usefull.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;Althought it's called "AS3 Snippets", wich is main programming language that I use, it's not exclusive to it. If you think some sort of snippet will be usefull to everyone, please email it to me, to include.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Thank you.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/7767350526431700951-1631510153415615547?l=as3snippets.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://as3snippets.blogspot.com/feeds/1631510153415615547/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://as3snippets.blogspot.com/2009/08/welcome.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1631510153415615547'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/7767350526431700951/posts/default/1631510153415615547'/><link rel='alternate' type='text/html' href='http://as3snippets.blogspot.com/2009/08/welcome.html' title='Welcome'/><author><name>Leonel Serra</name><uri>https://profiles.google.com/103868582576755683569</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='//lh6.googleusercontent.com/-ips_khF9940/AAAAAAAAAAI/AAAAAAAAAAA/sZpINcjwhk0/s512-c/photo.jpg'/></author><thr:total>0</thr:total></entry></feed>
