Helpful actionscript 3 commands

A place for tutorials on how to get the most out of Flash

Helpful actionscript 3 commands

Postby jakejoke » Thu Jan 14, 2010 10:33 pm

Thought I'd make a topic on Actionscript 3 commands that are generally useful for this project or whatever.
Will update when I find anything else useful. Feel free to add anything, just try and copy my format for uniformity.
Remember, in Actionscript 3, action commands go in the TIMELINE on a new layer is best. Create keyframes as needed

Creating buttons for navigation
Code: Select All Code
function clickHandler(event:MouseEvent):void {
    gotoAndPlay ('my scene');
}

button.addEventListener(MouseEvent.CLICK, clickHandler);

You can replace clickHandler with whatever you want. Just ensure every button has a different name eg: clickHandler1, clickHandler2 etc.
Replace ('my scene') with the name of your scene, or the actual frame number on your timeline
Replace button with the name of your button instance. Name it in the properties window

Dynamically Change FPS in your movies
Code: Select All Code
this.stage.frameRate = number;

Replace number with an actual number obviously
This is extremely useful for creating scenes that will play slower, or faster depending on the FPS of your document.
Slow-mo cumshots? Hyperspeed blowjobs? It's now possible without having to edit the animation itself.
I've used it in my buttons to navigate the scene. Seems to work best that way.

Disable use of the TAB key (yellow boxes on your buttons)
Code: Select All Code
Movie Clip Name.tabEnabled = false;

Replace Movie Clip Name with the name of your movie clip instance. Name it in the properties window
Last edited by jakejoke on Sat Jan 16, 2010 1:46 am, edited 2 times in total.
------------------
Feels good man
User avatar
jakejoke
 
Joined: Mon Jan 11, 2010 6:33 pm

Re: Helpful actionscript 3 commands

Postby -QQ- » Fri Jan 15, 2010 7:16 am

thanks this'll help for bone animations
Rule 34 killing your childhood since the dawn of porn.
User avatar
-QQ-
 
Joined: Sat Jan 09, 2010 5:40 pm
Location: in your closet watching you

Re: Helpful actionscript 3 commands

Postby JL95 » Fri Jan 15, 2010 8:23 am

Interesting. Will be very useful.

btw, I think that if we want to use a string with gotoAndPlay(), we have to remember to name the keyframe accordingly first?

I remember some on (Press) syntax that can be placed directly into buttons too but am not too sure if it works the same way in 3.0 as in 2.0
JL95
 
Joined: Thu Jan 14, 2010 8:17 pm

Re: Helpful actionscript 3 commands

Postby Renara » Fri Jan 15, 2010 11:28 am

I think it's changed JL95, which is what the first snippet jakejoke has posted is for; ActionScript 3.0 is many ways more javascript-like than 2.0, but also adds a lot of new stuff (such as the ability to specify types, true classes etc.). So rather than defining an explicit event using the on() syntax, you have to create an event handler function, and attach it to the target.

In many ways this is better, though seems a lot more unwieldy at first, however my plan for v0.3 is to produce a load of standard classes which hide the bulk of it so you're not doing anything really much more complicated as an animator, but which will ultimately tie into a standard interface, so you no longer have to add buttons to individual animations.
Renara (team twitter | newgrounds)
Team Lead Programmer
Lok Team Member
Site Administrator
User avatar
Renara
Foxy Admin
 
Joined: Fri Jan 08, 2010 4:16 pm

Re: Helpful actionscript 3 commands

Postby JL95 » Fri Jan 15, 2010 4:31 pm

Ah. I see.

btw, do they still have those yellow boxes popping up whenever we press tab? I remember that used to be one of the main issues with buttons (Especially hidden ones) and people had to use Movie Clips to get around it.
JL95
 
Joined: Thu Jan 14, 2010 8:17 pm

Re: Helpful actionscript 3 commands

Postby Renara » Fri Jan 15, 2010 10:45 pm

I don't think that's to do with the script as-such, though there are scripted ways to prevent it. When you specify buttons there's a way to choose tab-order (which in itself can be used to add "anti-cheat" and such).
Renara (team twitter | newgrounds)
Team Lead Programmer
Lok Team Member
Site Administrator
User avatar
Renara
Foxy Admin
 
Joined: Fri Jan 08, 2010 4:16 pm

Re: Helpful actionscript 3 commands

Postby jakejoke » Sat Jan 16, 2010 1:45 am

Updated for tab key thing
------------------
Feels good man
User avatar
jakejoke
 
Joined: Mon Jan 11, 2010 6:33 pm


Return to Tutorials



Who is online

Users browsing this forum: No registered users