FORUMS: list search recent posts

Simple (I hope) sample code request

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Brett Sneed
Simple (I hope) sample code request
on Oct 12, 2011 at 12:41:17 am

Hi - I haven't touched Flash since Adobe acquired it. Anyway, actionscript 3 has me very confused, and I was hoping someone could provide some examples to achieve the following:

1. Jump from scene "skeleton" to scene "hat" when the letter h is pressed.

2. Within a scene ("skeleton"), toggle a layer's visibility every time the spacebar is pressed.

The goal here is I want to make a skeleton's mouth appear to open and close as I press the spacebar so it looks like it is talking. I will be projecting the flash movie and as guests walk into the room, the skeleton will talk to them (I will be in another room watching them via a cheap CCTV set-up, broadcasting my voice into the room). When I compliment someone's costume, I will tell them I tip my hat to them as I press the h key, the scene jumps to an animation where the skeleton hand lifts off the hat and the skull comes off the body. another gimmick is to jump from the friendly skeleton to a very scary one on a different key press, etc. I think you get the idea.

Anyway - if anyone could help, it would be great!



Return to posts index

demetri tashie
Re: Simple (I hope) sample code request
on Oct 12, 2011 at 2:25:44 am

if you must use timelines and scenes, it would at least be better to place a frame label on the first frame of each scene and use them to navigate to. name them 'skeleton1' and 'hat1' or anything else that makes sense.

although you can use code such as nextScene() and previousScene(), that code can often be unreliable.
if you are using timeline navigation, trust labels more than scenes ( at least that was my experience when i was using scenes or long timeline scenarios)

the satge should listen for the events , and take you to whichever frame label based on which key was pressed.

keycode 32 is for space bar and 72 is for the letter h

some simple code like this would do it:
import flash.events.KeyboardEvent;

stop();

stage.addEventListener(KeyboardEvent.KEY_DOWN, goFrameLabel);
function goFrameLabel(e:KeyboardEvent):void {
if (e.keyCode==32){
gotoAndPlay('skeleton1')}
else if (e.keyCode==72){
gotoAndPlay('hat1')}
}


i hope that helps


Return to posts index

Brett Sneed
Re: Simple (I hope) sample code request
on Oct 13, 2011 at 1:33:06 am

Thank you very much. I ended up using the same code to do my open/close mouth thing instead of toggling the layer on and off, I just jumped to a different frame label and back.

You rock!



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]