;

PDA

Click to See Complete Forum and Search --> : action scripting not work for loop play?


ksouth
08-15-2006, 06:00 PM
well, here's the action script i'm trying to get...

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
gotoAndPlay("5");
};
}

*cough*indogo thanks alot...like coffee*cough*

i have kool moves 5.2.3 and i'm trying to get it when you press right, it goes to the "icon"

problem is though, i have a loop play on frame 3 and when i press right, it goes straight to frame 1. I think it's cuz of the loop play.

if any 1 has any advise plz post

XareoX
08-16-2006, 01:15 AM
Ok so you press left button and it doesnt loop try this post that code in and then go to frame 5 then go to the actionscript/sounds window then press the + button then click the button that says ''go to frame'' then change those drop down menus so it says ''keyframe 1'' and ''play'' that should make it loop.

ksouth
08-17-2006, 02:19 PM
no, i already know how to loop

i want an action script to go to key frame 4. This won't work though

I also have key frames 1-3 and three goes to key frame 1 on loop

blanius
08-17-2006, 02:26 PM
well, here's the action script i'm trying to get...

this.onEnterFrame = function(){
if(Key.isDown(Key.RIGHT)){
gotoAndPlay("5");
};
}

You're not trying to use this in the main timeline are you? Because the onEnterFrame will only work on a child movie within the main timeline. Use a dummy movie clip with your repeated actions like this in it. or use setInterval to have the function keep checking.

w.brants
08-17-2006, 03:38 PM
If the frame you go to is the last one, try gotoAndStop instead of gotoAndPlay. You might have forgotten to set a stop action at the end of your movie.

indogo
08-17-2006, 06:46 PM
Hi there.....sorry didn't get back sooner..

Examine the attached file...left arrow goes to frame 3...right to frame 5...I presume you are needing multiple actions..

note...the keyframes have been named (as mentioned before)(rightclick/rename in movie explorer or timeline)..jumping is unpredictable otherwise and causes the effect you describe.

I had to add a dummy frame at the end which was needed for stability (aka stopping in the first keyframe is not reliable)...the flash player does have the odd quirk..

The code does work in the main timeline (even though it shouldn't) but I was going to suggest creating a movieclip for handling your keyboard actions (in a similar way that buttons are types of movieclips)...so actions would become _root.gotoAndPlay("three"); and so on...note the movieclip would need to be present in all main timeline frames.

Ok hope you get there

mike

w.brants
08-18-2006, 01:37 AM
Instead of onEnterFrame you could also use a key listener.
That probably requires less cpu load because it is only triggered when a key is pressed and doesn't have to perform actionscript code each enterFrame event.

indogo
08-18-2006, 07:50 AM
Instead of onEnterFrame you could also use a key listener.
That probably requires less cpu load because it is only triggered when a key is pressed and doesn't have to perform actionscript code each enterFrame event.

Yes that sounds better...the method I used was the only one I could find when I was looking some time ago....macromedia incorporate key detection into the button action so I needed the equivelent method for koolmoves.

I remember trying a key listener without success...do you have an example of working syntax?

regards

mike

w.brants
08-18-2006, 08:09 AM
listener = new Object();

listener.onKeyDown = function () {

var keycode = Key.getCode();

if (keycode == Key.LEFT){

_root.txt1.text = "You pressed LEFT";

} else if (keycode == Key.RIGHT){

_root.txt1.text = "You pressed RIGHT";

}

}

Key.addListener(listener);

indogo
08-18-2006, 08:43 AM
Thankyou for that...I'm off to play with it myself :) (perhaps I should rephrase that!)

regards

mike

edit...well I'm pleased to report that it worked a treat...perfect response which is independant of frame rate (does a small celebration dance) definately a better method...ow where did ksands go :)
note...I used it in the main timeline.