Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




KeyStroke Function Not Working



Okay, this _seemed_ simple enough... but somehow I seem to have screwed it up. I have this code attached to a button. next to the button is an input text box, if that matters in any way. Now, if I click on the button, sure enough, I jump to the next scene. but I can hit the enter key a thousand times(trust me on this one) and it just refuses to go. what am I missing? on (release, keyPress "<Enter>") { nextScene();} Thanks in advanceSim



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 09-12-2004, 01:11 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

KeyStroke Function Not Working
Okay, this _seemed_ simple enough... but somehow I seem to have screwed it up. I have this code attached to a button. next to the button is an input text box, if that matters in any way. Now, if I click on the button, sure enough, I jump to the next scene. but I can hit the enter key a thousand times(trust me on this one) and it just refuses to go. what am I missing?



on (release, keyPress "<Enter>") {
nextScene();
}


Thanks in advance
Sim

Keystroke Script Not Working
I have a movie that I want to control with a keystroke; it will jump to the next frame as I hit the enter key.


Code:
this.on(keyPress "<Enter>");{
this.nextFrame();
}


This won't work when I publish it into a Windows projector (.exe).

Does anyone know if it's my code or the way it's published?

Keystroke Listener Not Working In .exe
*This is for AS 2.0, not 3. (wrong forum)*

I have a movie that I want to control with a keystroke; it will jump to the next frame as I hit the enter key.


Code:
this.on(keyPress "<Enter>");{
this.nextFrame();
}
This won't work when I publish it into a Windows projector (.exe).

Does anyone know if it's my code or the way it's published?

On (keystroke)?
I am trying to set up a button that would enable the spacebar and right arrow keys to navigate the flash movie. I used the example the macromedia site gives and it won;t work. Any thoughts?

This is what I am using now.

on (keyPress "<Right>"){
gotoAndStop(65);
}

[Help] Keystroke - More Then Once Per Hit?
Hey everyone,

I just have a question. This has always been a problem when I make things in flash , in this case a game, and it really fustrates me

If you use the whole "if (Key.isDown(Key.SHIFT))" or any key for that matter , flash considers it being pressed more then once when you clearly only pressed it once.
This is because it considered it pressed down constantly when you hold the key down , but it happens so fast that it seems to you as the user that you only pressed the key down simply once


This might not be a problem in most cases, but unfortunatly for me Im not part of that catagory. My problem is this:


1) Im making a platform game, but there are two characters in it. When you press the shift button, it will go to the other character and vice versa.

2) There is a _root.player = false; variable. False being the red character and true being the blue one

3) When you press the shift button, the variable should simple just change back and forth between true and false

4) But since Flash considers what seems to be one easy hit of the shift key a bunch of keystrokes, the _root.player variable changes between true and false numerous times sometimes causing it to land back on what it was originally



Anyways, if someone could help me out here it'll be greatly appreciated as always

Simulate Keystroke?
is it possible to simulate a keypress in flash mx??? say i wanted to simulate the backspace key or a character key being pressed in an input text field???


thanks

SOUND ON KEYSTROKE
Hello! Does anybody know how to trigger sound on a keystroke in Flash 5. I’m trying to get the user warned (audio) according to what is being written within input text field.
Thx

Keystroke Capturing
onClipEvent(mouseDown){
if (Key.isDown(Key.CONTROL)){
this.startDrag();
}
}

Why doesn't this work in my browser when it works fine when previewing? Key.isDown(Key.CONTROL) never evaluates to true for some reason in Explorer...

This is in Flash MX

Cheers,

GP
gp@1lg.com

Imaginary Keystroke
Can a flash file be programmed to hit an imaginary keystroke?

ie: When the loop starts, it sends "control-L" to the computer?


Thanks for your help!

Button Using Keystroke
I want to make a keystroke (using "i") stop sounds and another keystoke (using "y") to activate the sound again. It will work in the movie, but not in the html. Does anyone know why it won't work when embedded in the html page?

Keystroke Password
is there a way to make a goto function work off of a keystroke pattern

Keystroke Control
I needed some actionscript that would toggle a movieclip on and off with the same keystroke. I got working but after hitting the key multiple times back and forth the movie starts to slow and I get "A script in this movie is causing Flash Player to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?" This is no good! here's the script I used on a frame of the main timeline that flips between 2 labeled frames to get the toggle effect:

stop();
keyListener = new Object();
keyListener.onKeyDown = function () {
if (Key.getAscii() == 49) {
_root.gotoAndStop("playcube");
}
}
Key.addListener(keyListener);

Thanks for any help!

Movie Changes On Keystroke
I have this flash movie that is a bus that can be moved around witht he keypad so that the up arrow moves it up and the down arrow moves it down etc. I'd like for it to be more realistic so when it is moving left it should be facing left and so on and so forth. The way I think this should be done would be in the bus movie create individual frames with different images in and individual frame labels, i.e. the bus facing left in frame 1 label =left , the bus facing forward in frame 2 label = front, etc and then use this code

Code:
on (keyPress "<Right>") {
currentX = this._x;
this._x = currentX + 5;
_root.turnRight();
}
with the turnRight(); called fro the main scene's actions layer

i.e.

Code:
function turnRight(){
gotoAndStop("movie", "right");
}
so why doesn't this work?

and is there an easier way?

CURSER & KEYSTROKE PROB
Hi

I have a input text variable on the main timeline called "message" and would like the curser to blink in this variable on loading of the page, i also want to be able to use the Enter key on my keyboard to send the value of "message" to my server can anybody help me out with this and suggest the scripting i need please...

Keystroke Capturing Weirdness
onClipEvent(mouseDown){
if (Key.isDown(Key.CONTROL)){
this.startDrag();
}
}

Why doesn't this work in my browser when it works fine when previewing? Key.isDown(Key.CONTROL) never evaluates to true for some reason in Explorer...

This is in Flash MX

Cheers,

GP
gp@1lg.com

How Can I Assign A Keystroke To A Button?
I'm using buttons to initiate actions, but I would prefer to simply make them invisible and respond to keystrokes. Can anyone help me out?

Simulate Keystroke In Flash MX?
hi again all,

just wondering if there is a way to simulate a keypress in flash mx.

not just myVar = "k" for example but as if a key has actually been pressed.

tnx!

Active Button With Keystroke
Hi, I have a series of buttons already created so that when you rollover them, a short movie clip with an embeded sound plays. It works something like and animated keyboard. I would like to associated the buttons with keystrokes as well. This would would work so that when you press the button "A" the "A" key will play the movie that has the sound and animation in it.

Example:

(keypress A) My_A_button.State = "Rollover"
or
(keypress A) My_A_button.State = "Down"

I am using flash MX.

Activate A Button With A Keystroke
Hi, I have already created a series of buttons so that when you rollover them, a short movie clip with an embeded sound plays. It works something like and animated keyboard. I would like to associated the buttons with keystrokes as well. This would would work so that when you press the "A" key on the keyboard the "A" button will go in a "rollover" "down" state.

Example:

(keypress A) My_A_button.State = "Rollover"
or
(keypress A) My_A_button.State = "Down"

thanks for your help!

Keystroke Triggering Sounds
i'd like to kick out a clip where there are half a dozen buttons that, when clicked, trigger sounds. this is no problem in itself, however i'm wondering how i could assign each button to a letter on the keyboard. any help/suggestions would be much appreciated.

thanks,
lane

Play Movie On Keystroke
I made a movie as a symbol inside my scene and I want it to play when you hit the letter b on the keyboard. I'm not sure how to go about doing this. i tried using

on (keyPress "B") {
gotoAndPlay(3);
}

but that didn't work. any helP?

Assign Actions On Each Keystroke
Hi,

I'm trying to assign an action to a different movie clip with each keystroke.

I have this code so far, but not getting anywhere. It listens for the "a" keystroke and does what it should, but how do I move on to the next mc on the stage?

Thanks.

-----------------------------------

onClipEvent (keyDown) {
watchKeys = new Object();
watchKeys.onKeyDown = function(){
if(Key.getCode() == 65){
gotoAndStop(2);
tellTarget ("_root.top") {
gotoAndStop(2);
}
}
}
Key.addListener(watchKeys);
}

---------------------------------

F6 Keystroke Not Recognized By Actionscript
I am trying to get this code to execute in the last frame of a swf, but the result is no response at all. Help?


PHP Code:



this.onEnterFrame = function() {
    if (Key.isDown(117)) {
        loadMovieNum("../images/feedback_correct_daace24.swf", 4);
    } else {
        loadMovieNum("../images/feedback_incorrect_daace26g.swf", 4);
    }
};
stop(); 

Emulate Keystroke In Flash App?
I am trying to invoke keystroke in flash without users typing. It is a bit different from typical keyboardEvent because the user won't be typing anything. I am wondering whether this is possible to be achieved within the power of Flash or Javascript.

Changing Text With Keystroke
FlashMX
Here is what I'm trying to do. I want to be able to have a dynamic text box that contains the titles for the photos in the photo gallery. The titles would be stored in a .txt file with variables such as title1, title2, etc. As the images change with the button click, so would the value of the variable for the text box.

I've been working on script pieces in different files.Here's what I have:

This gets me an array that I can cycle through with keystrokes. This is on frame 1 of the actions layer.

this.title_array=[title1,title2];
this.title_index=0;
title=this.title_array[this.title_index];
function ChangeTitle(d){
this.title_index=(this.title_index+d)%this.title_a rray.length;
if(this.title_index<0){
this.title_index += this.title_array.length;
}
title=this.title_array[this.title_index];
trace(title);
}
function onKeyDown(){
if(Key.getCode()==Key.LEFT){
this.ChangeTitle(-1);
}else if(Key.getCode()==Key.RIGHT){
this.ChangeTitle(1);
}
};
Key.addListener(this);

The next piece is a LoadVars piece that loads the variable from the text file. I have this on frame 1 on the LoadData layer.

titleVars = new LoadVars();
titleVars.onload = addItems;
titleVars.load("text.txt");

I have this on frame 1 of the actions layer.

function addItems(){
title1 = titleVars.title1;
title2 = titleVars.title2;
}

So, I have been trying to combine them but haven't been having much luck.I just started working with actionscript about 5 days ago, so I'm sure there is probably a simple solution that I'm overlooking.

Thanks for the help

Start Animation With A Keystroke
I have a line on a client who wants someone to create an animation that "starts with a keystroke". Info is a bit fuzzy right now, but I'm pretty sure that what he means to say is that he wants there to be an initial frame or scene and then for it to proceed, he just hits "ENTER" or whatever. I've never done anything like that before. Is it possible? And if so, can someone just give me a point in the right direction? This guy wants me on-site tomorrow, so any quick help would be much appreciated and bring glorious karma and stuff. Thanks in advance!

Removing Keystroke Delay
How can I make it so that when I press a key the key doesnt type once, wait a second, then repeat ti'll you let go, I want it to be smooth

Keystroke Listener Based Menu
I have a menu consisting a movie clip with several buttons linking to different scenes and named frames within scenes. The menu appears when a user hits the space bar using the following code placed on a blank "listener" movieclip:

onClipEvent (load) {
_global.stopped = false;
}
on (keyPress "<Space>") {
_root.clipboard.nextFrame();
if (_global.stopped) {
_root.play();
_global.stopped = false;
} else {
_root.stop();
_global.stopped = true;
}
}


The stopped variable is so that the movie will pause when the menu is up, selfPaced simply prevents the movie from advancing during certain scenes.

The buttons on the menu each have the following code:

on (release) {
_global.stopped = false;
_root.gotoAndPlay("3d");
_root.clipboard.gotoAndPlay(7);
}

where "3d" could be any label.

Here is the strange thing: Everything works fine EXCEPT in scene three. Then two of the button simply stop working. The cursor will change to a hand, but the mouseOver action does not work and I can't click them. I have even tried cutting and pasting the menu from another scene, but nothing seems to work. I've also examined the code over and over and it is identical to all of instances of the menu in other working scenes. Any suggestions?

Extremely Weird Keystroke Problem
Hi,

I'm going to try to explain this as well as I can. I have a game that is in one scene, on 3 keyframes. The first keyframe is the menu, the second is the actual game, and the third is a high score page. On the high score page, there is a datagrid. When you play the game without the datagrid on that high score page, everything works perfectly fine, and keystrokes are detected on the game page. Then, when you put the data grid on the high score page, the keystrokes are not detected when you start the game up. Then, if you uncheck the export to actionscript within the datagrid linkage properties, and start the game, it works fine. BUT if you go to the high score page first, before the game is played, the keystrokes are not detected. Note: when I put the datagrid on the high score page there is no code attached to it right now, just the plain component. This same error will occur when I put any component on the high score page.

Does anyone have any idea why this might be happening?

Thank you for any help what so ever,
~David

Problems Capturing Enter Keystroke
Hello,

I have a curious dilemma in trying to capture the enter keystroke.


Here's what I'm trying to do:


1. Set the focus on a text field when the program loads.
2. When the user enters text and hits the enter button, it fires a function.

Now, the code below is nearly there but when the program loads, and you type in any key EXCEPT THE ENTER KEY, all keystrokes are capured and recorded EXCEPT THE ENTER KEY.

The only way you can cause the enter key to respond is by first physically pointing and clicking your mouse in the text field first and then hitting enter.

Here's the code:
username_txt.focusEnabled = true;
Selection.setFocus(username_txt);


TextField.prototype.onKeyDown = function ()
{
trace( "onKeyDown" );
if( Key.getCode() == Key.ENTER ){ trace( "ENTER PRESSED" ); } /*doesn't work unless you first pointed and clicked your mouse in the textfield */
}
};

TextField.prototype.onKeyUp = function ()
{
trace( "onKeyUp" );
if( Key.getCode() == Key.ENTER ){ trace( "ENTER PRESSED" ); } /*doesn't work unless you first pointed and clicked your mouse in the textfield */
}


Very strange.

Any Ideas?

Problems Capturing Enter Keystroke
Hello,

I have a curious dilemma in trying to capture the enter keystroke.


Here's what I'm trying to do:


1. Set the focus on a text field when the program loads.
2. When the user enters text and hits the enter button, it fires a function.

Now, the code below is nearly there but when the program loads, and you type in any key EXCEPT THE ENTER KEY, all keystrokes are capured and recorded EXCEPT THE ENTER KEY.

The only way you can cause the enter key to respond is by first physically pointing and clicking your mouse in the text field first and then hitting enter.

Here's the code:
username_txt.focusEnabled = true;
Selection.setFocus(username_txt);


TextField.prototype.onKeyDown = function ()
{
trace( "onKeyDown" );
if( Key.getCode() == Key.ENTER ){ trace( "ENTER PRESSED" ); } /*doesn't work unless you first pointed and clicked your mouse in the textfield */
}
};

TextField.prototype.onKeyUp = function ()
{
trace( "onKeyUp" );
if( Key.getCode() == Key.ENTER ){ trace( "ENTER PRESSED" ); } /*doesn't work unless you first pointed and clicked your mouse in the textfield */
}


Very strange.

Any Ideas?

Problems Capturing Enter Keystroke
Hello,

I have a curious dilemma in trying to capture the enter keystroke.


Here's what I'm trying to do:


1. Set the focus on a text field when the program loads.
2. When the user enters text and hits the enter button, it fires a function.

Now, the code below is nearly there but when the program loads, and you type in any key EXCEPT THE ENTER KEY, all keystrokes are capured and recorded EXCEPT THE ENTER KEY.

The only way you can cause the enter key to respond is by first physically pointing and clicking your mouse in the text field first and then hitting enter.

Here's the code:
username_txt.focusEnabled = true;
Selection.setFocus(username_txt);


TextField.prototype.onKeyDown = function ()
{
     trace( "onKeyDown" );
     if( Key.getCode() == Key.ENTER ){ trace( "ENTER PRESSED" ); } /*doesn't work unless you first pointed and clicked your mouse in the textfield */
}
};

TextField.prototype.onKeyUp = function ()
{
     trace( "onKeyUp" );
      if( Key.getCode() == Key.ENTER ){ trace( "ENTER PRESSED" ); } /*doesn't work unless you first pointed and clicked your mouse in the textfield */
}



Very strange.

Any Ideas?

Simulating A Keystroke In Actionscript (not Accepting Key Input)
I know how to accept keystrokes as input, but i'm having trouble finding out how to do the reverse.

I'm building a promo for a client and they want to kick to Webshots after the promo plays, and to do that you push Ctrl-Shift-S (or something like that) to kick off the screen savers.

Is it possible to have Actionscript *send* keys to the OS rather than just receive keys? Thanks in advance

Also, some background if needed....
Going to use XP's Task Scheduler to kick off the Promo SWF file, probably every 15 minutes or so, and want Webshots random images to be displayed the rest of the time. If the keystrokes are not possible, is it possible for Flash to kick off a program and then exit itself (the .swf) gracefully until it's next scheduled time?

The whole thing *could* be built in flash, but the randomizing of images, not to mention the copyrighted images, well, the client isn't paying *that* much, heh heh.

Anyway, thanks!

Keystroke Control: Toggle Start/top With Spacebar
Greetings all,

This is my first post. Thanks in advance for your help and support.

I am trying to control playback via keystrokes. I have a test movie with three scenes. I am using the left and right arrows to move between scenes and the spacebar to toggle between play and stop.

The left/right arrow functionality seems to be working fine. I have it set up so that pressing the right arrow takes you back to the beginning of the current scene (and stops the movie). Pressing it again takes you to the beginning of the previous scene (and stops the movie). If you are already stopped at the beginning of a scene, the first press of the arow will take you to the beginning of the previous scene. The left arrow works the same way but for the next scene.

I am having a little toube with enabling the spacebar functionality. I need it to start/resume playback if the movie is currently stopped and stop playback if the movie is currently playing. here's the priblem:

If the movie is stopped by using the spacebar, everything works fine. However, if the movie is stopped by using one of the arrows (say you press the right arrow to return to the beginning of the scene, the movie also stops), the fact that the movie is stopped does not register and hence it takes two presss of the spacebar to resume playback. It's as if one press is necessary to register the stop (even though the movie is already stopped) and then the second one to resume playback.

Is this making sense? I am happy to post a copy of the test *.swf if that would be helpful.

My apporach was to define a variable and determine the behavior of the spacebar based on whether the variable was true or false. I then set the value to treu of value as necessary. but that doesn;t seem to work. Would it be better to simply check if the movie is currently playing and base my logic on that? And, if so, how do I check the playback staus of the movie?

Again, thanks in advance for the help.
TN

Keystroke Shortcut For Resizing Brush Tool?
Hi, is there a keyboard shortcut combination to increase or decrease the brush tool sizes? Like in Photoshop you can press ']' or '['

Function Not Working
I'm using flash 5 to develop.

I am very perplexed...
Here's my code....

============================

AScript, text_box and button on main timeline

function test (txt1, txt2) {
text_box = txt1 + txt2;
}

============================

on Button click.....

on (release) {
test ("Text One", "Text Two");
}

============================

The button works fine when run on local PC, but when uploaded to server, it doesn't work. I have Player 8 when I am browsing on the web

What is wrong?

Function Not Working
I'm having a problem with a function called "Move"...it's not being called unless I place it outside the ParticlePositive1_mc.onRelease function...here's the code(there aren't any script errors)...


Code:
var Times_n:Number = 0;
var Interval_n:Number = setInterval(Move, 1000);
ParticlePositive1_mc.onRelease = function() {
this.stopDrag();
this.onEnterFrame = function() {
if (this.hitTest(HitTest_mc)) {
ParticleBar1_mc._x = this._x;
ParticleBar1_mc._visible = true;
}
else {
ParticleBar1_mc._visible = false;
}
if ((this.hitTest(HitTest_mc)) && (ParticlePositive2_mc.hitTest(HitTest_mc))) {
delete this.onPress;
delete ParticlePositive2_mc.onPress;
if (this._x<ParticlePositive2_mc._x) {
function Move():Void {
trace("function Move is being called");
this._x--;
ParticlePositive2_mc._x++;
Times_n++;
if (Times_n>=1) {
clearInterval(Interval_n);
}
}

[F8] Function Not Working
Hi everyone,

I'm trying to get the following function to work:

function door() {
door_mc.gotoAndPlay("sceneOut");
mcLoader.loadClip("business.swf", myLoader);
door_mc.gotoAndPlay("sceneIn");
}

I then call the function here:

businessBtn_mc.onRelease = function() {
door();
}

It works fine as is but I'm trying to make it work for all the other buttons as well by trying to add a parameter to the function like this:

function door(movieName) {
door_mc.gotoAndPlay("sceneOut");
mcLoader.loadClip(eval(movieName), myLoader);
door_mc.gotoAndPlay("sceneIn");
}


then call the function again with the value added:

businessBtn_mc.onRelease = function() {
door("business.swf");
}

...but it doesn't work.

I've attached the fla files so you can see the full code.

I wonder if someone could take a look and see where I've gone wrong?

Thanks so much.

Function Working Only Once ?
Hi I have this function that scrolls my menu back to it's original place :


Code:
//Tweens
import mx.transitions.Tween;
import mx.transitions.easing.*;

ResetMenu = function() {
ResetScrollBar = new Tween(_root.scroll_bar, "_x", Bounce.easeOut, _level0.scroll_bar_x, 42.5, 1, true);
ResetMenu = new Tween(_root.menu_holder, "_x", Bounce.easeOut, _level0.menu_holder_x, 18, 1, true);
}
I call it from a button and it works but only the first time, if I click a second time on the button (after scrolling my menu) nothing happens :cry:


Code:

on (press) {
ResetMenu ();
}
Can you please help ?

dip

Function Not Working...
I'm having a problem with a function called "Move"...it's not being called unless I place it outside the ParticlePositive1_mc.onRelease function...here's the code(there aren't any script errors)...


Code:
var Times_n:Number = 0;
var Interval_n:Number = setInterval(Move, 1000);
ParticlePositive1_mc.onRelease = function() {
this.stopDrag();
this.onEnterFrame = function() {
if (this.hitTest(HitTest_mc)) {
ParticleBar1_mc._x = this._x;
ParticleBar1_mc._visible = true;
}
else {
ParticleBar1_mc._visible = false;
}
if ((this.hitTest(HitTest_mc)) && (ParticlePositive2_mc.hitTest(HitTest_mc))) {
delete this.onPress;
delete ParticlePositive2_mc.onPress;
if (this._x<ParticlePositive2_mc._x) {
function Move():Void {
trace("function Move is being called");
this._x--;
ParticlePositive2_mc._x++;
Times_n++;
if (Times_n>=1) {
clearInterval(Interval_n);
}
}

The Following Function Is Not Working...why?
function glowMe(p_mc, p_play, p_stop){
if(p_mc.onRollOver){
p_mc.gotoAndPlay(p_play);
}
else{
if(p_mc.onRollOut){
p_mc.gotoAndStop(p_stop)
}
}
}
glowMe(blue_mc, 2, 1);

Function Not Working
on my main timeline on the frame

ActionScript Code:
stop();
csub._alpha = 0;
bsub._alpha = 0;
function FadeIn(c) {
    this.onEnterFrame = function() {
    if (c._alpha < 100) {
        c._alpha+= 5;
    }
    }
}

function FadeOut(d) {
    this.onEnterFrame = function() {
    if (d._alpha > 0) {
        d._alpha-= 5;
    }
    }
}

then on my button I have

ActionScript Code:
on(release) {
    FadeIn(csub);
}

This all works great. Although if I do:

ActionScript Code:
on(release) {
    FadeIn(csub);
    FadeOut(bsub);
}

The Fade out works great too. Although the FadeIn stops working. Anyone know what I'm missing here?

Sandman9

Function Not Working Right.
I have a problem with my function, it works alright but for some reason it only works once at a time..

let me explain, i have a bullet and an object, when the bullet hits the object both mc's get unloaded but after they unload and effect and an item will appear in its place... but as soon as you hit another object with a bullet the first lot of item/effect dissappear? why is this?
here is my code..

I have an MC labeled functions and in its actions are these functions...


ActionScript Code:
onClipEvent(enterFrame){
    dropchance = random(2);
}
onClipEvent(load){
    unloadframe = 51;
        depth = 0;
    itemdepth = 99998;
    function attachItem(a, b) {
        if (dropchance == 0){
            namea = "itemdrop" + itemdepth;
            _root.attachMovie("itemdrop", namea, itemdepth, {_x:a, _y:b});
            _root[namea].gotoAndStop(random(3)+1);
        } else {
            trace('No Drop');
        }
    }
    function effectExplode(a, b) {
        nameb = "explode" + depth;
        _root.attachMovie("explode", nameb, depth,  {_x:a, _y:b});
        _root[nameb].onEnterFrame = function () {
            if (this._currentframe == unloadframe) {
                this.unloadMovie();
            }
        }
    }
}

and the hittest is as follows:


ActionScript Code:
if (this.hitTest(_root.theobject)){
                _root.theobject.unloadMovie();
                this.unloadMovie();
        _root.functions.effectExplode(this._x, this._y);
        _root.functions.attachItem(this._x, this._y);
}

so why does this only work once and then seem to remove once another hittest occurs? i dont get it..


any help is welcomed.
thanks.

Function Not Working
i'm trying to call a function from inside nested functions and can't get it to work. i tried directing the scope of the call to the function every way i knew how (_global, _parent, _root) and even tried declaring the function in a different way like

var myFunction = new function() { ...... }

below is the appropriate part of my code. bospv2_start() is the function that won't work. what am i doing wrong? i can call the function in other places just fine.










Attach Code

function flushLSO() {
agent_so.data.bospv2_agentName = dataAgentName;
agent_so.data.bospv2_agentEmail = dataAgentEmail;
agent_so.data.bospv2_agentGroup = dataAgentGroup;
agent_so.flush();
var twLSOundefinedOut:Tween = new Tween(LSOundefined, "_alpha", Strong.easeOut, 100, 0, 3, false);
twLSOundefined.onMotionFinished = function() {
LSOundefined.removeMovieClip();
bospv2_start();
};
}

function bospv2_start() {

Function Not Working
I'm making a little quiz for school. And a function I used just the other day isn't working. Why not.

ActionScript Code:
stop();countries(c1,"Morocco",p1);//more African countries.function countries(box,count,countx){     if(box==count){          countx=1;     }else{      countx=0;}

That's all on frame 1.
On frame one there's also an imput text box with the instance name c1, and a next frame button.
On the next frame I have a dynamic text box witht he instance name total.
frame 2 has the AS

ActionScript Code:
//imagine p1+p2+p3+p4toatal.text=p1}

Why dosen't this work?

The Following Function Is Not Working...why?
function glowMe(p_mc, p_play, p_stop){
if(p_mc.onRollOver){
p_mc.gotoAndPlay(p_play);
}
else{
if(p_mc.onRollOut){
p_mc.gotoAndStop(p_stop)
}
}
}
glowMe(blue_mc, 2, 1);

Function Not Working
I don't get why my menu dropdown function is not working. It works when I put the instance name of the dropdown menu in, but when I try to use eval for the instance name it won't work. This code is giving me the problem.


ActionScript Code:
menuopen(eval("d"+q), -219, 0);


This is most of my AS


ActionScript Code:
/////////////////////////Button Functions/////////////////////////function menuclose(item, beg, end) {    var butclose:Tween  = new  Tween(item, "_y", Strong.easeOut, beg, end, .3, true);    var maskclose:Tween  = new  Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, -225, .3, true);    clearInterval(dropup1);};function menuopen(item, beg, end) {    var butopen:Tween  = new  Tween(item, "_y", Strong.easeOut, beg, end, .3, true);    var maskopen:Tween  = new  Tween(eval(item+"mask"), "_y", Strong.easeOut, beg, end, .3, true);};function butup(item) {    if(dropup1 != null){        clearInterval(dropup1);    }    var butin:Tween  = new  Tween(item, "_alpha", Strong.easeOut, 0, 12, .5, true);};function butdown(item) {    var butin:Tween  = new  Tween(item, "_alpha", Strong.easeOut, 12, 0, .5, true);};///////////////////////Button Actions/////////////////////////Buttons on the main nav barvar q:Number = 1;b1.onEnterFrame = function(){        eval("b"+q).onRollOver = function() {    butup(this);    menuopen(eval("d"+q), -219, 0);    };    eval("b"+q).onRollOut = function() {    butdown(this);    dropup1 = setInterval(menuclose, 1000, eval("d"+q), 0, -225);    };    eval("b"+q).onReleaseOutside = function() {    butdown(this);    dropup1 = setInterval(menuclose, 1000, eval("d"+q), 0, -225);    };    q++;    if(q == 3){ delete this.onEnterFrame; }}

Function Not Working
Hello good people!

Is this right?

PHP Code:



function something(){   //code}mc.onRelease = function(){   something();} 




or is it like this?


PHP Code:



something = function(){   //code}mc.onRelease = something; 




Thanks!

Not Sure Why Function Not Working
I am using Flash 8 and just learning ActionScript 2.0.

I have a basic call to a function that I am not sure why it is not working.  
3 Questions:
1.) Am I passing the value into the function correctly.
2.) Can I pass a value into a function and not use it.
3.) How come in the code that works, I don't have to call the function by togglePower(),  Instead I call it without the ()?
Here is my code:
NOT WORKING
CODEfunction togglePower(myVar:Number):Void {
    remote_mc.light_mc.play();
}
remote_mc.power_btn.onRelease = togglePower(55);

Copyright © 2005-08 www.BigResource.com, All rights reserved