background preloader

Learn ActionScript

Learn ActionScript

O'reilly: Gentle Introduction I'm going to teach you to talk to Flash. Programming languages are used to send information to and receive information from computers. They are collections of vocabulary and grammar used to communicate, just like human languages. Using a programming language, we tell a computer what to do or ask it for information. It listens, tries to perform the requested actions, and gives responses. So while you may think you are reading this book in order to "learn to program," you are actually learning to communicate with Flash. Learning to speak a computer language is sometimes considered synonymous with learning to program. What would happen if we were to say, "Flash, make a ball bounce around the screen?" Flash couldn't fulfill our request because it doesn't understand the word "ball." Flash still can't fulfill our request without more information. Our hypothetical English-speaking-Flash example exposes four important aspects of programming: Most programming has nothing to do with writing code.

ActionScript® 3.0 Reference for the Adobe® Flash® Platform The ActionScript® 3.0 Reference for the Adobe® Flash® Platform contains the ActionScript language elements, core libraries, and component packages and classes for the tools, runtimes, services and servers in the Flash Platform. Filter by product using the preset filters This reference combines the information about the ActionScript language elements and libraries for the following Adobe products and runtimes. Click on a product name below to filter this reference to show only the content for the latest version of that product and related runtimes: Filter by product using the filter controls Use the controls at the top of the page to customize your view of the reference: Use the filters to include or exclude content for specific products and runtimes.

Constantes y funciones de nivel superior - Información Referencia de ActionScript® 3.0 para la plataforma de Adobe® Flash® public function Vector(sourceArray:Object):Vector.<T> Crea una nueva instancia de Vector con elementos que son instancias del tipo de datos especificado. Cuando se llama a esta función, se debe especificar el tipo de datos de los elementos del vector resultante (el tipo base del vector) mediante un parámetro type. Esta función utiliza la misma sintaxis que al declarar una instancia de Vector o al llamar al constructor new Vector. var v:Vector. El vector resultante se llena con los valores de los elementos del argumento sourceArray. En cualquier caso, el tipo de datos de todos los elementos del argumento sourceArray debe coincidir con el tipo base T especificado en la llamada a la función. Si el argumento sourceArray tiene longitud 0, la función devuelve un vector vacío. Si se transfiere un vector como argumento sourceArray y su tipo base no es T, o si se transfiere un conjunto y sus elementos no son todos instancias de tipo de datos T, se intenta convertir los valores en el tipo base.

Code snippets Adobe Flash Professional CS5 has a feature called the Code Snippets panel that contains ActionScript 3 snippets that are commonly used in projects such as banner advertisements and games. If you've been searching for an easy way to start learning ActionScript 3 and want to add simple interactivity to your projects, then you should learn about this panel. Code snippets are useful not only individually, but can be mixed and matched to rapidly create complex interactive projects. Advanced programmers can use this panel to create and store custom snippets for later use. Each snippet comes with instructions that explain how to use it and what code in the snippet needs to be modified. During this tutorial, you will learn how to do the following: Apply snippets to your graphic assets (both the Add to Frame method and the Heads Up Display method that's new in Flash Professional CS5.5) Edit the properties of snippets Combine multiple snippets The following snippets are featured in this tutorial:

String - ActionScript® 3.0 Reference for the Adobe® Flash® Platform Splits a String object into an array of substrings by dividing it wherever the specified delimiter parameter occurs. If the delimiter parameter is a regular expression, only the first match at a given position of the string is considered, even if backtracking could find a nonempty substring match at that position. For example: var str:String = "ab"; var results:Array = str.split(/a*?/); // results == ["","b"] results = str.split(/a*/); // results == ["","b"].) If the delimiter parameter is a regular expression containing grouping parentheses, then each time the delimiter is matched, the results (including any undefined results) of the grouping parentheses are spliced into the output array. var str:String = "Thi5 is a tricky-66 example If the limit parameter is specified, then the returned array will have no more than the specified number of elements. If the delimiter parameter is undefined, the entire string is placed into the first element of the returned array. Parameters Returns

FLV Playback There have been quite a few changes to the way in which you implement a custom FLV player using the NetConnection and NetStream classes in ActionScript 3. You can look at the code here to see the current ActionScript 2 implementation. The ActionScript 3 version starts out the same way by defining the NetConnection object and passing null its connect method. Also the same is the creation of the NetStream object by passing in a reference to the aforementioned NetConnection object. var nc:NetConnection = new NetConnection();nc.connect(null);var ns:NetStream = new NetStream(nc); We can finally create an embedded video object using only code! var vid:Video = new Video(320, 240);this.addChild(vid); Once we’ve created the video object we now need to connect it to the NetStream object. vid.attachNetStream(ns);ns.play(“test.flv”); There have been major overhauls to the way in which you respond to events from the NetStream class. Lee

Assigning dynamic/unique variable names in a for loop in AS3 | Useful Stuff. Assigning dynamic variable names to objects created in a for loop in AS3. You have to get very creative to search these questions on google because words like “for” and “loop” are so utterly common. If you have a loop in AS3 creating multiple variables but need them to have unique names (for later modification) you need to create something like an array to store the references to the variables. For example, anything you create in a for loop is a temporary reference. In my situation I had a loop creating my navigation elements, but needed to position each X value separately. Here is the method I used to keep the references to these variables: Now, to use those references: To be absolutely clear, the above example creates two MovieClips according to the loop (while i < 2), and places each MovieClip in the mcArray array at index i (which we have defined as the integer counting the loop). Now if I wanted to access those individual MovieClips I could use the mcArray to do so. Like this:

Reusable classes Make your own reusable classes using Flash and AS3 My interest in Flash started mostly because of a Jib-Jab cartoon ("This Land") in 2004. I'm the author of a feature I call "Mazoons," which are a combination of mazes and cartoons. In 2002, I even had a book published, "Super Silly Mazes." I'm not a professional programmer, but making my mazes interactive by programming them with Flash became a hobby/obsession of mine, to the point where I have now learned more than I bargained for. Lately I'm working on a new website about Flash and Actionscript 3.0 called The Flash Connection. View all articles by Jody Hall Let's suppose that in your programming experience, you know how to make a Movie Clip draggable with the mouse, and you also know how to write a routine to make a MovieClip respond to the arrow keys and move around the stage. Packages are just directories (or folders, if you prefer) on your hard drive. There are two ways in Flash to designate a classpath.

AS3 Flash: Low CPU Clouds Animation - Perfect for Mobile In our our recent tutorial on clouds effect via BitmapData.perlinNoise and ColorMatrixFilter, we presented a nice clouds animation but very CPU intensive and not suitable for larger images or for mobile devices. Here we present a version that is extremely CPU efficient, runs very well on Android 2.2, and can be used to generate large images. In the two examples linked below we generate 500 by 380 animations. Click each screen shot or the corresponding text link to open a Flash movie. Download Download all source files corresponding to these effects: cloudsfast.zip How is performance optimized In our previous tutorial, Realistic White Clouds on Blue Sky in AS3 Flash, we presented a method for producing a continuously evolving picture of white clouds on a blue background, making use of Perlin noise and a ColorMatrixFilter. Creating an instance of the clouds is easy: simply use the constructor as follows: About the Code Here is how we do the wrapping. Layering the clouds

Related: