Hello,
I recently purchased Flash CS5 and I want to get into AS3, but I have a hard time trying to migrate my AS2 knowledge over to AS3.
Using AS2, I’ve always used a container to contain all my MC, but now I have no idea whether this form is used anymore or a better flow of MC management is used.
I’ve seen some tutorials recommending classes, while others simply use an addChild Method. Is someone can explain a new form of way to incorporate a snippet of my AS2 code to AS3 I would greatly appreciate it.
// I want everything to be made inside a container.
// >> I would like to understand how methods are used in AS3
setContainer();
// Hero is inside the container.
// >> I would like to understand how parameter methods are used in AS3
setHero(0,0);
// >> I would like to understand how functions are defined using AS3
function setContainer():Void {
// In the library I have an empty mc labeled 'container'
// >> I would like to understand how MC are attatched
var mc:Object = _root.attachMovie("container", "container", _root.getNextHighestDepth());
// >> I already know the new syntax is mc.x = mc.y = 0;
mc._x = mc._y = 0;
}
//accepts 2 parameters for the location and places a hero on stage inside container mc.
function setHero(xloc:Number, yloc:Number):Void {
// In library I have a mc labeled 'hero'
var mc:Object = _root.container.attachMovie("hero", "hero", _root.container.getNextHighestDepth());
mc._x = xloc;
mc._y = yloc;
//as soon as the hero is on stage, it moves to the right.
// >> I would like to understand how OnEnterFrame is used in as3
// >> to my understanding EVENTS.onENTEREVENT is used. with an 'e'
mc.onEnterFrame = function(){
// >> I am curious if this is still a property used.
this._x += 2;
}
}
stop();
I tried asking for the smallest, yet most useful migration of code for me. thanks!