Forum Topic: Oop Action Script?

(159 views • 11 replies)

This topic is 1 page long.

<< < > >>
None

Kings-Cant-Fall

Reply To Post Reply & Quote

Posted at: 10/30/09 08:11 PM

Kings-Cant-Fall NEUTRAL LEVEL 08

Sign-Up: 12/28/04

Posts: 866

I purchased MX 2004 Professional five years ago and used it for about a year. For the last three years I've been working on my CS degree and programming almost exclusively in Java. I heard that the newest Action Script is highly object oriented.

Is there any way to compile the latest AS with MX2004Pro? Can anyone recommend me a good resource? Not something that teaches OOP, but maybe a website listing the libraries and what they entail. Are there any other Java programmers that would be so kind as to tell me the differences in syntax between the two? Especially in the area of classes, inheritance, polymorphism, objects/array of objects?

Any help would be greatly appreciated!


None

Headshot777

Reply To Post Reply & Quote

Posted at: 10/30/09 08:21 PM

Headshot777 FAB LEVEL 21

Sign-Up: 05/04/08

Posts: 3,186

No, I don't think you can use ActionScript 3 in anything lower than Flash CS3, though I heard there was some type of AS3 preview for Flash 8, but it was pretty messed up.

If you're planning on buying Flash CS3 or CS4, though, there are AS3 tutorials all over Google.

12

BBS Signature

None

zrb

Reply To Post Reply & Quote

Posted at: 10/30/09 08:23 PM

zrb LIGHT LEVEL 11

Sign-Up: 08/08/06

Posts: 4,554

If you want to write codes in AS3 and OOP, you can use haXeand/or Flash Develop. There's probably more but I've heard of these two the most.

Oh yeah they're free.

School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

None

knugen

Reply To Post Reply & Quote

Posted at: 10/30/09 08:56 PM

knugen LIGHT LEVEL 35

Sign-Up: 02/07/05

Posts: 4,704

haXe is a language itself, the confusion probably lies in that it can be compiled to .swf's. It's supposed to be a good and standardized language, so it might be worth looking into instead of AS3.

FlashDevelop is AS3 though and an amazing program considering it's free, it should also allow you to work more similar as to how you did with Java (as opposed to the Flash IDE) so that's my recommendation :)


Muted

zrb

Reply To Post Reply & Quote

Posted at: 10/30/09 08:58 PM

zrb LIGHT LEVEL 11

Sign-Up: 08/08/06

Posts: 4,554

At 10/30/09 08:56 PM, knugen wrote: haXe is a language itself, the confusion probably lies in that it can be compiled to .swf's. It's supposed to be a good and standardized language, so it might be worth looking into instead of AS3.

I should pay attention to what I'm posting about and actually know what it is before suggesting it :X

School Sux ! || As :Main || As3: Main || Animation: Main || Flash Tutorials ||

BBS Signature

None

Kings-Cant-Fall

Reply To Post Reply & Quote

Posted at: 10/30/09 09:24 PM

Kings-Cant-Fall NEUTRAL LEVEL 08

Sign-Up: 12/28/04

Posts: 866

Really? A colleague told me that there was some SDK that allowed me to do so. Anyway, say I wrote the following AS2.0 class in an external flash file (.as).

class Triangle {
	private var base:Number;
	private var height:Number;
	private var hypotenuse:Number;
	public function setBase(tempBase:Number):Void {
		base = tempBase;
	}
	public function setHeight(tempHeight:Number):Void {
		base = tempHeight;
	}
	public function setHypotenuse(tempHyp:Number):Void {
		hypotenuse = tempHyp;
	}
	public function draw(baseX:Number, baseY:Number):Void {
		var drawObj:MovieClip = new MovieClip();
		drawObj.moveTo(baseX, baseY);
		drawObj.lineTo(base, 0);
		drawObj.lineTo(0, height);
		drawObj.lineTo(-base, -height);
	}
}

How would I go about implementing this flash in my Main flash file (fla) I tried

#include "Triangle.as"

but it gave me this error

**Error** Triangle.as: Line 1: Classes may only be defined in external ActionScript 2.0 class scripts.

Can I not use my custom class files in my FLA productions?


None

knugen

Reply To Post Reply & Quote

Posted at: 10/30/09 09:34 PM

knugen LIGHT LEVEL 35

Sign-Up: 02/07/05

Posts: 4,704

It's "import" in AS2/3;

import package.Class;

However, I don't think you should waste time on AS2. Set up FlashDevelop, and perhaps download the trial (30 days, all features) of Flash CS4 if you need to work with other graphics than bitmaps (either way FD should be used for coding).


None

Kings-Cant-Fall

Reply To Post Reply & Quote

Posted at: 10/30/09 10:01 PM

Kings-Cant-Fall NEUTRAL LEVEL 08

Sign-Up: 12/28/04

Posts: 866

Can I even package my classes in AS 2.0? It seems like package isn't even a reserved word1?!

package trig {
//code
}

Gives me a syntax error. And neither import trig.Triangle, import trig.*, nor import Triangle; work?!

I'm purchasing CS4 but would like to refamiliarize myself with flash tonight.


None

Afro-Ninja

Reply To Post Reply & Quote

Posted at: 10/30/09 10:12 PM

Afro-Ninja EVIL LEVEL 38

Sign-Up: 03/02/02

Posts: 13,469

At 10/30/09 10:01 PM, Kings-Cant-Fall wrote: Can I even package my classes in AS 2.0? It seems like package isn't even a reserved word1?!
Gives me a syntax error. And neither import trig.Triangle, import trig.*, nor import Triangle; work?!

There are no packages in AS2.
There is no Triangle class in AS2 or AS3
Flashdevelop *can* be used to write AS2, it's just a text editor.
You can still write OOP applications in AS2, it's just not as full-featured

BBS Signature

None

Kings-Cant-Fall

Reply To Post Reply & Quote

Posted at: 10/30/09 10:18 PM

Kings-Cant-Fall NEUTRAL LEVEL 08

Sign-Up: 12/28/04

Posts: 866

At 10/30/09 10:12 PM, Afro-Ninja wrote: There are no packages in AS2.
There is no Triangle class in AS2 or AS3
Flashdevelop *can* be used to write AS2, it's just a text editor.
You can still write OOP applications in AS2, it's just not as full-featured

I know there is no Triangle class in AS2. I created a custom Triangle class (see above) in an external .as file. All I want to do is to import this class in my main FLA file so I can use it's functions and stuf


None

knugen

Reply To Post Reply & Quote

Posted at: 10/30/09 10:23 PM

knugen LIGHT LEVEL 35

Sign-Up: 02/07/05

Posts: 4,704

I moved up to AS3 before getting into OOP, so I'm not very familiar with what's different in AS2, but you can make use of packages (just not with the same syntax): Link.

If you plan on sticking to AS2 you will probably find the whole series of tutorials useful.


None

GustTheASGuy

Reply To Post Reply & Quote

Posted at: 10/31/09 10:47 AM

GustTheASGuy LIGHT LEVEL 08

Sign-Up: 11/02/05

Posts: 11,429

The SDK you heard of was the Flex SDK. It's the core Adobe compiler, it's free. You can use it with Flashdevelop or the few other AS IDEs.
AS3 is very similar to Java, except maybe that it doesn't use proper collections and has some extra dynamic behavior.

haXe is an alternative language and compiler and platform that can be used to build AS3 apps. It very much owns AS3 and the Adobe implementations in all aspects, but it's 'nonstandard'.

To use AS2 classes within Flash you don't need any directives, it automatically resolves occurrences in type decs and constructor calls and imports.

#ngprogramming at irc.freenode.net
haXe | Keel imperative | Spyro! | Thru you


All times are Eastern Standard Time (GMT -5) | Current Time: 01:05 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!