So for example class buttons - how to make object move on button press if i have class buttons for example ? Him and only him not all objects ?
public class Car{
public var speed : int;
public function accelerate(){
speed += 5;
}
}
Gorepete Wrote:I have been converting some stuff to AS3 and thereby slowly learning it (need as3 for Air to properly export .FLA to .apk/iOS), and classes threw me for a loop at first, but really they do end up being a better concept than they way it is handled in AS2.
Think of a class as an archtype of an object. In AS2, you might have an enemy movie clip (let's say). This movie clip will be in your library and have a bunch of code embedded in it so the game knows how that enemy will act when you drop it on the stage using attachMovie or whatever mechanic you use to spawn and generate enemies. The benefit of this is that the enemy is a nice and neat little self contained package. The drawback of this is that if you have 20 copies of the enemy on the stage, AS2 becomes really, really code intensive trying to manage, organize, and maintain the integrity of those 20 enemies.
Terrantor!!! Wrote:That said, I do miss the ease of actionscript 2's listener functions and the ability to traverse roots, parents, and thises. Really hard to accomplish in as3. I just had more control.
Gorepete Wrote:Terrantor!!! Wrote:That said, I do miss the ease of actionscript 2's listener functions and the ability to traverse roots, parents, and thises. Really hard to accomplish in as3. I just had more control.
This used to drive me nuts too, but then I found out you can just use MovieClip(this.root).whatever or MovieClip(this.parent).whatever the same way you would have used _root.whatever or _parent.whatever in AS2
FruitSmoothie Wrote:Man I wish some of you guys would do tutorials or stream yourself coding and explaining some things or something. It's pretty overwhelming to start off (Especially since I'm trying to learn animation and improve my art at the same time). I just try to learn one or two new things a day, I figure eventually I'll understand enough. Shaymus22 on youtube is a pretty good teacher, I don't think he has many videos though. People usually stop past the basics in video tutorials (For good reason, as I'm sure it'd be very difficult to explain some of the advanced stuff).
I'm not sure how to go about making code for a game as efficient as possible really. I feel like if I try to piece things together, it's going to turn into a mess. I'm kind of worried about learning bad habits. Is it just best to start by getting things to work and worrying about efficiency later? Time to mess with some very basic games...
Users browsing this forum: No registered users