ActionScript Teaching

Some thoughts on learning code, Flash and Javascript


For my students, why are you learning to code? Is it just because the school says so for your thesis?

What are you interested in doing? Producing animations that include characters, fancy drawing and game play? Or just text and interface based animations for a text and still photos site? Is your thesis project going to be an app, a responsive site or a dedicated mobile site?

The field is going towards JavaScript, my assumption is in five years almost everything will start with html, css and Javascript and then build in some way or form on that. HTML is just a cockroach that survives. You need to know it cold no matter what.

But animation and game based work is currently a lot easier to do in Flash right now, it’s what Flash started life as and publishing to devices is just easier from it. If you have Android you can do it now as easily as making a swf, Apple makes life harder because Apple (*&*^*&%!!!!****).

Ultimately the reason anyone other then computer scientists should learn to code is that it builds the logic of interactivity into your bones. When you have to make something work you have to pull the problem apart until it reaches it’s smallest unit which you can make. You then have to learn how to assemble blocks into a larger project which is how the pyramids, Rome and everything else was built. So learning to code even if you go become just a UX designer or information architect is important because you know what the tools are that your projects are built with.

Business wise having JS skills makes you much more valuable these days and from that perspective it’s hard to say don’t build it in Flash. But if you have a cool creative idea that is fresh and interesting people will hire you because your smart and do cool things. Since ActionScript and JavaScript are from the same family all of your skills and knowledge will transfer over. Do interesting things with interesting thoughts and no one will care at all what tools you use.


Using Movie Clips from a loaded swf

When you need to load a movie clip in a loaded swf how do you do it? then you want to use the clips in the loaded movie your swf.
Every swf can be loaded in three different ways , while you can use the code included in a movie clip this also allows you to use the visual assets in the fla’s library . to make this work you need two swfs on your base swf with this code in the main timeline

Yes I know it should a class but we’re just trying to learn the basics of the code

In our second swf named s_1.fla is a movie clip in the liibrary named C1 set to dispatch

var _loader:Loader
var info:LoaderInfo
_loader = new Loader(); //create a loader
info= _loader.contentLoaderInfo;//checks the actual contet of the object not just the loader we are splitting things up here
info.addEventListener(Event.COMPLETE, onInit, false, 0, true)// add a listener for the init event that fires when all the assets of the loaded swf is available to you

function onInit (e:Event) {
// e is the intit event it means the swf is ready to be used
// target is the swfs contentloaderInfo every swf has an applicationDomain, a loaded swfs domain by default is the main movies child. hasDefinition is a method it’s asking if in this application is there a Movie CLip named “c1”
trace(“head exists: ” +“c1”) );
// okay so are definition exists but we need to set it up so we can use is as a constructor and make it into a class we do that by using the keyword as types the “c1 as a Class so we can pu tit into a variable and then make a new instance of the it
var head:Class =“c1”) as Class;
var p = new head()
//make a new instance and stick it on the stage

// actually load the swf
_loader.load(new URLRequest(“s_1.swf”))

You should be able to past this code into a main timeline and it will run once you make the second swf named s_1.swf with the movie clip in it.