Moving And Stopping
My friend needs action script to make a movie clip not be able to move on top of another mc.
He uses this code for the moving clip:
onClipEvent(load){
x = this._x;
y = this._y;
speed = 5;
}
onClipEvent(enterFrame){
if (Key.isDown(Key.LEFT)) {
x -= speed;
}
if (Key.isDown(Key.RIGHT)) {
x += speed;
}
if (Key.isDown(Key.UP)) {
y -= speed;
}
if (Key.isDown(Key.DOWN)) {
y += speed;
}
this._x = x;
this._y = y;
}
and he wnats it so when it tries to go over "clip1" (instance name) it doesn't.
I can make an event if it moves on top of "clip1," but not stop moving over it. Can anyone help?
FlashKit > Flash Help > Flash ActionScript
Posted on: 09-09-2006, 09:08 PM
View Complete Forum Thread with Replies
Sponsored Links:
Moving Text Then Stopping....
I just recently went over the Flash 5 lessons but they really don't help me with what I want to do. I wanted to have text come from the left side and each letter move to the right, stop until the rest of the text finishes then repeat again. Can someone help me out and point me in the right direction?
View Replies !
View Related
[CS3/F8]AS2 Stopping A Tween From Moving.
Hi all, I have a yellow square that i am tweening along the x axis using the .tween class, however this animation starts as soon as the frame is loaded, i have tried several ways to make it start at a stationary position yet to no avail.
The play control works so far and it does loop the animation like i want it to yet i just want the square to start at a stop.
I also need a working stop button as i can only make it pause curently.
I have uploaded a working .zip file with the examples save in CS3 and F8 formats any help is appreciated greatly.
Regards,
Rich.
View Replies !
View Related
Moving And Stopping Objects Via AS
Howdy ... I have a problem ...
I want to move an Object via AS in this way:
Start: x = 0 moving to x = 300 waiting there for 4 seconds moving from x = 300 then to x = 500 ...
how can i do this in AS rather then motion tween ... any help much appreciated
cheers
ChromeD
View Replies !
View Related
Random Moving And Stopping...
I've instituted the code for random movement from this tutorial - http://www.kirupa.com/developer/actionscript/random.htm
Does any know of away that I can modify this so when the user rolls over one of the movieclips it will stop moving and once the user rolls offs it will resume random movement.
Thanks in advance.
View Replies !
View Related
[CS3/F8]AS2 Stopping A Tween From Moving.
Hi all, I have a yellow square that i am tweening along the x axis using the .tween class, however this animation starts as soon as the frame is loaded, i have tried several ways to make it start at a stationary position yet to no avail.
The play control works so far and it does loop the animation like i want it to yet i just want the square to start at a stop.
I also need a working stop button as i can only make it pause curently.
I have uploaded a working .zip file with the examples save in CS3 and F8 formats any help is appreciated greatly.
Regards,
Rich.
View Replies !
View Related
Stopping A Character From Moving Through Object
Hi,
Newbie here...and I'm using flash mx 2004.
I have a movieclip (character) with an instance named "car", and a png turned movieclip with instance name "toxic". The car keeps going through toxic and I want to use toxic as a barrier.
I understand that I have to use collision detection so I tested that by using
if(car.hitTest(toxic)){
trace('Collision detected!');
}
So, that worked. But in place of trace('Collision detected!');
What actionscripting do I need to add so toxic becomes solid and can not be walked through? Thanks.
View Replies !
View Related
Stopping My Symbol From Moving Out Of The Border
Hello,
im feeling ill from trying to solve this so ive come here in search of some much needed guidance.
i am doing a uni project and have to make a game that is half frogger and half pacman. Im nearly done but cant work out how to stop a symbol that i move with the arrow keys to stop when he gets to the borders of the screen.
This is the code to make him move:
onClipEvent (keyDown) {
if (Key.isDown(key.RIGHT)) {
this.gotoAndPlay("roll");
this._x = this._x+20;
}
if (Key.isDown(key.UP)) {
this.gotoAndPlay("roll");
this._y -= 15;
}
if (Key.isDown(key.DOWN)) {
this.gotoAndPlay("roll");
this._y += 15;
}
if (Key.isDown(key.LEFT)) {
this.gotoAndPlay("roll");
this._x -= 10;
}
}
This code is placed inside the instance of my frog (well a hedgehog but nevermind).
What i had thought of is to put an if statement saying it can only move if it was within the x and y coordinates. I used this:
if(this._x > 10 && this._x < 600 && this._y > 10 && this._y < 400){
above the other code. This made it so when the frog moved out of these coodinates he couldnt move anymore. it disabled all controls. I then tried an else{
this._x = this._x + 1 so that it would move the symbol back to within range of the 1st if statement. But im afraid i had no joy
Im sure there is some help on these forums and im sorry if i am repeating apost but i didnt know how to search for this.
Well
Thanks
fonze
View Replies !
View Related
Stopping Items From Moving Off Screen, Possible?
Hello again people, ive got my paddles to move at last. Now im trying to stop them from going off the stage at the top and the bottom. If you keep the key presses up or down it will continue to move into I guess indefinatly. Ive added an if statement after my movement code but it dont seem to work, Anyone know why this peice of code is not working thanks.
Code:
private function keyPressedDown(event:KeyboardEvent):void {
var key:uint = event.keyCode;
var step:uint = 5
switch (key) {
case Keyboard.UP :
myleftbat.y -= step;
if (myleftbat.y > stage.stageHeight) {
myleftbat.y < (stage.stageHeight);
}
break;
case Keyboard.DOWN :
myleftbat.y += step;
if (myleftbat.y < stage.stageHeight) {
myleftbat.y == (stage.stageHeight);
}
break;
case Keyboard.NUMPAD_8:
myrightbat.y -= step;
if (myleftbat.y > stage.stageHeight) {
myleftbat.y < (stage.stageHeight);
}
break;
case Keyboard.NUMPAD_2:
myrightbat.y += step;
if (myleftbat.y < stage.stageHeight) {
myleftbat.y == (stage.stageHeight);
}
break;
}
View Replies !
View Related
Actionscript Moving Left But Not Stopping
This is probably an obvious answer but... I currently have this code:
onClipEvent(enterFrame) {
this._x-=10;
if (this._x > 35){
this._x=stop();
}
}
The movie clip currently moves to the left as it should but I want it to stop when it gets to 35 on the x coordinates. Is there an easier way to do this?
View Replies !
View Related
Moving And Stopping A Movie Clip
hi everyone! i'm new to this forum but have been using flash for a while. in the past i've done everything with motion tweens but now that i'm trying to use actionscript i've run into a probelm.
i want to move a movie clip on the stage. this is the code that i am using:
onClipEvent(enterFrame){
_x = _x + 10;
}
after it moves to this position i want it to stop - at the moment it just keeps on moving. despite my best attempts i'm having no joy. i know there is probably a ridiculously simple solution but i'm stumped.
any help would be much apprecitated
View Replies !
View Related
Moving And Stopping It With Mouse Movements
Hello,
I am trying to create time-line that moves in the direction of the mouse movement but then will stop whenever I hover over an area. In other words, I have links on the time-line that I want to be able to stop at by hovering over the button. The code listed below is what I am using for the x and y background movements:
(What am I missing to get the background to stop when I hover over a button?)
this.onMouseMove = function() {
constrainedMove(bg2_mc, 4, 1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
var mousePercent:Number = _xmouse/Stage.width;
var mSpeed:Number;
if (dir == 1) {
mSpeed = 1-mousePercent;
} else {
mSpeed = mousePercent;
}
target.destX = Math.round(-((target._width-Stage.width)*mSpeed));
target.onEnterFrame = function() {
if (target._x == target.destX) {
delete target.onEnterFrame;
} else {
target._x += Math.ceil((target.destX-target._x)*(speed/300));
}
};
}
View Replies !
View Related
Stopping A Moving Object With ActionScript
Greetings,
I have a movie clip I am moving from the left side of the stage to the right using AS, however I can't seem to get the clip to scale larger or stop.
I was able to succesfully get the clip to move, so I am wonderging if anyone can help me stop the MC and gradually make the clip larger.
Here is the AS as it stands now -
onClipEvent (load) {
_x=24;
_y=111.7;
_xscale=_yscale=0;
_alpha = 10;
}
onClipEvent (enterFrame) {
_x=_x+3;
_xscale=_yscale=+100
_xscale=_yscale=+100;
_alpha = _alpha+2;
}
onClipEvent (data) {
stop();
}
All help is greatly appreciated.
Best,
CG
View Replies !
View Related
Stopping Sound After Moving To Next Scene In Flash 5
I have a piece of music that I'd like to loop in a stopped frame, but I also want the music to stop when I use a button to move to the next scene. It's a single frame that I've added it into, but the music should stop entirely so I can play different sounds in other scenes. In other words, I can't mute everything when I move to a new scene. I just want to stop this one piece of music.
Should I just add a stop music line to each button? If so, what's the code for that?
View Replies !
View Related
Moving A M/c Using KeyDown Then Stopping At A Specific Point
Hi - I'm moving a m/c left and right on a screen using the onClipEvent (keyDown) command successfully. But here is a simply, but maddening thing that I need to fix. How do you stop the clip from moving when you reach a specified limit on the far left or right of the screen? Say _x = 35 and _x = 500 I want the clip to move in between these two numbers. How do I do it??
ta
frank
View Replies !
View Related
Dragging Objects (stopping Mouse From Moving)
Hello,
I am very stuck. I tried looking over my old Director scripts for help but I cant make anything of them to help them with Actionscript.
Basically what i want to do is, when i am dragging a a movie clip such as 'lungs_mc' i dont want the user to be able to drag it outside of a box called 'dragArea_mc' which has co ords of: w:560.0, h:538, x: 235, y:57.0.
Basically when the user drags lungs_mc to the edge of box it stops the user from moving the object outside this box, but they are still able ot move it inside of the box.
Any Suggestions??
If you dont know how to retrain 'lungs_mc' within 'dragArea_mc' then even retraining them within x and y co ords would be great and i will just use < and > for those.
Also 'lungs_mc' is on the _root and so is 'dragArea_mc'. They both must stay on the root to make the whole movie work.
It would be greatly appreciated if anyone could help as it would solve a massive problem for me
thanks a lot :-)
Lee
Edited: 12/15/2006 at 05:22:58 AM by leej_w
View Replies !
View Related
Collision Detect: Stopping A Movie From Moving On The Stage
Hey everyone,
I have multiple stationary movies on the stage (they dont move around on the stage) and I have a movie that is moved by the arrow keys (on the keyboard). How can I make it so that when the movable movie comes in contact with one of those statinary movies, they don't overlap each other?
(e.g. When Pac-Man hits a wall, he stops moving until the user gives another direction. Also, attempting to move in the blocked direction repeatedly doesn't allow you to pass through)
Thanks!!!
- OneMrBean
View Replies !
View Related
Stopping A Movie Clip From Moving At Specific X Position
I have created a simple movie where I am moving a movie clip using buttons with action script. I have everything moving the way I want it to but I am looking for some code to set a limit to how far it will move in order for it to stop within the masked area.
Right now my code looks like this...
moveLeft.onRollOver = function() {
rocket.onEnterFrame = function() {
this._x -= 8;
};
};
moveLeft.onRollOut = function() {
delete rocket.onEnterFrame;
};
moveRight.onRollOver = function() {
rocket.onEnterFrame = function() {
this._x += 8;
};
};
moveRight.onRollOut = function() {
delete rocket.onEnterFrame;
};
Any help would be much appreciated
View Replies !
View Related
Change Direction Of Movie Clip/stopping Moving Clip
Hello everyone,
I cannot wrap my brain around this anymore. It's been sometime since I have done much actionscript but here it is:
Functionality:
I have the movie clip moving from left to right and once it reaches a certain point, it changes direction and goes back, infinitely.
I have a hitTest to check weather the mouse is over the target movie clip, if it is, the movement stops.
Problem1 - Movement:
When I mouseover the target movie clip it stops (hitTest=true) but the movement does not resume when the hitTest is false.
Here's the code:
var xchange=10;
holder_mc.onEnterFrame = function() {
//trace("x_pos: "+this._x)
//trace("xchange: "+xchange)
this._x += xchange;
if (this.hitTest(_xmouse, _ymouse, true)) {
xchange=0;
this._x += xchange;
}
else{
if(this._x > 0){
xchange=10;
xchange*= -1;
}
else if(this._x < -645){
xchange *= -1;
}
}
}//--------------------------------------
Problem 2 - CPU Resources
Also I have code on the individual movie clips within the target movie clip, they simply play frames forward and backward to enlarge a thumbnail. After a while the computer starts hating life and chugs. I know it is from the hitTest checking on each enterFrame and it eats up the resources. Is there a way to do this without the chug?
Here is the code that expands the thumbnails within the target movie clip:
stop();
this.onEnterFrame = function() {
if (rewind == true) {
prevFrame();
}
};
this.onRollOver = function() {
this.swapDepths(this.getNextHighestDepth());
rewind = false;
play();
};
this.onRollOut = function() {
rewind = true;
};
//----------------------
If someone could give me any insight into this problem I would greatly appreciate it.
Thanks guys,
I hope I've been clear.
View Replies !
View Related
Moving Vertical Bar Which Holds Moving Thumbnail Images When Mouse Is Over
Hi!
im not completely new to Flash MX - have utilised all basic animation tween/morphing /buttons
and very simple action script- movie controls - stop , back ,forward etc
however i need a moving bar feature, e.g. a moving news reel or a vertical bar which holds a number of images i.e.10 and
when the mouse is over - i want it to move downwards and when is not over the feature i want it to stop moving
(or even instaed of the feature to automatically scroll images i could also use a button to press to move through the images)
then: the thumbnail images from the moving feature i need to be selectable which then produces a larger version of the image on
another section of the page.
i dont no if i put this thread in the right forum!
if any one knows of any tutorials or has any suggestions to help implement this feature
i would appreaciate any help!
- dont really know where to start with it!
thanks
(i have looked at the flash kit tutorials but havent found what im looking for
dont even no if this is more of an animation or action script questions)
View Replies !
View Related
Slowly Moving Smoothly - Moving Photos And Pixel Smoothing
So, I'm slowly....very slowly moving a small thumbnail across my stage. The problem is that when the pic moves over a pixel it looks choppy, I want it to look smooth. The border of it looks especially choppy, it's distracting from the site.
Is there a pixel-smoothing option for the stage? or some equivalent?
Does my question even make sense?
Please help.
Thanks
View Replies !
View Related
Moving Running Forward But Elements Moving Off Stage
I'm positive I've done it by the book. All symbols on the stage - one by one dragged them off the stage creating timelines - about 6 layers. Play the movie and all the elements start on the stage and move off. Just the way I wanted it but in reverse. Simple vertical and horizontal motions. My mistake must have been in the beginning somewhere - but where ?
View Replies !
View Related
Moving Menu And Not (yet) Moving Arrows
Hi,
The title I guess say it all, huh?
But just to be sure.
I have a main menu wich goes right or left. Depends what categorie you choose. When it goes left I have to load a arrow movie wich goes left and for right has to load a moviw arrow which goes right (and not wrong). Thats means that there are two movies: arow left movie and arrow right movie. And both have to react at the moving menu, which were to load and play.
So first level would be the menu which ships from right to left.
Second level (under the menu) one of the arrow movie has to load depending which direction the movie goes.
(now Im confused. What was there I wanted??? A, right!)
I figured out that maybe its more confortable to load it from the library but also if it can be loaded from external files I dont mind. (I did the container thing before so I understand it a bit.
The arrow movies are movies played in the background, as the menu remains on top all the time.
The script for animating the menu is:
onClipEvent (load) {
_root.newposition = "null";
}
onClipEvent (enterFrame) {
current = getProperty(_root.drop, _x);
if (_root.newposition<current) {
distance = current-_root.newposition;
setProperty("_root.drop", _x, current-(distance*.1));
}
if (_root.newposition>current) {
distance = _root.newposition-current;
setProperty("_root.drop", _x, current+(distance*.1));
}
}
View Replies !
View Related
Moving Mouse Image Moving
hi everybody. i'm using flash professional 8 and i want to create something like this: http://www.kenzoparfums.com/FR/home/home_FR.html when moving the mouse on the stage the hole stage moves. how do i do that? thank you
View Replies !
View Related
Moving Objects: Moving Keyframes?
Can I move multiple layers on a timeline, so that they will all move. Basically I just want to move the location of the multiple layers.
Whenever I do this, it seems to move only some of them and thus the whole animation is messed, different starting points and ending points...a big mess.. It makes me want to cry.
Seems like there is an easy answer or I might just be the biggest chump on the planet.
Case
View Replies !
View Related
Moving Objects: Moving Keyframes?
Can I move multiple layers on a timeline, so that they will all move. Basically I just want to move the location of the multiple layers.
Whenever I do this, it seems to move only some of them and thus the whole animation is messed, different starting points and ending points...a big mess.. It makes me want to cry.
Seems like there is an easy answer or I might just be the biggest chump on the planet.
Case
View Replies !
View Related
Moving The Stage After Resizing - Or Moving All Objects On The Stage? Heeeelp
Hello! I'm in dire need of help!
I've been forced to resize the stage of my movie but as the stage is expanded to the right and down everything ends up in the wrong place. So I wonder:
Is there any way to move the stage rather than the contents thereon?
or
is there a way to move all the content on all layers and even all scenes simultaneously?
or
is there a way to expand the stage equeally on all sides rather than just right and down?
THANKS ALOT TO WHOEVER COULD HELP ME!
Freddy D, Stockholm, Sweden
View Replies !
View Related
Stopping A Mc From Another One...
Whats going wrong with this script?
I try to control a mc from another one:
-----------------------------------------
1. MCName is my variable for the clip!
2. Both mc`s are in a mainmovie!
-----------------------------------------
on (release) {
MyClip = "_root"+"."+_root.MCName;
MyClip.gotoAndStop(2); -> I think here is my mistake!
}
------------------------------------------
Thanks!!
Mikalux
View Replies !
View Related
Stopping A MC
Hi All,
I'm struggling with this one and i'm sure that it's an easy one to solve.
After downloading a menu system from flashkit i've amended the code and design slightly to give me the look that I want. Each button is allocated to a wedge on the menu system, which when clicked opens and when hovered off closes.
you can find the menu at www.partyboy.org/flashstuff/
Each button has the code:
on (rollOver) {
revolver_mc.carrRotate(number);
}
on (rollOut) {
revolver_mc.cartRetract();
}
on (release) {
revolver_mc.cartOpen();
}
Where the number is the relevant wedge to rotate to.
2 Questions for ya:
1. How can I force the movie to finish even if say, i've hovered over another button. eg. I hover over the "journal" button, I want that movie to finish playing even if I move the mouse over the "link" button before it's finished?
2. I have a text effect which I want to apply to my buttons. I want this effect to play when the page loads up and stop. How do I apply it without affecting the action of the buttons i've already added?
Anyones helps is much appreciated!
View Replies !
View Related
MP3 Is Not Stopping
I am only a novice so don't laugh.
I am creating a Flash movie and i want to have an MP3 soundtrack playing in the background. When i test the scene, the animation finishes and the music keeps on playing, then when i want to test the scene again, i have to wait for the original music to finish otherwise i get an overlap of music with multiple amounts of the same track playing at once.
All i want to do is to have the music stop when the animation is finished.
Thanks for your help
My movie so far can be seen here: http://freespace.virgin.net/pete.wills1/Test/_notes/The Iron Stick Tornament Round 1.swf
View Replies !
View Related
Why Is It Stopping?
Here is the code:...
onClipEvent(enterFrame)
{
_root.loadMovie(_root.path[_root.i]);
trace(_root.i);
}
this is hooked into one of the MC's and it works, The mc loads the picture and I can see it and everything, problem is, it seems the loadMovie method stops the running of the mc. cause when the trace window shows up I see the number for the frame where it loaded the image from loadMovie, but then there is no repeating in the trace window. Now if I comment out the loadMovie method. the trace window pops up and I see i flip through like normal.
Why is this?
Cedric
View Replies !
View Related
Stopping A Swf
I am really new at this flashMX...been playing with it for a couple days...my question is:
I have 2 buttons START and STOP on a bitmap picture...when I press the START button the movie "norma_girl_Scene 1.swf" plays...how do I make it stop and exit with the second STOP button...the script for the START button is..........
on (release) {
loadMovieNum("norma_girl_Scene 1.swf", 1);
play}
View Replies !
View Related
Stopping
ok I got a bunch of crap goin on in my movie it play till about frame 355 then it supposed to go to the main page. It keeps loopimng and goin back to the beginning and only flashes the main page quickly.
I;ve tried just the StopO; command but it still loops back to the beginning. How do i make it sit and the main page?
View Replies !
View Related
Stopping
I have an amination already created and i want it to stop repeating itsself. How o i go about doing this?>
Also i would like to post this animation on my website. How can i display this on my site.
View Replies !
View Related
Stopping _x And _y
Code:
onClipEvent (load) {
_x = Math.round(_x/5)*5;
_y = Math.round(_y/5)*5;
dx = _x;
dy = _y;
}
onClipEvent (enterFrame) {
if (Key.isDown(1)) {
// Mouse click
dx = Math.round(_root._xmouse/5)*5;
// Round off
dy = Math.round(_root._ymouse/5)*5;
// to nearest 5
}
if (_x != dx) {
_x += dx>_x ? 5 : -5;
// Add 5 or -5 depending on dx>_x
}
if (_y != dy) {
_y += dy>_y ? 5 : -5;
// same as before
}
if (_root.follow, hitTest(_root.line)) {
this.stop();
}
}
see where it says this.stop(); ? well the _x and _y do not stop they keep on going.. i've tried _root stop(); everything..
i want to stop the script from continuing..if it doesn't then the mc will just keep going and going..
please help!
View Replies !
View Related
Stopping
Hi All,
I'm just learning AS so if this is a really dumb question ... sorry.
I have a remote control with 6 buttons ... screen changes for each button press and displays new info on a TV screen.
Button 6 - which will play frame 7 (code below) will play an embedded wav file also.
MY PROBLEM IS THIS ... I cant work out the code, how to stop the audio when another button is pressed eg button 4 or 5.
Please help ... deadline is in 6 hours and I'm really stuck__________________________________________________ _____
on (press) {
tellTarget ("led") {
gotoAndPlay(2);
}
tellTarget ("_root.tv.channels") {
gotoAndStop(7);
}
if (_root.tv.boxen.boxen_anaus == 0) {
tellTarget ("_root.tv.boxen") {
prevFrame();
}
}
}
on (release, releaseOutside) {
tellTarget ("led") {
gotoAndPlay(1);
}
}
__________________________________________________ ___
View Replies !
View Related
Stopping It
Alright guys I need a little help here. Me and a buddy are making a flash intro in Flash 8 Professional. So we have a star coming across the background from the left hand side and using the "explode" effect we have it break apart or explode into peices as music is playing in the background. We have our video done right?...or so we thought. We only want to video to play once..but it continues to loop over and over again. So how do we stop it from looping?
Is there a setting to do it?
Any help is much appreciated. Thanks!
View Replies !
View Related
Stopping An MP3
Hi so iv created 2 scenes which are connected by a button which iv managed to code ok but now my problem is when I use the button the next scene appears but the mp3 from the previous scene keeps playing. Is there a code I can put into the actions of the button to stop the mp3?
View Replies !
View Related
Stopping An MC?
A vairable is set that is the frame that I need an MC to stop on.
How can I make it so that the MC keeps playing through and when the variable gets set, it plays through the animation and just stops on that frame. So if the stop frame is 5 and when the var is generated the mC is on frame 6, the MC wont just jump to frame 5, it will play through 6-30 then 1-4 and stop on 5...
Thanks
View Replies !
View Related
[F8] Stopping Xml
Hello everyone was wondering if anyone could help me. I have built a map that pull all the data off an xml sheet. Anyway i need to breakdown the map by catogories so have started building other xml sheets. (client choice) How do i get flash to stop loading one and start loading another xml sheet. Is this even possiable. Thanks in advance
View Replies !
View Related
Stopping Flv
How do you stop an flv on a cue point? How do you load a movie clip on a different cuepoint?
I just want a progressive flv to stop/pause at the end of the clip instead of going back to the beginning. I also want to load a sound clip in the middle of the video on a cue.
View Replies !
View Related
Stopping Mc - Still Not There
on actions layer, frame 1 inside my movie clip I have:
counter
on the last frame of an animation layer inside the same mc I have:
if (counter < 4){
counter += 1;
gotoAndPlay("frmStart");
}
(and) it is still not stopping as desired....
please- any advice would be helpful
View Replies !
View Related
|