Monster Racer Rush
Select between 5 monster racers, upgrade your monster skill and win the competition!
4.23 / 5.00 3,881 ViewsBuild and Base
Build most powerful forces, unleash hordes of monster and control your soldiers!
3.93 / 5.00 4,634 Viewsso with the on.enterFrame command gone in AS 3.0, i was wondering how i would execute this command and get the same effect with my effect.
here is the effect:
http://www.newgrounds.com/dump/item/a06a9d55c5847d7754f74787 589c20ef
the flames on the left use a MC code
onClipEvent (enterFrame) {
gotoAndPlay(random(28)*0);
}
the slower flames on the left are using a frame command inside the MC
gotoAndPlay(random(28));
how can this be changed to AS 3.0 without losing the individual effects?
thanks for any help :D
At 11/4/12 09:10 PM, Max-Vador wrote: so with the on.enterFrame command gone in AS 3.0, i was wondering how i would execute this command and get the same effect with my effect.
here we go:
AS2 and AS3 are both event-driven. What does this mean?
it means you attach what's called an "event listener" function to Objects. What this does is listen for what's called an "event" to fire, and then run the function you gave it before.
an example:
stage.nativeWindow.addEventListener(Event.RESIZE, onWindowResize);
function onWindowResize(e:Event):void{
//resize stage elements
}
that example will not work outside of an AIR application, and that was intentional. Don't just copy/paste, pay attention.
Q: Did you say AS2?
A: Yes, I did. AS2 is actually a lot more like AS3 than AS1. Thing is, AS2 allows AS1 practices such as
onClipEvent(enterFrame)
the difference here is AS3 doesn't allow that, so your programs come out more structured.
Q: Stage?
A: it's pretty much the equivalent to "_root" - which also means you should need to use it VERY RARELY. Don't abuse "this." and "stage.", and don't ever use "parent."
a few notes:
use FlashDevelop to program (it's free)
The Flash IDE was made for animators, and everything about its coding sucks. FlashDevelop was made for programmers, and has no paint bucket or pencil tool.
if you don't understand function, classes, public, private, etc. I suggest you take a look at "AS3, FD, and OOP the Right Way" - located in the link in my signature.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
thanks again egg
so both 2 and 3.0 have event listeners, but in 3.0 they must be defined, whereas 2.0 they were already defined(but limited to) load, enterFrame, etc?
i'll read up on your tutorials in your sig
At 11/4/12 09:50 PM, Max-Vador wrote: thanks again egg
so both 2 and 3.0 have event listeners, but in 3.0 they must be defined, whereas 2.0 they were already defined(but limited to) load, enterFrame, etc?
i'll read up on your tutorials in your sig
Close, in AS1 the event was onClipEvent(enterFrame) in AS2 it's onEnterFrame = function() {} in AS3 you must define event listeners.
okay, so 3.0 is closer to C+ in that it has unending variables but they are all user defined
At 11/4/12 10:01 PM, Max-Vador wrote: okay, so 3.0 is closer to C+ in that it has unending variables but they are all user defined
Kinda, 2.0 is more like that. In AS2 mode you're allowed to write AS1 code, you'll pretty much have to accept that all AS2 you'll find or write is actually just AS1 from the 90s.
At 11/4/12 10:01 PM, Max-Vador wrote: okay, so 3.0 is closer to C+ in that it has unending variables but they are all user defined
If that's a typo and you meant C++ then no, AS3 has little in common with C++ other than AS3 being a C-like language. Don't know what you mean by "unending variables" though.
At 11/4/12 11:24 PM, Diki wrote: If that's a typo and you meant C++ then no, AS3 has little in common with C++ other than AS3 being a C-like language. Don't know what you mean by "unending variables" though.
C-languages and ECMAScript languages are... About as far away as you can get.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 11/4/12 11:52 PM, egg82 wrote: C-languages and ECMAScript languages are... About as far away as you can get.
ECMAScript has some influence from C, hence it having near identical syntax, but in terms of functionality they're very different.
And if you want to get faaaaaarrr away from ECMAScript you can always look at Fortran, LISP, Forth, or if you're feeling in the mood for some punishment, COBOL.
But this is getting a tad off-topic. :)
onEnterframe is available since As1, too.
The thing that makes it "As2" is it being a member of certain classes.
on() and onClipEvent() only work on one type of object each.
Additionally, they cannot be removed at runtime.
The event methods like onMouseDown are possibly defined by multiple classes. So you can treat them the same way.
Nesting does not work, with them. (button in button)
Some things still needed listeners.
These are 4 ways to handle events and they are not always interchangeable.
---
In As3 there's EventDispatcher, which a lot of classes extend.
It dispatches events.
Kind of a simplification I'd say.
so i took suggestions, i did some reading, and i got it working O_o
surprised myself too
this.addEventListener(Event.ENTER_FRAME, main);
function main(event:Event)
{
flame.gotoAndPlay((int)(Math.random()*28));
}
thanks for all the help.
i'll probably stick to AS 1/2.0 for some of these simple frame actions, but i'm starting to get 3.0
At 11/5/12 03:53 PM, Max-Vador wrote: this.addEventListener(Event.ENTER_FRAME, main);
As scope does not change the way it does in As1/2, you can omit "this." in most scenarios, including this one.
((int)(Math.random()*28));
There are 2 ways to do a cast in As3:
type(expression)
expression as type
As you can see, the braces around the type can be omitted.
You should be able to pass the Number without a cast and get the same result.
okay thanks.
never was good at cleaning up after myself
At 11/5/12 04:16 PM, milchreis wrote: type(expression)
expression as type
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
At 11/5/12 04:55 PM, egg82 wrote:At 11/5/12 04:16 PM, milchreis wrote: type(expression)http://gskinner.com/talks/quick/#46
expression as type
That's off topic.
At 11/5/12 05:15 PM, milchreis wrote: That's off topic.
I suppose, but my point was you should probably try to use type(expression)
function main(event:Event)
datatype variables, and give functions a return value. If you were using FlashDevelop (free coding IDE) it would yell at you.
also, I generally do e:Event, but that's just personal reference. I don't like carpel tunnel.
Programming stuffs (tutorials and extras)
PM me (instead of MintPaw) if you're confuzzled.
thank Skaren for the sig :P
understandable
i'm still learning so whatever you throw at me is a good thing
i read your tutorials egg, very helpful, especially on the if, else structure