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.

Tags: Adobe Animate

Similar Questions

  • 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;

    }

    }

  • How to trace all the functions and variables Movie Clip

    How can I find all the functions and variables available Movie Clip?  Thank you

    Use the describeType() function.

  • 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.

  • 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);

    }

    }

  • [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();

  • Movie Clip Visible after 5 sec

    Hello

    I have 3 Movie clips foam1, foam2, foam3

    they are visible after 5 sec on the hit with scratch movieclip test

    scratch.onEnterFrame = function() {}

    this.startDrag (true);

    };

    scratch.onRollOver = function() {}

    If (this.hitTest (_root.soap1)) {}

    foam1.gotoAndPlay (2);

    }

    else {if (this.hitTest (_root.soap2))

    foam2.gotoAndPlay (2);

    }

    Else if (this.hitTest (_root.soap3)) {}

    foam3.gotoAndPlay (2);

    }

    };

    then use

    setTimeout(visibleF,5000,whatever)

  • Cannot add event listener to instantiated Movie Clip

    Hi guys,.

    I have a clip that I'm loading dynamically in my scene when a key is pressed.  Then, I would like to add a mouse event listener to the Movie Clip object so it can trigger a function when clicked.  I get an error when you try to do this and cannot find a solution anywhere.

    Here is my code:

    newLayerBT.addEventListener (MouseEvent.CLICK, newLayerBT_CLICK);

    function newLayerBT_CLICK (MouseEvent): void {}

    layerCount = layerCount + 1;

    Make a new object in my class BlankLayerMC

    var newLayer:BlankLayerMC = new BlankLayerMC;

    addChild (newLayer);

    Position the new object

    newLayer.y = prevY + newLayer.height;

    Change the text inside the object in order to take account layerCount courses

    newLayer.layerName.text = 'Layer' + layerCount;

    newLayer.layerNum = layerCount;

    prevY = newLayer.y;

    My problem occurs with this line...

    newLayer.addEventListener (MouseEvent.CLICK, moveSelection);

    layerArray.push (newLayer);

    }

    function moveSelection(e:MouseEvent):void {}

    var t = e.target;

    layerSelectedGraphic.x = t.x;

    t.y = layerSelectedGraphic.y;

    }

    Any help would be greatly appreciated

    change:

    function newLayerBT_CLICK (MouseEvent): void {}

    TO:

    function newLayerBT_CLICK(e:MouseEvent):void {}

  • Movie Clip should stop when that date back to the 1st scene (Web page)

    The .fla file:

    http://www.2shared.com/file/r_u9xlp1/home.html

    The problem is the graph of movie clip. It must show that on the 2nd stage (page), but when I go back to the 1st scene (page), it continues to display.

    I hope someone can help me. Thanks already for your time.

    Greetz

    scorro_ht

    use:

    function fl_ClickToGoToScene(event:MouseEvent):void

    {

    removeChild (graphMc);

    delete graphMc headphones, if there is

    graphMc = null;

    MovieClip (this.root) .gotoAndPlay (1, "scene 1");

    }

  • Error #1009 with a movie clip button that is located in a clip

    OK, so I have a button in a movie clip of mc causing a great error problem which continues to repeat.  My code is extremely simple:

    Stop();

    infoGraphicDisparity.addEventListener (MouseEvent.CLICK, disparityGO);

    function disparityGO(event:MouseEvent):void

    {

    MovieClip (this.root) .gotoAndPlay ("disparity");

    }

    I used these types of buttons, a million times, and now CS6 doesn't like it.  Any help is very appreciated.  Thank you

    I have no idea which is MAIN, but...

    stage.addEventListener (Event.ENTER_FRAME, enterFrameHandler);

    Listener is originally the function that seeks to target the HAND at the rate of your file, and she continues to do if you move in the 2 structure.  If there is no HAND in box 2, then it is your source of error.  Try to remove this event listener before going to box 2 and the problem should go away.

  • Create a button in a movie clip for ipad

    I am trying to create a button in a clip for an ipad app (a button next to a slide show, the slide show page is a clip.
    This is the code that I have tried. Button = nextbutton, video clip = artworkmovie. I want just the button to advance the movie clip an image.

    nextbutton.addEventListener (MouseEvent.CLICK, nextClickHandler);

    function nextClickHandler(event:MouseEvent):void

    {

    artworkmovie.nextFrame ();

    }

    It works very well from the scene, but if I have the button 'next' in the film 'artworkmovie' I get the error "Line19 1120 access of undefined property nextbutton. (Line19 is "nextbutton.addEventListener (MouseEvent.CLICK, nextClickHandler);") How can I create a path to the button? I tried artworkmovie.nextbutton and that has not worked.

    Sorry for this one basic question and thank you for your help.

    artworkmovie.nextButton should work.  Make sure you have the name of button assigned to each keyframe in the movieclip.

  • Do away with button movie clip

    Hi all

    Thank you very much for watching my post and I hope you can answer my question

    Basically, I have a 3D interactive project only when the viewer clicks on the window and drag either right or left, then it pops up as they spin a 3D model, I have given out in Maya. What they do moves the mouse over the x axis that causes the clip to play backward or forward.

    The code I got from this site works like a dream! I even made sure that as they click a button depending on whether he goes to the other almost identical movie clip and he will leave the same frame as the previous video clip let go. I'm rather proud of myself for the moment

    However - on the second clip almost identical (mc_2), it has some tags on the images. And what I really want to do is, press the mouse for labels to disappear and when the viewer has finished breakfast through the time line with the mouse move and break the mouse, who reappear labels!

    Looks a lot like now here: http://BMC.Erin.utoronto.ca/~Enid/interactivethyroidectomy/

    So, I worked on this code which works perfectly in a small test project I've done. I put this on a button called my_btn and then made a label and this changed to a clip called my_mc and it all worked perfect

    on {(press)

    _root.my_mc._visible = false;

    }

    on (release) {}

    _root.my_mc._visible = true;

    }

    But what I really need to do is for my previous movieclip, mc_2, use the code above. However, if I add anywhere amoungst my actionscript previous coding in the mc_2 layer, then the viewer can no longer scrub through the timeline more. Clearly this code above is affected my previous code. which is:

    Stop();

    mc_2.stop ();

    var startX:Number;

    var startFrame:Number;

    var changeDistance:Number;

    var travelDistance:Number;

    mc_2.onPress = pressHandler;

    mc_2.onRelease = releaseHandler;

    mc_2.onreleaseoutside = releaseHandler;

    function pressHandler (): Void {}

    startX = mc_2._xmouse;

    startFrame = mc_2._currentframe;

    this.onMouseMove = moveHandler;

    }

    function releaseHandler (): Void {}

    this.onMouseMove = null;

    }

    function moveHandler (): Void {}

    changeDistance = mc_2._xmouse - startX;

    travelDistance = startFrame + changeDistance;

    If (travelDistance > mc_2._totalframes) {}

    mc_2.gotoAndStop (travelDistance % mc_2._totalframes);

    } ElseIf (travelDistance < 0) {}

    mc_2.gotoAndStop (mc_2._totalframes + (travelDistance % mc_2._totalframes));

    } else {}

    mc_2.gotoAndStop (travelDistance);

    }

    }

    Just so I'm ultra clear for the various layers etc.

    On stage 1, I have four layers

    Actions, buttons, clips, video and background

    In two, it has the above actionscript and then mc_2

    Inside of the mc_2 are 100 images from a view of 360-degree images of a shoulder of Maya

    in the top layer of the images, I have labels - one of which ive converted a clip called my_mc to this post.

    So what I have to do is add somewhere in the ActionScript for the mc_2 who, with all the mouse, presses and releases for him also make a specific mc (my_mc) invisible when the mouse is pressed and re appear when the mouse is released.

    I hope that makes sense.

    I thank very you much for your help in advance.

    CAT

    If you want to target something inside the mc_2, then just target mc_2 in the path...

    mc_2.my_mc._visible = false;

  • Movie clip button requires two clicks to activate

    Hello. Is there a reason why my movie clip buttons require only two clicks to activate the toggle function?

    I don't understand why this is happening.

    My code:

    btn_radio.addEventListener (MouseEvent.MOUSE_UP, ToggleRadio);

    btn_radio.buttonMode = true;
    btn_radio.useHandCursor = true

    function ToggleRadio(myEvent:MouseEvent) {}
    {if(!btn_radio.) Toggle)}
    btn_radio.gotoAndStop ("up");
    }
    on the other
    {
    btn_radio.gotoAndStop ("Down");
    }
    btn_radio. Toggle =! btn_radio. Toggle;
    }

    Any help would be great.

    -Pat

    probably because your pimples are starting in position 'high '.  use:

    btn_radio.addEventListener (MouseEvent.MOUSE_UP, ToggleRadio);

    btn_radio.buttonMode = true;
    btn_radio.useHandCursor = true

    function ToggleRadio(myEvent:MouseEvent) {}
    {if(!btn_radio.) Toggle)}
    btn_radio.gotoAndStop ("Down");
    }
    on the other
    {
    btn_radio.gotoAndStop ("up");
    }


    btn_radio. Toggle =! btn_radio. Toggle;
    }

  • Movie Clip (with script) of nesting in button

    I'm pretty new to Flash, I have the basics but struggle when it comes to tasks more complex requiring a code etc. My problem seems simple in theory but in practice it's a different story; for me anyway.

    First stop, I create an online gallery. It is made against several thumbnail images of the art of the pieces which, when clicked, show the image in a larger format. I reached this goal in duplicating the chassis 12 times (how many images it is on the page) and linking each miniature to its corresponding image that runs through frames 1-12.

    I had this working perfectly, except for my animation of miniature mouseover who did very well when the mouse is in the affected area, but once outside the animation just broken back. This was done simply by nesting a movie clip symbol in the State over the button (that does not need any code).

    However, once I searched the internet for ways allow the animation to return to his State not active with an animation of back once the mouse is over the affected area, I hit a new problem entirely. Of course, this effect required some basic coding and was not pressing the button a on the State to activate the animation. This means that when I tried to embed the new animation in the zone reached the animation button was on the button, its ability to disable link area.

    I've tried everything I can think of, but I can't get the animation that will be triggered when the user hovers over the button and allow the button to link to its framework.

    I know this is a long post and thank you for reading. If you don't know what anyone that I said, please ask. I'll also give you a link to the tutorial I used as a base for my animation to be nested within the button. (http://www.kirupa.com/developer/mx20...ton_effect.htm)

    Thanks again.

    If 'frame2' is your label and not "frame2_Page 1", you must use:

    Stop();

    this.onEnterFrame = function() {}

    if(Rewind == true) {}

    prevFrame();

    }

    }

    this.onRollOver = function() {}

    return = false;

    Play();

    }

    this.onRollOut = function() {}

    Rewind = true;

    }

    blakeheaps.onRelease = function() {}

    _root.gotoAndPlay ("frame2");

    }

Maybe you are looking for

  • How can I prevent a Web site from loading automatically into a new tab?

    Whenever I go back to my home page, a Web site different guard load automatically in a new tab. How can I stop this from happening?

  • BSoD on install Skype

    So, I use Skype for AGES on my old computer. I just upgraded a bit small for a better. I tried to install Skype on this computer and I go through the installation process, but whenever I try to open Skype, I get a BSoD. Any help?

  • How to customize the virtual keyboard?

    Hello I am looking for a way to customize the virtual keyboard. I want to customize keyboard and form location, places default keys in the keyboard for some specific languages, the keyboard, the size of the keyboard etc. However, the customization ne

  • program to fix lumia 520 nokia

    Program Nokia lumia 520 on the computer

  • Creative cloud won't Sync Typekit fonts.

    Creative Cloud will not sync my typekit fonts and fonts previously synchronized are no longer available on my adobe apps. All I get are the default fonts. When I go to the assets-> fonts, a blue wheel appears constantly. This blue wheel has turned fo