How to stop a movie clip moving

I'm not newbie to flash but I am newbie to coding using
actionscript!!!
I am trying to create a button that moves a movie clip
("content1") diagonally across the screen but once the movie clip
reaches a certain x co-ordinate I want it to stop and then when I
click another button I would like it to return to it's starting
position. At the moment the movie clip moves if I click one of the
buttons but as soon as I click another one it stops which it
shouldn't it should go back in the other direction. The other
problem is that once I've clicked a button I cant seem to get it to
stop moving once it reaches a certain _x position it just keeps on
moving off the stage.
Below is the script I have so far not including any
conditions to check if "content1" has reached it _x position
Could anyone help please!!!!
//on Right movie clip containing the button
onClipEvent (enterFrame) {
_root.content1._x += speedX;
_root.content1._y -= speedY;
//on Right button inside movie clip
on (press) {
speedX = 5.5;
speedY = 1.33;
//on Left movie clip containing the button
onClipEvent (enterFrame) {
_root.content1._x += speedX;
_root.content1._y -= speedY;
//on Left button inside movie clip
on (press) {
speedX = 5.5;
speedY = 1.33;

Many thanks ClBeech!!!
I've tried the code you suggested but it doesn't seem to work
:0(
I'm working on a Mac using Flash Pro 8 which only has the
option to publish as 'actionscript 1.0 or 2.0' is the script you
supplied an actionscript 3.0?
Below is the script with the amendments, I've changed my
button instance names to match the script you supplied (left_btn /
right_btn)
stop();
import mx.transitions.Tween;
import mx.transitions.easing.Strong;
var rposX = 369;
//the ending x of the right position
var rposY = 84;
//the ending y of the right position
var lposX = 116;
//the ending x of the left position
var lposY = 154;
//the ending y of the left position
right_btn.onPress = function() {
new Tween(content1, '_x', Strong.easeOut, content1._x,
rposX, time, false);
new Tween(content1, '_y', Strong.easeOut, content1._y,
rposY, time, false);
left_btn.onPress = function() {
new Tween(content1, '_x', Strong.easeOut, content1._x,
lposX, time, false);
new Tween(content1, '_y', Strong.easeOut, content1._y,
lposY, time, false);

Similar Messages

  • How to stop a movie clip that is loaded dynamically

    Hello Flash Forum,
    I am using the loadmovie method to load a swf file into a
    movie clip "container"
    Code snippet:
    var mc:MovieClip = this.createEmptyMovieClip("mc",1);
    mc.loadMovie('bbc_module1.1.swf','bbc_audio',container.getNextHighestDepth(),
    {_x:300.8, _y:240});
    mc._lockroot = true;
    The movie clip I load does not have a stop action in frame 1,
    but comes up playing (audio and images). I am not using video. It
    is a series of still images synced to the audio.
    I would like to be able to load the movie clip, stop it from
    playing, and by clicking buttons, get it to play, pause, etc like
    the buttons and skin on the FLVPlayer.
    Any tips on how to do this?
    Thanks,
    eholz1

    Many thanks ClBeech!!!
    I've tried the code you suggested but it doesn't seem to work
    :0(
    I'm working on a Mac using Flash Pro 8 which only has the
    option to publish as 'actionscript 1.0 or 2.0' is the script you
    supplied an actionscript 3.0?
    Below is the script with the amendments, I've changed my
    button instance names to match the script you supplied (left_btn /
    right_btn)
    stop();
    import mx.transitions.Tween;
    import mx.transitions.easing.Strong;
    var rposX = 369;
    //the ending x of the right position
    var rposY = 84;
    //the ending y of the right position
    var lposX = 116;
    //the ending x of the left position
    var lposY = 154;
    //the ending y of the left position
    right_btn.onPress = function() {
    new Tween(content1, '_x', Strong.easeOut, content1._x,
    rposX, time, false);
    new Tween(content1, '_y', Strong.easeOut, content1._y,
    rposY, time, false);
    left_btn.onPress = function() {
    new Tween(content1, '_x', Strong.easeOut, content1._x,
    lposX, time, false);
    new Tween(content1, '_y', Strong.easeOut, content1._y,
    lposY, time, false);

  • I feel Dumb - How to stop a movie clip

    Hello folks..never posted here before, so, please be gentle..
    I have used Flash CS3 for a while, and just upgraded to
    CS4...This is where i am either missing something, or just not
    looking in the right place..
    I have a basic stage...4 graphics in the clip ( converted to
    graphic symbols ), each on their own layer..Each layer is using a
    motion tween.
    What i would like to find out how to do is that when the clip
    gets to the end, to just stop. At the moment, when i upload the
    .SWF file to a webpage, its running in a loop, continuous....I used
    to do this in CS3 by adding a " stop() " command on the last
    keyframe....How do i now get the movie to stop in CS4?? I am at a
    lost, even after trawling the internet for hours today...
    Hope someone can help..
    Niko

    Outstanding....( i was sure i tried this earlier
    on...obviously not )
    Thank you so much for the prompt reply Colin...very much
    appreciated...
    Niko

  • How do I stop a movie clip from looping

    I am using Action Script 3 and the 'stop()' function is not working to stop my movie clips from looping continuously.
    I have added the 'stop()' function to the last frame on the timeline of each movie clip.
    I originally built the .fla file in Flash CS6 using Action Script 2 where it was working with no problems (I have since upgraded and don't have access to CS6 anymore).
    I have all the separate movie clips positioned on Frame 1 of my main stage with the following script to start them playing:
    Cigarette_Reveal.play();
    KickTheHabit.play();
    BallMove.play();
    BallFlip.play();
    Offer.play();
    I want each of these movie clips to stop playing after one animation sequence is complete.
    Please help!

    Turn on strict mode in your publish settings. This will allow you to see the compiler errors that are preventing the actionscript in your fla from compiling correctly.

  • Dreamweaver CS4 How to play a movie clip by clicking an image

    Hi
    Can anyone recommend a DW Behaviour, Widget or simple piece of Javascript coding that would allow me to start (or start and stop) a movie clip by clicking an image.
    I have a web page created in DW CS4 which has 4 FLV video clips and I would like visitors to be able to start their clip of choice by clicking a small still from each movie stacked at the right side of the page.
    I've seen this done on many sites but don't know how complex it would be.
    Any help / advice much appreciated.
    Thanks
    George

    Hi Ned, thanks for the response;
    1.Yes I named the instance.
    2.I  don't beleive so. I started from the library creating a new symbol, added the graphics, added the key frames, then created the tween. Then I dragged the symbol onto the main stage and named the instance. So I don't think there is a movie clip inside an mc.
    Here is the main timline:
    Here is the mc timeline:
    Here is what I'm trying to do:
    stop();
    blk1._visible = false;
    blk2._visible = false;
    blk3._visible = false;
    ppk1._visible = false;
    ppk2._visible = false;
    ppk3._visible = false;
    storeCartons = new Array();
    storeCartons = [blk1, blk2, blk3, ppk1, ppk2, ppk3];
    startButton.onRelease = function() {
        myNumber = Math.floor(Math.random()*storeCartons.length);
        trace("myNumber "+myNumber);
        activeCarton = storeCartons[myNumber];
        activeCarton._visible = true;
              activeCarton.play();

  • Any one know how to stop iTunes movies from playing menu music when movie is paused?

    Anyone know how to stop iTunes movies from playing menu music when the movie has been paused?

    JourneyMan24 wrote:
    Anyone know how to stop iTunes movies from playing menu music when the movie has been paused?
    Can't. This is done for the individual movie, not by iTunes.
    Some have it, most don't.

  • How do I transfer movie clips from iPhoto to iPad?

    How do I transfer movie clips from iphoto on my iMac, to my iPad?

    You can use a USB flash drive & the camera connection kit.
    Plug the USB flash drive into your computer & create a new folder titled DCIM. Then put your movie/photo files into the folder. The files must have a filename with exactly 8 characters long (no spaces) plus the file extension (i.e., my-movie.mov).
    Now plug the flash drive into the iPad using the camera connection kit. Open the Photos app, the movie/photo files should appear & you can import.
     Cheers, Tom

  • How do I stop a Movie Clip (Button) from working once clicked?

    Ok,
    I'm using a movie clip as a button to show content on a page, effectively its like a new page of the website. Problem is, with the script im using for it, once the content is show, the button is still active and if clicked again, will re-load the content. I want a way to effectively disable the button whist the content is shown.
    Thanks.
    this.services_inner.buttonMode = true;
    this.services_inner.addEventListener(MouseEvent.MOUSE_OVER, rollOver_services);
    this.services_inner.addEventListener(MouseEvent.CLICK, onClick_services);
    function rollOver_services(evt:MouseEvent):void {
    this.services_inner.play();
    function onClick_services(event:MouseEvent):void {
    MovieClip(root).mov.backgrounds.colour.gotoAndPlay(2);

    Thanks, that does stop it, however, i now need it to work again if a different button is clicked... there are 4 buttons (movie clips) in total, so I assume I'd just need to add the event listener back again on click of the others?
    This is the "Services" Button, with the event listener removal.....
    this.services_inner.buttonMode = true;
    this.services_inner.addEventListener(MouseEvent.MOUSE_OVER, rollOver_services);
    this.services_inner.addEventListener(MouseEvent.CLICK, onClick_services);
    function rollOver_services(evt:MouseEvent):void {
    this.services_inner.play();
    function onClick_services(event:MouseEvent):void {
    MovieClip(root).mov.backgrounds.colour.gotoAndPlay(2);
    this.services_inner.removeEventListener(MouseEvent.CLICK, onClick_services);
    This is the "Contact" Button, which when clicked would need to "re-activate" the Services button.
    this.contact_inner.buttonMode = true;
    this.contact_inner.addEventListener(MouseEvent.MOUSE_OVER, rollOver_contact);
    this.contact_inner.addEventListener(MouseEvent.CLICK, onClick_contact);
    function rollOver_contact(evt:MouseEvent):void {
    this.contact_inner.play();
    function onClick_contact(event:MouseEvent):void {
    MovieClip(root).mov.backgrounds.art.gotoAndPlay(2);
    this.services_inner.removeEventListener(MouseEvent.CLICK, onClick_contact);

  • How to freeze a movie clip?

    Hi,
    I am new to flash, and I've never done animation before, so I'm a little confused on how to make a symbol movie clip, freeze and then keep moving.
    Do I need to do it frame by frame?
    I made a character walk from off the stage to the center by using a motion tween and it appears to be moving because I edited the symbol to make the legs move. But now I don't know how to make the legs stop when the character reaches the end of the motion tween. Is it even possible?
    I hope I explained myself clearly...All help is appreciated.
    Thanks

    the moving legs should be a movieclip.  that movieclip will be a child of the character movieclip.  the legs movieclip should have an instance name on the character timeline (eg, legs_mc).
    then if your character is added to the main timeline, assign an instance name (eg, character_mc) and when character_mc stops moving, use:
    character_mc.legs_mc.stop();

  • How do I recerence Movie Clips on the Main Timeline from inside a class?

    Hey everyone, this might be a stupid question but I thought
    I'd ask cause it's making me nuts. I'm all of 2 days into AS3
    (coming from not using Flash at all in YEARS) so feel free to
    consider me ignorant. I do have plenty of application development
    experience in other areas though.
    I can't seem to create a class that can reference an instance
    of a movie clip on my main timeline. I'd post code of what I've
    tried but I've gone through so many desperate edits & wild
    guesses that it was just garbled junk before I deleted it all.
    Basically here's how I figured Flash could work, though maybe
    it doesn't work this way at all.
    I'm assuming that with AS 3 being so big on being a true
    object oriented environment, I wouldn't need to mix my code and
    interface together. Preferably I'd be using the Flash authoring
    tools just to design my interface. Create a button... place it
    somewhere... give it an instance name. Roughly the equivilant of
    Apple's InterfaceBuilder for those of you that might be familiar
    with Cocoa development. I can see maybe having to put a few lines
    of ActionScript onto frame 1 (though really I'm hoping Flash would
    have a better method of kicking off the application at this point
    that using code tied to frames) to load my classes & such, but
    after that I'd like all of my code to be held in external class
    files.
    So maybe I've got:
    Interface.fla - My interface
    Button_1
    Button_2
    TextField_1
    Main.as - My main controller class using to handle all of my
    applications behavior
    SomeClass.as - Some helper Class
    SomeOtherClass.as - Some helper Class
    Main.as would have instructions in its initialization method
    to go ahead & attach events to buttons & initialize
    anything else that needs to happen when the application starts.
    From there on it would all be objects communicating back &
    forth. Button_1 would get clicked with would fire
    Main.someMethod(). Main.someMethod() would then do it's thing and
    set the value of TextField_1. All very clean & code is very
    separated from interface.
    Unfortunately I can't for the life of me figure out how AS3
    classes reference each other like that. There doesn't seem to be
    any kind of a global 'root' or '_root' I can use to locate any
    movie clips on the stage. I've searched the help & the web for
    any kind of simple tutorial but to no avail. My job has tasked me
    with building a flash app for a project but I'd really rather not
    have a tone of ActionScript just shoved into frame 1. That just
    seems... ugh! (::shudder::)
    Can someone maybe point me in the right direction here? I'm
    really willing to do my homework but I can't seem to locate the
    info I need to get started. Also, is there an ActionScript IRC
    channel or something maybe?
    Thanks,
    Cliff

    I worked with the problem last night and the solution I
    started coming to involved creating my own custom document class
    based off which extends MovieClip. My thought is that way I have
    access to the initialization routine of the timeline itself and
    that all of the elements on the main timeline should be
    "properties" of my custom class.
    Is this correct? Is there a down side to doing this & if
    so what is it & why?
    Also, just for my reference, the last time I did anything
    with ActionScript I think I was using '_root' to target the main
    timeline. WHat are the global variable names in AS 3? Is it just
    'root' & 'stage' or 'Root' & 'Stage' or what?

  • How can you make movie clips partially visible?

    Okay, so this sounds simple, but I'm tottally lost... I'm a thirteen year old boy that has been using Flash for a little over 3 years. I program video games. I recently embarked on a game where one of the modes is to be split screen, player one gets the top half, player 2 the bottom. The promblem with this is that my game is based off of a moving background, where inorder to keep the main character centered the background moves instead of them. Becsause of this,when setting up split screen, the screen on the upper layer takes over the bottom because there would be more showing then there would be in the game: Parts would be off screen. I was wondering if there was anyway that using hitTest(s) (or some other method) you could make a movie clip partially visible/ invisible. I know the code for making something invisible when touching something else. But I was wondering if there was a way to make only the part of the movie clip touching another movie (it would have its alpha turned off... let's say it's a hitBox) or only the part of the movie clip touching the hitBox visible, invisible. Another way of looking at this is that I want a movie clip to be a small box, but inside I want their to be a huge picture. I want to make it so that when you move the picture different parts are viewable in this little box. And to make this as clear as I can... : I want to make a circle that I'll call the magnifying glass. I want to make an invisible picture that can be moved using code (I know that part). I want it so that when part of the picture is under the magnifying glass it's visible, not the hole thing, jus that circular area. Another reason I'd like to have this promblem solved is for a moving water effect. I want to make a movie clip and tween showing a square of rushing water, but without putting anything over parts of it (other than a hitBox) I want to make only a squiggly line of that water box visible. Thank you so much! =D I really hope you guys know! =D P.S. I also am currently using the trial of CS4, if that helps anything. But if it's only possible in AS3, then it's impossible to me because I use AS2 conservatively.

    Thanks... but I think you've misunderstood my question. I suppose magnifying glass wouldn't be the right word... I just wanted to explain that I want only the part of one mc touching another mc to be visible. I hope this isn't confusing. I have no need to enlarge an image. I want to make a movie clip only partially visible. Check out the fla.

  • How do I backup movies/clips to use in future projects?

    After burning my first DVD & deleting the iMovie file, I was sad to discover that I could not just pop the DVD into my drive & access the material to use in future projects. (Is there a way to do do this that I don't know about?)
    I'm guessing I need to burn the archived iMovie file onto multiple regular CDs (I have not burned anything that spans several CDs before). This is confusing me because the zipped file is hardly smaller than the original (Is there a better zip program than the one that comes with this system?) I threw away the wrapper for my blank CDs so I don't know how much they hold but I think it is something ridiculously small like 670MB and the iMovie file is 7GB. Is this the only way to save my movie/clips so that I can bring clips into a future movie?
    1.8 GHz Power PC G5   Mac OS X (10.3.9)   256 MB DDR SDRAM

    welcome Novice to the  board ....
    hmm, multidimensional question ...
    DVD is end-of-the-road, not meant for further processing; there are tools, allowing to import DVD to iM, but that is a time-consuming and lossy (=losing pic quality) process, due to the deliver-format nature of DVDs.... search forum for "DVD import"
    iM is by concept not meant to handle a clip in many projects (that can easily been accomplished with pro tools as FC(E), which offer "bins" for imports, offering the content to many sequences/projects).
    there are workarounds, dragging clips from the internal files of an iM project to another... but, as said: you "fumble" the concept: import tape, edit, burn - done.
    a video contains ~13GB of data per hour... and, video is allready highly compressed, no zipper can reduce that dramatically... and, you risk damage of files... yepp, a cd-r fits ~700MB = 3.5min of video......
    recommended workflow:
    * don't store iM projects on -r media (cd/dvd), but firewire connected harddrives..
    * keep the tapes; import clips from tape into project; you can export single clips out of iM/import into another project, I wouldn't do that with "lots" of clips, importing the tape is... more convenient..

  • How to keep a Movie Clip on the screen for 5 secs.

    I am having trouble with keeping a movie clip on the screen.
    I am setting it up to play a movie using the .onPress function. It
    is calling the movie but only shows it for a split second. How can
    I make the movie stay on the stage for 5 seconds? Here is how I
    have it coded:
    rc1MC.onPress = function() {
    if (rc1MC.hitTest(_xmouse, _ymouse, false)){
    _global.correct++;
    updateStats();
    var c1:MovieClip = this.attachMovie ("correct1_mc",
    "correct1",4300);
    var ymov = this._y;
    var gravity = 20;
    c1.onEnterFrame = function() {
    ymov += gravity;
    xmov *= 0.5;
    c1._rotation += 5;
    c1._x += xSpeed;
    c1._y = ymov;
    if (c1._y>stageHeight) {
    c1.removeMovieClip();
    delete this.onPress;
    Thanks Brandon

    Got my answer...
    http://forums.verizon.com/t5/FiOS-TV-Technical-Assistance/For-Those-of-You-Who-Want-to-View-Subscrib...

  • How to Remove a Movie Clip

    Hi,
    On the main timeline, I have the following code:
    external_btn.addEventListener(MouseEvent.CLICK, showMenu);
    function showMenu(e:MouseEvent):void
    var myMovieClip:MovieClip = new Member();
    addChild(myMovieClip);
    myMovieClip.x = 597.95;
    myMovieClip.y =359.15;
    in the internal movie clip, that I linked it to Member:
    In the member movie clip, I have the following code to remove the movie clip that was created in the main timeline of the root movie clip.
    release1_btn.addEventListener(MouseEvent.CLICK, goBack1);
    function goBack1(e:MouseEvent):void
    MovieClip(root).removeChild(myMovieClip);
    I received the following compiler error:
    1120: Access of undefined property myMovieClip.
    Please help me know how to resolve this error message.
    Thanks,
    Robert.

    that's (coding on more than one timeline) not good coding style, but this will correct your error and the prevent a few more:
    release1_btn.addEventListener(MouseEvent.CLICK, goBack1);
    function goBack1(e:MouseEvent):void
    MovieClip(this.parent).removeChild(this);

  • How to email a Movie Clip in Flash

    Hi everyone.
    I am creating a painting / drawing application in flash.
    I want to add a functionality, which allows the user to send his/her painting to his/her email address.
    How can this be done?
    Please note that the painting / drawing would be a movie clip
    Help on an urgent basis would be greatly appreciated
    Thanks

    Hi,
    I did something similar for AS2:basically there was a "designer" swf where one could interact to create a design,
    and a "viewing" swf that contained all the bits and pieces used (e.g. a blank t-shirt).
    The designer swf would send data (placement of objects, coordinates of strokes) to the server, and the server would amend the blank viewer swf by compiling the data object and adding it as another code block. The code of the viewing swf would handle constructing the desired image, by placing objects, adding strokes, etc.
    With the simple structure of AS2 code, php could do that.
    I sort of believe that something similar could be done for AS3 if the server is able to run java (the flex sdk programs). Addition: PHP by itself should be able to replace an embedded text file ... such as an xml description of the artwork

Maybe you are looking for

  • What are the reasons for disabling the saving of data in a PDF?

    I seem to have had more than my share of encounters lately with PDF files that have editable fields but have their data saving capability disabled. In some of these situations this has been an absolutely maddening inconvenience. When I attempt to bri

  • Table Control in ITS is getting wrongly displayed

    Hi All, I Have developed a program(say abc) and created a screen for that program(abc). My issue is that,i have kept the table control in the box . When i execute the screen in se80 under the program(abc) ,its displaying properly ( i mean table contr

  • IF YOU Adobe Please Solve this

    Dear Adobe We are all very happy when you introduce CS3 application. But know too much problem with these applications. First of all one big mistake you don't put contact E-mail address on your web site. For new user have a big problem to tell you ab

  • How do I turn off mail notifications?

    I already went to System Preferences > Notifications and set Mail Alert Style to "none" and also unchecking notification center, badge app icon and sound options. Despite taking these steps, the mail icon in my dock displays a "new email" light and d

  • Import of custom class doesn't seem to work...

    OK, I have my custom class defined in a file called "rootInstace.as". This is what it contains: package import flash.display.MovieClip; public class CRoot extends MovieClip public static var _root:MovieClip; public function CRoot () _root = this; thi