Before anything else, I have to say a few things. First, in AS3, you cannot place code on an object, and must refer to it's instance name. Second, if you have code remotely changing frames inside a movie clip, you have to make sure all instances of the movie clip are on the same layer and have the same instance name, otherwise when moved to a new frame, the movie clip reverts to the beginning state.
--{Codes}--
Instance Names/Labels/Paths
Instance Names are sorting mechanism Flash uses to define different objects. Say two of the same object are placed on the same workspace and you only want to change one of them. So Flash does not get confused by which one you mean, it has you call each INSTANCE a different name. This can be done by clicking on the object (not the frame the object is in) and opening the properties window.
Labels are names given to keyframes. To label a keyframe, select it and open the properties window.
Paths are required by code to know what to work in. A path is always written with instance names separated by periods. The name of the scene is excluded. Say I wanted to toggle cum on/off on a leg in a game with multiple characters, my path might look something like (right_thigh.peach_thigh.(instance name)) with the (instance name) referring to that of the cum.
Buttons
A button can be placed anywhere in the .fla. I prefer to keep mine in "scene 1" for simplicity. You then need Flash to monitor the button for a click. to do this, you must define where the button is, and a function that clicking the button will execute. The following is this code.
- Code: Select All Code
import flash.events.MouseEvent; ------------//you need to add this before anything else.
button_1.addEventListener(MouseEvent.CLICK, button_1_clk);
function button_1_clk(event:MouseEvent):void{
(~what the function does~)
}
button_1 = The path to the button followed by the button's instance name. (e.g. sprite_1.button_1) Separate with periods. If the button is in "scene 1," don't designate a path, only the instance name.
button_1_clk = The ID of the function that is excecuted once the button is clicked.
(~what the function does~) = The command you want to be excecuted. Copy paste from below.
Common Types of Commands
All of the following commands can be either manually executed (button, if-or statement, etc.), or automatically executed (when the frame is played). For the former, insert the code into the formula above. For the latter, simply place in the action window alone.
1) gotoAndPlay
This command goes to the designated label (e.g. "fuck," "cum," etc.) or frame # (omit the quotations if it is a #)and begins playing. If going to a frame inside a movie clip, the path must be designated at the beginning.
- Code: Select All Code
gotoAndPlay("frame_1");
frame_1 = The frame label or # you want to go to and play at.
2) gotoAndStop
This command goes to the designated label (e.g. "fuck," "cum," etc.) or frame # (omit the quotations if it is a #) and does not begin playing. Good for changing outfits (or cum). If going to a frame inside a movie clip, the path must be designated at the beginning.
- Code: Select All Code
gotoAndStop("frame_1");
frame_1 = The frame label or # you want to go to and stop at.
3) visible
This command toggles visibility of movie clips.
- Code: Select All Code
sprite_1.visible = true/false;
sprite_1 = Path to movie clip and instance name.
true/false = either true or false.
4) stop
Stops at the frame that contains it or at a frame designated ahead of time once the playhead reaches it. Place the frame label or # inside the parentheses if it is wanted. I recommend JUST PLACING IT WHERE YOU WANT TO STOP!
- Code: Select All Code
stop();