AS3 FL4 Move Movie Clip

Suppose that un has two buttons "left " " and a" entitled ' .
le ' left ' moves to le left
et the "right ". " to the right
et the goal is to move the object " ball "
based on ce potential requires only script to do this?

Here is a version:

var howFar:int = 5;

left.addEventListener (MouseEvent.MOUSE_UP, moveLeft);

right.addEventListener (MouseEvent.MOUSE_UP, moveRight);

function moveLeft(event:MouseEvent):void {}

ball.x += howFar;

}

function moveRight(event:MouseEvent):void {}

ball.x = howFar;

}

Simply change the value of the variable howFar to change the distance that the "ball" is moved. "Ball" is moved whenever you click on one of the buttons.

A second version:

var howFar:int = 5;

var moveLeft:Boolean = false;

var moveRight:Boolean = false;

left.addEventListener (MouseEvent.MOUSE_DOWN, leftDown);

left.addEventListener (MouseEvent.MOUSE_UP, leftUp);

right.addEventListener (MouseEvent.MOUSE_DOWN, rightDown);

right.addEventListener (MouseEvent.MOUSE_UP, rightUp);

stage.addEventListener (Event.ENTER_FRAME, onEf);

function leftDown(event:MouseEvent):void {}

moveLeft = true;

}

function leftUp(event:MouseEvent):void {}

moveLeft = false;

}

function rightDown(event:MouseEvent):void {}

moveLeft = true;

}

function rightDown(event:MouseEvent):void {}

moveLeft = false;

}

function onEf(event:Event):void {}

{if (moveRight)}

ball.x += howFar;

}

{if (moveLeft)}

ball.x = howFar;

}

}

In this version the object "ball" will continue to move as long as the left or right button is pressed. It stops when the button is released.

Either version, the 'balloon' will continue to move even after he left the visible area of the scene.

Tags: Adobe Animate

Similar Questions

  • AS2 to AS3 conditional movie clip function

    I had an AS2 script which would have melted all clips of movie except the rolls more than one. I'm trying to implement this script in AS3, but I can't seem to make it work. Can someone please tell me where I'm wrong? Thank you!

    Here is the AS2 script:

    function alpha (obj) {}

    for (var i = 1; i < = 24; i ++)

    {

    if (obj._name! = 'p ' + i).

    {

    var box_tween:Object = new Tween (_root.port ["p" + i], "_alpha", Regular.easeInOut, 100, 40, 1, true ");

    { } else

    {

    obj._alpha = 100;

    }

    }

    }

    Here is my attempt to translate this to AS3:

    function onButtonOver(e:MouseEvent):void {}

    for (var i: Number = 1; i < = 4; i ++)

    {

    if (e.currentTarget! = 'p ' + i).

    {

    var enterTween:Tween = new Tween (["p" + i], "alpha", None.easeOut, 1,.4, 1, true);

    { } else

    {

    e.currentTarget.alpha = 1;

    }

    }

    You are welcome.

    Please check the answer, if you can.

  • AS3: see the hide the elements of the movie clip, single button array.

    Hello and please forgive my Noobdity I teach myself AS3 and stuck on what are obviously the basics.

    I did the simple animations for years without using any AS3 at all, the time has come to take seriously.

    I read the daylights out of all reference documents Adobe now but I am stuck on this task.

    I have 4 objects of movie clip whose visibility I control with two buttons.

    First button, two of these visible clips and the other two will make visible = false

    For example: Mc1 and Mc2 > visible, Mc3 and Mc4 > visible = false

    The second button run the same function but in reverse

    Eg: Mc1 and Mc2 > visible = false, Mc3 and Mc4 > visible

    I've determined correctly or incorrectly reading endless and looking for a table should be the best way to do it.

    I may have to use the child feature add but * shrugs, I'm lost atmo

    I've been blunders on the code for the first of two simple buttons.

    I start slowly form a mindmap what should be done, but it's early days.

    Here is my code and please feel free to

    Last attempt tries to use the mouse on the trigger to control the visible state of the second two clips.

    var wcArray:Array = [myMovieclip1, myMovieclip2];

    var acArray:Array = [myMovieclip3, myMovieclip4];

    acComp_btn.addEventListener (MouseEvent.CLICK, _acComp);

    internal _acComp(e:MouseEvent): void {}

    for each {(var point: MovieClip dans acArray)}

    Item.visible =! item.visible;

    }

    }

    acComp_btn.addEventListener (MouseEvent.MOUSE_OUT, _wcComp);

    internal _wcComp(e:MouseEvent): void {}

    for each {(var point: MovieClip dans wcArray)}

    Item.visible =! item.visible = false;

    }

    }

    Currently run 1050 error: impossible to assign a value, not reference.

    The text in blue works with 2 clips of film acArray of course, where the attempt to use the mouse on.

    Any advice on the solution or the best method to implement would be greatly appreciated.

    For what you're trying to make a table is more complication than a solution, you have already divided in two arrays anyway probably due to this tax... and have two buttons to do isn't necessary, but you may already be knowing that since you have only code for one of them in any case.

    All you need is a button that activates the visible properties to their opposites.

    var array: Array = [myMovieclip2, myMovieclip3, myMovieclip1, myMovieclip4];

    myMovieClip1.visible = myMovieclip2.visible = false;  or the other two... depending on what initially as invisible

    btn.addEventListener (MouseEvent.CLICK, _acComp);

    function _acComp(e:MouseEvent): void {}

    for each {(var point: MovieClip dans tableau)}

    Item.visible =! item.visible;

    }

    }

    LF, you must have two buttons to do the opposite, as you say, then clicking on buttons must end up affecting all the buttons, no not only one of the tables you have done.  If each button should do what you say, then you should not use the! operator since that can go the opposite of what you intend, so you must assign the desired state.

    var wcArray:Array = [myMovieclip1, myMovieclip2];

    var acArray:Array = [myMovieclip3, myMovieclip4];

    acComp_btn.addEventListener (MouseEvent.CLICK, _acComp);

    function _acComp(e:MouseEvent): void {}

    for each {(var point: MovieClip dans acArray)}

    Item.Visible = false;

    }

    for each {(var item2:MovieClip in wcArray)

    Item2.Visible = true;

    }

    }

    wcComp_btn.addEventListener (MouseEvent.CLICK, _wcComp);

    function _wcComp(e:MouseEvent): void {}

    for each {(var point: MovieClip dans wcArray)}

    Item.Visible = false;

    }

    for each {(var item2:MovieClip in acArray)

    Item2.Visible = true;

    }

    }

  • AS3 MOVIE CLIP HELP BUTTON!

    Hello

    I am a beginner and need help.

    I have several movie clip buttons and everytime my mouse over and out they run perfectly, no problem... but now I want these buttons of movieclip to an image when you click on it, and for that, I don't know what to do!

    Here is the code I have so far for the movie clip buttons

    I would appreciate your help, thank you!

    btn_mc.buttonMode = true;
    btn2_mc.buttonMode = true;
    btn3_mc.buttonMode = true;
    btn4_mc.buttonMode = true;
    btn5_mc.buttonMode = true;
    btn_mc.addEventListener (MouseEvent.ROLL_OVER, onButtonOver);
    btn_mc.addEventListener (MouseEvent.ROLL_OUT, onButtonOut);
    btn2_mc.addEventListener (MouseEvent.ROLL_OVER, onButtonOver);
    btn2_mc.addEventListener (MouseEvent.ROLL_OUT, onButtonOut);
    btn3_mc.addEventListener (MouseEvent.ROLL_OVER, onButtonOver);
    btn3_mc.addEventListener (MouseEvent.ROLL_OUT, onButtonOut);
    btn4_mc.addEventListener (MouseEvent.ROLL_OVER, onButtonOver);
    btn4_mc.addEventListener (MouseEvent.ROLL_OUT, onButtonOut);
    btn5_mc.addEventListener (MouseEvent.ROLL_OVER, onButtonOver);
    btn5_mc.addEventListener (MouseEvent.ROLL_OUT, onButtonOut);

    function onButtonOver(e:MouseEvent):void
    {
    e.currentTarget.gotoAndPlay ("over");
    }

    function onButtonOut(e:MouseEvent):void
    {
    e.currentTarget.gotoAndPlay ("out");
    }

    The function below will work so that a button is, then you need to create separate functions for each button that is clicked, or use a switch statement in a function to take an action based on which button has been clicked using the event.currentTArget to determine which.

    btn_mc.addEventListener (MouseEvent.CLICK, onButtonClick);

    function onButtonClick(e:MouseEvent):void
    {
    gotoAndStop (2);

    }

  • How can I enlarge the movie clips? [with pictures]

    There are 9 video clips in each square (object) and the color in each video clip can be changed by mouse click.


    However, if I want one of the spaces enlarge by clicking on it, then I can click on each video clips to change the color.

    How can I do? Can I create another movie clip and cover the place to click to enlarge?

    Please help me! Thank you!!!

    AS2 or AS3? AS2, you can disable the movieclip which is clicked by mc.enabled = false; For AS3, you can either remove the event listener as mc.removeEventListener ("your event type used listener", onClickFunc) or you can add a flag (Boolean variable) you set to false when it was enlarged and use it to check your onClickFunc and decide whether to change the color of a movieclip or not.

  • Key Flash / Movie Clip

    Hello...

    I'm pretty new to Flash... I am trying to create a button or movie clip... I have 3 empty boxes with a message next to each... When you click on the first box, a check mark is displayed and a message is playing to go to the second box unchecked... When you click on the second box this box appears and plays a message to pass to the third box unchecked... At the end all the 3 boxes checked and the messages are there... Once this is done, it turns more and 2 buttons appear...

    Don't know if I should create 3 buttons with a clip in each or create a clip with buttons in them... And how do...

    Any help would be greatly appreciated... I work in Flash 9.

    Images of Marcus

    Here is a link to a file of CS3/AS3 the basics of what you no doubt do demos...

    http://www.nedwebs.com/Flash/AS3_Check_Moveon.fla

  • roleOver movie clip button help

    Im stuck with the addition of roleovers to my movie clip buttons. To the then that my button code is set so that once clicked top stays on a framewhich is another color, it remains that color until the user clicks another button. It works fine, but now I need to ad a rolover to each button that is the same color that the button once clicked - my code goes like this, I'd appreciate it really any entry:

    var buttons_array:Array = new Array(home_btn,showcase_btn,aboutus_btn,approach_btn,contact_btn);


    for (var i: int = 0; i < buttons_array.length; i ++)
    {
    buttons_array [i] .mouseChildren = false;
    buttons_array [i] .buttonMode = true;
    buttons_array [i] user.user = i;
    buttons_array [i] .addEventListener (MouseEvent.MOUSE_DOWN, callSelectionButton);
    }


    function callSelectionButton(evt:MouseEvent):void
    {
    selectionButton (evt.target.id);
    }

    function selectionButton(id:int):void
    {

    for (var i: int = 0; i < buttons_array.length; i ++)
    {
    if(i==ID)
    buttons_array [i] .gotoAndStop (2);
    on the other
    buttons_array [i] .gotoAndStop (1);
    }
    }


    selectionButton (0);

    You should read a bit about as3.

    in the meantime, try:

    dazzlah wrote:

    Attached code:

    //-----------------------------

    var buttons_array:Array = new Array(home_btn,showcase_btn,aboutus_btn,approach_btn,contact_btn);

    for (var i: int = 0; i<>
    {
    buttons_array [i] .mouseChildren = false;
    buttons_array [i] .buttonMode = true;
    buttons_array [i] user.user = i;
    buttons_array [i] .addEventListener (MouseEvent.MOUSE_DOWN, callSelectionButton);
    buttons_array [i] .addEventListener (MouseEvent.MOUSE_OVER,mouseOverF);
    buttons_array [i] .addEventListener (MouseEvent.MOUSE_OUT,mouseOutF);
    }

    var lastSelectedBtnID:int;

    mouse to the bottom of the function
    function callSelectionButton(evt:MouseEvent):void
    {

    lastSelectedBtnID = evt.target.id
    selectionButton (evt.target.id);
    }
    function selectionButton(id:int):void
    {
    for (var i: int = 0; i<>
    {
    if(i==ID)
    buttons_array [i] .gotoAndStop (2);
    on the other
    buttons_array [i] .gotoAndStop (1);
    }
    }

    mouse over the function
    function mouseOverF(evt:MouseEvent):void
    {

    If (evt.currentTarget.id! = lastSelectedBtnID) {}
    buttons_array [evt.currentTarget.ID] .gotoAndStop (2);
    }

    }

    mouse over the function
    function mouseOutF(evt:MouseEvent):void
    {
    If (evt.currentTarget.id! = lastSelectedBtnID) {}

    buttons_array [evt.currentTarget.ID] .gotoAndStop (1);

    }

    }

  • Question of Nasted movie clips

    Hello

    I have this problem. I have a movie clip with the instance name mc1 and it is placed on the root music scene. I have movie clip with the instance name mc2 inside mc1.

    I want access to mc2 from the clip of root. If mc2 is on the first picture in mc1 - there is no problem - I use mc1.mc2. But if I place mc2 on the second picture, then flash throws the exception.

    I use Flash CS3 + AS3.

    Thank you

    1. you can place it on executives who need. You can set _visible to false on the frames property, it should not be seen or move it out of the scene.

    2. you can export it to the library, and then use a variable with attachMovie.

  • Images of iPod touch - volume of the .mov clips

    Hello

    When I use an iPod touch pictures, the .mov clips sound volume is too low, even if I turn as hard as possible in Final Cut. How can I get stronger?

    Thank you!

    Unfortunately, it really isn't that you can do. You could make a new project and put just the clips that need to be more strong in there, then set volume as loud as it goes, then export than as a video, and then import that new video in your regular project (except that it is strong this time) and you can increase the volume at maximum again. If all goes well, which should help. However, the quality may be slightly reduced.

  • Cannot move clips to the timeline.

    Mac OSX: 10.11.2

    Premiere Pro: 10.4.0

    I had problems with Premiere Pro on 10.3 and 10.4. At this point, I just want to get either version working.is curr

    10.3 hangs at startup despite uninstalling all my Red Giant Software

    10.4 opens but when I try to move clips no matter where it just doesn't happen. Cannot move bins clips or timeline. And when I opened an old project, I can't move clips autour on the timeline even if they are already there.

    Any help is greatly appreciated. I know there are many of you who know what it's like to not be able to get the software you paid for work. It's frustrating say the least!

    Removal of the preferences has worked. So far, 10.4 works!

  • [JSFL] Have a name binding class by name of movie clip

    Hello

    I have a few question doing this. As I do this for some time, I wanted to try a jsfl script instead of doing it manually every time.

    My library will look like this every time.

    2015-12-15_11-30-42.jpg

    What I would like: ave in the end:

    2015-12-15_16-31-01.jpg

    What I want is simple, I want to just take the name of each clip and paste it into the link attribute.

    If the name was easy enough, but as it was the full path, I needed to cut it, so I used the substring.

    But then, despite my attempts, I can't paste the name into the binding attribute.

    It won't take my last sentence: "fl.getDocumentDOM (). library.items [i] .className = newClassName;

    Any ideas?

    Here is the code:

    function init()

    {

    fl.outputPanel.clear ();

    var i = fl.getDocumentDOM (). library.items.length;

    var lib = fl.getDocumentDOM () .library;.

    While (i)-

    {

    If (fl.getDocumentDOM (). library.items [i] .itemType == "movie clip")

    {

    getName = fl.getDocumentDOM () var. library.items [i] .name;

    newClassName = getName.substring (20, getName.length);

    FL.trace (newClassName);

    () fl.getDocumentDOM. library.items [i] .className = newClassName;

    }

    }

    }

    init();

    Finally got my code works with a few more lines.

    Well, I just needed to add "item.linkageExportForAS = true;". Of course...

    function init()

    {

    var i = fl.getDocumentDOM (). library.items.length;

    var lib = fl.getDocumentDOM () .library;.

    While (i)-

    {

    var point = lib.items [i];

    If (lib.items [i] .itemType is "movie clip")

    {

    if(Item.linkageExportForAS==false)

    {

    getName var = lib.items [i] .name;

    newClassName = getName.substring (20, getName.length);

    item.linkageExportForAS = true;

    item.linkageClassName = newClassName;

    }

    }

    }

    }

    init();

  • 2 problems with CS6 - Movie Clip not seen &amp; interpolations added to the library

    Occasional user of Flash. I need to edit a project which began in CS6, so I prefer to leave in this version. Once I started to edit the project, I noticed two things happening. Video clips animate not when previewing in the program. However, the Movie Clips animate properly in the preview publish and published format. The second question, each classic Tween I create is added to the library. I don't remember these two questions when originally, I worked on the project. Is there something I could have changed (preferably, option, etc.) to cause these issues? TIA

    There the scripts inside the movieclip? The instance is defined as a movieclip or a chart?

    Something in the way, as long as you have not used the OS TLF or IK, you should be able to work on the file in CC and still open ok in CS6 later.

  • Using CS4 Flach and action script 2.0 how to move a specific frame in the main timeline when a movie clip instance come at the end of his chronology?

    Using CS4 Flach and action script 2.0 how to move a specific frame in the main timeline when a movie clip instance come at the end of his chronology?

    code on the last frame of your movieclip instance:

    _root.gotoAndStop ('whatever_frame');  will work unless this swf is loaded into another swf.  in this case, you must use a relative path to the main timeline (for example, _parent or _parent._parent etc.).

  • I can't move clip source window to the timeline by grabing it with the mouse.

    I can't move clip source window to the timeline by grabing it with the mouse. I can cut it short it. Once that there I can't move at all

    If first is weird, restart your computer, open the first while pressing SHIFT + alt up to the Welcome screen.

    See if this will help.

  • Using the ActionScript 2.0 Movie Clip Variable Array

    I just want to use several movie clip attached as table, btw, it's the simple code:

    if(_Global.pLevel == 0)
    {
    var box1:MovieClip = _root.attachMovie ("flip_box_lg", "fb1", this.getDepth () + 5, {_x:100,_y:100});})
    Box1._width = 100;
    Box1._height = 40;
    Box1._x = 60;
    Box1._y = 80;
    var box2:MovieClip = _root.attachMovie ("flip_box_lg", "fb2", this.getDepth () + 6, {_x:100,_y:100});} ")
    Box2._width = 100;
    Box2._height = 40;
    Box2._x = 170;
    Box2._y = 80;
    this.onEnterFrame = assignF;
    }

    Can I just making it like that?

    for (var i = 0; i < 6; i ++)
    {
    [i] var box: MovieClip = _root.attachMovie ("flip_box_lg", "fb" +(i+1), this.getDepth () + 5, {_x:60+(i*110),_y:80});})
    }

    Thank you before

    use:

    var box: Array = [];

    for (var i = 0; i)<>
    {
    Box.push (_root.attachMovie ("flip_box_lg", "fb" +(i+1), _root.getNextHighestDepth (), {_x:60+(i*110),_y:80}));}))
    }

Maybe you are looking for

  • Safari, suspended when using Hotmail

    Hello A colleague asked me to solve a problem she has with her hotmail account using safari (5.1.10) on his Macbook pro (OSX 10.6.8). When it loads Hotmail (via MS live.com) the browser hangs and will not have to type in the body of the email. I've t

  • I would like to change my cursor vertical bar in the form of block, such as those used on the old green screens

    In Internet Explorer, the cursor can be changed to a form of block, I can't find a way to do it with Firefox, the shape of block is a former carry dating back to the era of the former "green screens".

  • SMS charged?

    If the sender send me an sms via iMessage, because there is no internet, I take my mobile company to receive even I have internet?

  • Ideapad U330 battery won't charge....

    Hi.., all Now, I'm facing a problem. It's the battery problem. The battery is not at a level. So, if you have the solution for him, please share to me. I already updated the bios for this most recent day. Thank you Daniel..,.

  • Hidden JDE display options

    I was looking for more in the debugging options and view of the JDE and all display options are blanked out, what should I do to make them work?  Also, I set a few breakpoints and the first time I ran it, they worked, but now they do not have...