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 {}

Tags: Adobe Animate

Similar Questions

  • Cannot add music and narration in movie maker.

    Original title: movie maker project on a stall

    good,

    I have two projects develop photos and titles laid out with all the fade in/out choices and now I can't add my choice of music, a story and "finish the project" in order to change it.  I had Director 7 on my old laptop and no problems like that.  WHAT ME DO OR NOT DO?  Help!

    Hello

    I imagine the inconvenience that you are experiencing.

    If you could answer a few questions that would help us resolve this problem:

    1. what version of Movie Maker is installed on the computer?

    2. What is the format of the music files you are trying to add?

    3. do you have a code error message when you try to add music and narration to the project?

    4. the problem occurs with all types of music files?

    If music files are Digital Right Management protected, you will not be able to add to the Movie Maker. It might not have to do with the settings but the Movie Maker is not able to recognize the file format of music stored on your computer.

    For information about adding narration to the project, you can follow the suggestions from this link:

    http://answers.Microsoft.com/en-us/windowslive/Forum/MovieMaker-wlsettings/how-to-add-narration-in-Windows-Live-Movie-Maker/072123c4-6517-46a0-9ed0-335ad38d3042

    Also check out these links for more information:

    Movie Maker

    http://Windows.Microsoft.com/en-in/Windows-Live/Movie-Maker#T1=overview

    How can I download and add music to a movie in Movie Maker?

    http://Windows.Microsoft.com/en-us/Windows-Live/Movie-Maker-add-music

    Can what types of files I use in Movie Maker?

    http://Windows.Microsoft.com/en-us/Windows-Live/Movie-Maker-file-types-FAQ

    I hope this helps. If you have any other queries/issues related to Windows, write us and we will be happy to help you further.

  • Cannot add event. Can't see the calendar.

    I was not able to use the lightning for a while. Most of my calendars are gone and I can't do more. The buttons to create events and they are dimmed. I can't even view the calendar I always said. Looks like all cycles updated some thing missing instead of the difficulty that I was hoping.


  • How to add events to the array elements?

    Hello.

    I have the table with 5 boxes.

    I show as boxes on the stage that + having shown that it is random.

    Now, I want to add events to this boxes.

    For example if I click for box1 I have to go to "p4", if I click to other boxes that I have to go to "p3".

    I'm trying to do the same thing as for the buttons, but its does not work:

    classNames[0].addEventListener(MouseEvent.CLICK, goCorrect);
    function goCorrect(event:MouseEvent):void {
         trace("p4");
         gotoAndStop('p4');
    }
    
    classNames[1].addEventListener(MouseEvent.CLICK, goWrong);
    function goWrong(event:MouseEvent):void {
         trace("p3");
         gotoAndStop('p3');
    }
    

    All the code in the code here:

    var classNames:Array=["box1","box2","box3","box4","box5"];
    var boxesList:Array=[];
    var ClassRef:Class;
    
    for (var i:int = 0; i < classNames.length; i++) {
         ClassRef=Class(getDefinitionByName(classNames[i]));
         boxesList[i] = new ClassRef();
         addChild(boxesList[i]);
    }
    
    var currentBox:MovieClip;
    
    
    var nextX:Number=0;
    for (var iii:int = 0; iii < classNames.length; iii++) {
         currentBox=boxesList[iii];
         currentBox.x=nextX;
         nextX+=currentBox.width;
    }
    
    
    for (iii= 0; iii < 1*boxesList.length; iii++) {
         var pos1:int = (Math.random()*1000) %boxesList.length;
         var pos2:int = (Math.random()*1000) %boxesList.length;
    
         if (pos1!=pos2) {
              var temp:int=boxesList[pos1].x;
              boxesList[pos1].x=boxesList[pos2].x;
              boxesList[pos2].x=temp;
         }
    }
    
    myBox1.visible=false;
    
    
    classNames[0].addEventListener(MouseEvent.CLICK, goCorrect);
    function goCorrect(event:MouseEvent):void {
         trace("p4");
         gotoAndStop('p4');
    }
    
    classNames[1].addEventListener(MouseEvent.CLICK, goWrong);
    function goWrong(event:MouseEvent):void {
         trace("p3");
         gotoAndStop('p3');
    }
    //box1.useHandCursor=true;
    

    You cannot add event listeners to the objects that send events. Generally speaking, an object that you want to send events should extend the EventDispatcher class.

    In your case, you add event listener for the classNames group members that are strings. String not to send events. So, you have to add listeners to events for objects that you instantiate while loop if classNames - these items are (I presume that these are instances of MovieClip, which stretches from EventDispatcher). Therefore, in your case, you can do the following:

    MovieClip(boxesList[0]).addEventListener(MouseEvent.CLICK, goCorrect);function goCorrect(event:MouseEvent):void {     trace("p4");     gotoAndStop('p4');}
    
    MovieClip(boxesList[1]).addEventListener(MouseEvent.CLICK, goWrong);function goWrong(event:MouseEvent):void {     trace("p3");     gotoAndStop('p3');}
    
  • I am maing a movie with windows movie maker and you cannot add a song for the end credits. Whenever I get the song imported the system stops... Help!

    I'm doing a movie with windows movie maker and cannot add a song for the end credits. Whenever I get the song imported the system stops... Help!

    I'm doing a movie with windows movie maker and cannot add a song for the end credits. Whenever I get the song imported the system stops... Help!

    ===============================
    If a music file Movie Maker crashes
    in a format that is not compatible. If you convert
    the file to the format of .wma before importing, you
    can have a better result.

    The converter below might be helpful to try:

    (FWIW... it's always a good idea to create a system)
    Restore point before installing software or updates)

    Format Factory
    http://www.pcfreetime.com/
    (FWIW... you can uncheck
    all the boxes on the last screen)

    After downloading and installing Format Factory...
    Open the program and choose an output folder...
    (this is where you will find your files when they are
    converted)

    Drag and drop your audio clips on the main screen...

    Select "while"WMA"/ OK...

    Click on... Beginning... in the toolbar...

    That should do it...

    Good luck.
    John Inzer - MS - MVP - Digital Media Experience - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • You can add an audio event listener triggered?

    I display a button "stop" Audio "to stop the audio clips triggered on a slide. It is easy to make for itself when you click on hide, but I'd love to also hide whenever the audio ended.

    Anyone know how a way JavaScripty to add a listener to the sound object triggered? (I'll live if it is not possible.) Thnx!

    If you're 9 Captivate? There might be a possibility from the new ' delay next actions of... "command, but you'll have to check the length of each audio clip. The delay time, which will be this audio clip duration, can be put into a variable that makes it more flexible. This command is functional to the SWF and HTML output. ATTENTION: I love the CpExtra widget, it's a 'must have' for each CP-developer who wants to go beyond the basic features of Captivate.

    @Rod I thought that CpExtra to the end of the audio event works with audio attached to objects or slides, with audio triggered by a tip action? Has this been changed?

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

  • [noob] Possible to add an event listener in a table?

    Hi all

    I suspect, it might not be a way to do this, but I thought I would ask.

    I was wondering if there is anyway to add an event listener to a table ("array.addeventlistener (EVENT, cheetosFunction)');.

    I'm working on writing from a table that has several pushed DisplayObjects in, and I was hoping that instead of having to associate each DisplayObject instance with a listener event separately ("head.addEventListener [...], torso.addEventListener [...] legs.addEventListener [...]" ""), since the entire table would be these DisplayObjects, I could save time by adding a unique EventListener in the table, which has a single line of code instead of several.

    Any way to do this, or do something useful in the same way?

    use:

    for (var i: int = 0; i<>

    table [i] .addEventListener (MouseEvent.CLICK, cheetosFunction);

    }

  • How to add a listener for a TextFrame BEFORE_PLACE / events AFTER_PLACE?

    Using Creative Suite Extension Builder 2.0 I am trying to automate some behavior once a text block is created, or when a text block is bound to an xml element. I'm not able to add the right event listener.

    The States of documentation that there is a BEFORE_PLACE and an AFTER_PLACE event on the text frame... these events bubbles. I tried listening on the events using IDScriptingEventAdapter by adding global listeners and listeners on the application or the document like this:

    IDScriptingEventAdapter.getInstance () .addEventListener ("afterPlace", handler);

    IDScriptingEventAdapter.getInstance () .addEventListener ("beforePlace", handler);

    IDScriptingEventAdapter.getInstance () .addEventListenerToObject ("afterPlace", handler);

    IDScriptingEventAdapter.getInstance () .addEventListenerToObject ("beforePlace", handler);

    The handler is not called when I create a text block.

    Anyone know what I'm doing wrong?

    BEFORE_PLACE and AFTER_PLACE is placed only for assets. (that is, items that appear in the links Panel).

    Substances

  • How to add an event listener to another window Native air

    Hello

    Anyone know if it is possible to add and event listener to a button created in another class.

    Basically, I create a save window with yes/no choice and the response must be returned to the window called the class to create this window.

    Note I have a save yes / no windows, so it must be accessible to the other windows that is created in it's own class

    Thanks in advance.

    It works very well, such a simple solution...

    Import as_files.confClass;
    var conf:confClass = new confClass();
    CONF. Win ("save this test")
    CONF._btn2.addEventListener (MouseEvent.CLICK, noFunc);
    function noFunc(event:Event):void
    {
    trace ('NO')
    }
    CONF._btn3.addEventListener (MouseEvent.CLICK, yesFunc);
    function yesFunc(event:Event):void
    {
    trace ('YES')
    }
  • Cannot remove the Image event listener

    I'm clearly missing something and would be grateful for the help.  I'm trying to run an event handler when a full picture of loading, then remove the Manager so that it does not once again the image needs to be reloaded later.

    The problem I'm having is that the event handler simple custom ' disappear, despite the call removeEventListener on the Image object.

    The following example illustrates the problem (the example do anything useful... it's just the shortest example to demonstrate the problem).  (To run the application, you will need to provide any file JPEG ol ' named 'myImage.jpg' in the directory 'src' to your project).

    What to expect to happen is:

    (1) at startup, the image loads and runs of loadComplete().

    2) loadComplete removes the event listener so that subsequent re-loads don't get re-triggers the Manager.  I want only the Manager to run once.

    3) 'loadComplete' should appear in the debug console.

    (4) a click on the button should display only 'change picture' in the debug console

    What I get instead is that Manager loadComplete is not removed, and whenever I click on the button, loadComplete runs when the image is re-load (i.e., each button click results in the showing in the debug console 'change picture' AND 'loadComplete' ).

    <? XML version = "1.0" encoding = "utf-8"? >
    " < = xmlns:mx mx:Application ' http://www.Adobe.com/2006/MXML "layout ="absolute"> "
    "<mx:Image width ="655"height ="181" source =" myImage.jpg" id ="MyImage" autoLoad ="true"="true"scaleContent complete =" loadComplete () " ="100"x ="100"/ >
    < mx:Button = "100" x = "341" label = "Button" click = "click (event)" / >
    < mx:Script >
    <! [CDATA]
    private void loadComplete(): void
    {
    trace ('loadComplete');
    myImage.removeEventListener ("complete", loadComplete);
    }
    private void click(evt:Event):void
    {
    trace ("change Image");
    myImage.load ("myImage.jpg");    Reload image even; This is just an example
    }
    []] >
    < / mx:Script >
    < / mx:Application >

    Hello

    You can only remove event listeners you added with the addEventListener() method in an ActionScript block. You cannot remove an event listener that has been defined in the MXML tag, even if it has been registered by using a call to the addEventListener () method that was made within an attribute of the tag.

    Check this page for reference.

    http://livedocs.Adobe.com/Flex/3/HTML/Help.HTML?content=events_05.html

    You can change the code a bit get it works

    
    
    private function myImage_creationCompleteHandler(event:FlexEvent):void
    {
         myImage.addEventListener("complete",myImage_completeHandler);
         myImage.load("myImage.jpg");
    }
    
    private function myImage_completeHandler(event:Event):void
    {
         myImage.removeEventListener("complete",myImage_completeHandler);
    }
    
  • Why add a listener for an Event object?

    Hello


    I just read something that I do not understand in a book and, of course, I need help...


    stage.addEventListener (MouseEvent.MOUSE_DOWN, clicSouris);

    function clicSouris (pEvt:MouseEvent): void
    {
    var positionX:Number = pEvt.stageX;
    var positionY:Number = pEvt.stageY;
    monDessin.graphics.moveTo (positionX, positionY);
    pEvt.currentTarget.addEventListener (MouseEvent.MOUSE_MOVE, bougeSouris);
    }

    function bougeSouris (pEvt:MouseEvent): void
    {
    var positionX:Number = pEvt.stageX;
    var positionY:Number = pEvt.stageY;
    monDessin.graphics.lineTo (positionX, positionY);
    pEvt.updateAfterEvent ();
    }


    My question is what appens when I add an event listener for the event of the object? And why it does this?


    Following the logic with the AS3 display list, I thought that only Classes that inherit from flash.display.InteractiveObject might react to events from mouse (or keyboard).


    You can subscribe itself in any event an event? Am I wrong?


    Can someone explain to me this point because I'm really confused!


    Thank you!

    Basically function clicSouris is in itself an event listener and has pEvt as event event object argument.

    When you call .currentTarget pEvt it refers to the current object where the pEvt event is dispatched.

    Event.target and Event.currentTarget will always return the interactive objects where the event is currently being distributed.

  • How can I add an event listener

    I tried to add an event listener for this object:

    < mx:Button id = "calculateButton".
    label =""
    toolTip =""
    styleName = "enable".
    Click = "swapToResultsState ()" "
    rollOverEffect = "{glowButton}".
    = Red "-100" horizontalCenter = "0".
    tabIndex = "85" / >

    by using this code:

    calculateButton.addEventListener (KeyboardEvent.KEY_DOWN, swapToResultsState);

    who gave this error:

    Several markers to this line :-1120: access of undefined property calculateButton. -1120: access
    undefined property swapToResultsState.

    What I am doing wrong?

    Keyboard events spread so you do not need to forward.  Just can't do anything if keyCode is 9

  • Movie Clip event handler block button event handlers

    Hello - really need help!

    I have a clip that contains a button. (i.e. my_mc.my_btn)

    I have a few event handlers for the clip (my_mc.onRollOut, my_mc.onRelease, etc.) and that they are working correctly.

    However, once I added these event handlers to deal with the clip, my breast my quit clip buttons all work together. It's like movie clip managers are overridding the functionality of the button.

    How to use movie clip handlers and my buttons inside continue to work?

    Help!

    You're right, manifestations of the parent are the substitution or fly, the events of the nested children. See this article for ways to deal with this: http://www.senocular.com/flash/tutorials/buttoncapturing/.

    Welcome,
    blemmo

  • Protected by digital rights management and cannot add music from windows media player to windows movie maker

    Original title: I can't add music from my windows media player to my windows movie maker?

    I made a video with windows movie maker and when I tried to add music from my windows media player, I got a message that says that my music is protected by digital rights management and it would'nt I will add the music.i have made a film before, and I could add music.the music in my Media Player is from my own cd collection. then how will I can't add music to my windows movie maker?

    Movie Maker probably only supports unprotected WMA files.

    WMA files will be protected if they were torn apart by WMP with the copy protect music setting (Options of WMP - music Rip) turned on. For an unprotected WMA, you will need to re - rip track, after being assured that this setting is disabled.

Maybe you are looking for