Impossible to get a function to stop

Hello world

I am currently working on a flash-based Web site project, and I experience a problem with a function without stopping to run... I have searched a lot on the internet, but could not come up with an answer.



There are several buttons on the page with a click MouseEvent and some arguments. And here's one, which refers to the button "PortfolioButtonHereandthere":



var newHereandthereContainer:MovieClip = new HereandthereContainer();var myfunction1;
PortfolioButtonHereandthere.addEventListener(MouseEvent.CLICK, myfunction1 = function(e:MouseEvent){load3D(e, newHereandthereContainer, 1000, 350, 500, myfunction1);});


The load3D function calls a movieclip in the library and the place on the stage:



function load3D(e:Event, containername:MovieClip, Xposition:Number, Yposition:Number, Zposition:Number, myfunction):void{
    
    if (containernameprevious != null) {
        buttonpressed.addEventListener(MouseEvent.CLICK, mypreviousfunction);
// enables again the previous clicked button to be clicked again
        this.removeChild(containernameprevious);
// removes the previous movieclip present on the stage
    }
    else {
    }
    
    this.addChild(containername);
// adds the movieclip on the stage
    
    containername.x = 1000;
    containername.y = 300;
    containername.z = 500;
    containername.alpha = .5;
// places the movieclip
    
    mypreviousfunction = myfunction;
    buttonpressed = e.target;
    containernameprevious = containername;
    
    this.addEventListener(Event.ENTER_FRAME, function(){rotate3D(containernameprevious, mypreviousfunction, buttonpressed);});
// calls a function to rotate the movieclip
    
}


At the end of the function, it calls another function (rotate3D) that rotates the movieclip:



function rotate3D(containername:MovieClip, mypreviousfunction, buttonpressed):void {
        
        buttonpressed.removeEventListener(MouseEvent.CLICK, mypreviousfunction);
// disables the button clicked to be clicked




        containername.rotationX += 1;
        containername.rotationY += 1;
// rotates the movieclip continuously
    
}




So basically that my button is a movieclip appear on the scene through the load3D function, then it rotates through rotate3D. Then if you click on another button, the movieclip disappears and is replaced by another.



Everything works fine, except that the rotation function continues to work away after clicking another button, even if the movieclip has been deleted, which means that if you click again on the same button, two functions will be executed at the same time and turn my movieclip twice faster... Of course, whenever you click the button again, it becomes more rapid, which is annoying.



If anyone knows of a way that I could stop my rotate3D() of the service running when I click on a button? I tried to use the return, break and stop() in many ways, but nothing seemed to work... I tried with a variable, but could not figure out where to put them and what to do with...



I searched a lot and couldn't find anything, so your help would be greatly appreciated! I can also provide more information if needed of course.





Thank you in advance.





Julien.

I'm guessing that your definition of inline function is the root of your problem because I see that you are trying to refer to them outside where they are defined.  Chances are that they do not exist here.  So the first thing you need to do is break this habit and start coding correctly.

Below is an interpretation of your code with the handler of properly defined functions and an adjustment or two.  I added a second point to test what I could do to your scenario.  It doesn't seem to be a change of the rotational speed.

And just in case you misunderstand things.  The way it is written that you have shown, the objects are created once and reused.  They are not created in the load3D function - it just adds it to the display list (puts them on the scene).  The 'var. new.."lines you have is where they will be created.

// these are defined outside so that they can be available to multiple functions
var buttonpressed;
var containernameprevious:MovieClip;
var mypreviousfunction:Function;

 var newHereandthereContainer:MovieClip = new HereandthereContainer();
PortfolioButtonHereandthere.addEventListener(MouseEvent.CLICK, myfunction1);

function myfunction1(e:MouseEvent):void {
 load3D(e, newHereandthereContainer, 100, 150, 500, "myfunction1"); // I changed the function name to a String
}

var newHereContainer:MovieClip = new HereContainer();
OtherButton.addEventListener(MouseEvent.CLICK, myfunction2);

function myfunction2(e:MouseEvent):void {
 load3D(e, newHereContainer, 100, 150, 500, "myfunction2");
}

function load3D(e:Event, containername:MovieClip, Xposition:Number, Yposition:Number, Zposition:Number, myfunction):void{  

     if (this.hasEventListener(Event.ENTER_FRAME)) {
         this.removeEventListener(Event.ENTER_FRAME, rotate3D);
     }
     if (containernameprevious != null) {
         buttonpressed.addEventListener(MouseEvent.CLICK, mypreviousfunction);
         this.removeChild(containernameprevious);
     }
     this.addChild(containername);
     containername.x = 100;
     containername.y = 100;
     containername.z = 500;
     containername.alpha = .5;
     containernameprevious = containername;
     mypreviousfunction = this[myfunction];  // I changed this to use the string to define the function using bracket notation
     buttonpressed = e.currentTarget; // I changed this to be sure it points to the object and not something inside it
     this.addEventListener(Event.ENTER_FRAME, rotate3D);
}

function rotate3D(evt:Event):void {

     buttonpressed.removeEventListener(MouseEvent.CLICK, mypreviousfunction);
     containernameprevious.rotationX += 1;
     containernameprevious.rotationY += 1;
}

Tags: Adobe Animate

Similar Questions

  • Impossible to get mouse events to stop the drip

    Hi folks - I'm sure it's simple, but I just can't see IT... and you would appreciate the help.

    I have a lot of buttons on the top active movie clip (that is to say, it meets the mouse clicks). When I click on one of the buttons, as well as the script for the button is enabled, running the script below on the video too...

    How to stop what is happening? I know there is a function in AS3, but I'm only able to use AS1 or 2 here...

    I'm sure it's something simple, but I can't see it--I tried to put an another movieclip around the buttons and a dummy handler in that, but it makes no difference...

    Thanks for any help.
    theWoosh

    mouseUp and mouseDown are global events (in as2) and trigger no matter the location of the mouse (as long as it is during the stage).

    to raise a particular movieclip or button, use onRelease.

    However, the object will be intercept mouse so events (if your movieclip isn't the object that receives mouse events), you may need to use a mouseUp and a hitTest() to detect if mouseUp occurred while your movieclip.

  • Two-node Rac (11204) Cluster node 1 has failed to stop with error: impossible to get in touch with the loan of cluster service. duty to force stop

    Newly build Production environment (don't use it yet)

    OS: Linux redhat 64-bit 2.6.18

    Cluster version: 11.2.0.4

    This environment clusterware installed last December, we are trying to install oracle RDBMS, so try to first stop the crs.  However on node 1, the v$ asm_diskgroup shows nothing under total_mb /free_mb on diskgroup OCR.  and stop the crs shows: impossible to get in touch with the loan of cluster service.

    Alerts cluster log shows below:

    2014-03-25 03:50:01.429:

    [crsd (8608)] CRS-1013: the location of the OCR in ASM disk group is inaccessible. Details in u00/app/11.2.0.4/grid/log/oprd100/crsd/crsd.log.

    2014-03-25 03:50:01.433:

    [crsd (8608)] CRS - 0804:Cluster Ready Service interrupted due to the Oracle Cluster registry error [PROC-26: error when accessing the physical storage]

    ]. Details at (: CRSD00111 :) in u01/app/11.2.0.4/grid/log/orpd100/crsd/crsd.log.)

    2014-03-25 03:50:02.123:

    [ohasd (12490)] CRS - 2765:Resource 'ora.crsd' failed on the server "orpd100".

    2014-03-25 03:50:03.407:

    [crsd (8623)] CRS-1013: the location of the OCR in ASM disk group is inaccessible. Details in u01/app/11.2.0.4/grid/log/orpd100/crsd/crsd.log.

    2014-03-25 03:50:03.411:

    [crsd (8623)] CRS - 0804:Cluster Ready Service interrupted due to the Oracle Cluster registry error [PROC-26: error when accessing the physical storage]

    The NEWSPAPER of the ASM alerts:

    Wed Mar 25 03:21:49 2014

    WARNING: Waited 15 seconds IO to write to the disk of PST 1 in Group 1.

    WARNING: Waited 15 seconds to write IO to disk of PST 2 in Group 1.

    WARNING: Waited 15 seconds IO to write to the disk of PST 1 in Group 1.

    WARNING: Waited 15 seconds to write IO to disk of PST 2 in Group 1.

    Wed Mar 25 03:21:49 2014

    NOTE: process _b000_ + asm1 initiating (21071) 1.1807368888 disk offline (OCR_0681_2EF4) with mask 0x7e in Group 1

    NOTE: process _b000_ + asm1 initiating (21071) 2.1807368889 disk offline (OCR_0681_2EF5) with mask 0x7e in Group 1

    NOTE: check PST: grp = 1

    GMON seeking ways of disc for Group 1 to 5 pid 27, DiSo 21071

    ERROR: read no quorum within Group: required 2 found 1 records

    NOTE: audit PST grp 1 fact.

    NOTE: start the PST update: grp = 1, dsk = 1/0x6bba42b8, mask is 0x6a, op = clear

    NOTE: start the PST update: grp = 1, = 2/0x6bba42b9 dsk, mask is 0x6a, op = clear

    GMON update modes of disk for the Group 1 to 6 for 27, DiSo 21071 pid

    ERROR: read no quorum within Group: required 2 found 1 records

    Wed Mar 25 03:21:49 2014

    NOTE: disassembly of the cache (not clean) Group 1/0x35AAB27B (OCR_DATA)

    WARNING: For disk offline OCR_0681_2EF4 0x7f mode failed.

    2 node rac cluster is normal.  We were able to stop the crs without force.

    What should I look at to understand what is happening here?

    Thanks to adavnace.

    WARNING: For disk offline OCR_0681_2EF5 0x7f mode failed.

    NOTE: e-mail CKPT suspend pins Unix process pid: 21073, image:

    No default value is 1 M

  • Registration for the web function has stopped working in my copy of photoshop elements 12.  I get this message "the operation could not be completed.  The system cannot find the path specified"reset preferences was not fixed.

    Registration for the web function has stopped working in my copy of photoshop elements 12.  I get this message "the operation could not be completed.  The system cannot find the path specified"reset preferences was not fixed.

    My os is windows 7.  elements of 12 worked fine for several months and then save for web stopped working

  • the gadgets function has stopped working properly...

    the gadgets function has stopped working properly... those I had put a few weeks ago are still on the desktop... but it won't let me add, remove or access the Panel command or right-click gadgets... when I right click on the desktop and click gadgets, nothing happens... when I go into Control Panel and click on gadgets nothing happens... the addition of gadgets, uninstall gadgets and restore the gadgets links in the Control Panel does not work... nothing happens when I click on them... the only link that works is the "get more gadgets online"... and I re-download and reinstall a gadget to access the menu gadget... another while TI leaves me not go... What is happening I'm frustrated

    Scanner of CFS on the computer:
    http://support.Microsoft.com/kb/936212

    All the best!

  • How the batch of photos of change in Version 2.0 of Photos... impossible to find the function.

    How the batch of photos of change in Version 2.0 of Photos... impossible to find the function.  If it has been deleted to "improve" the Photo experience?

    Lot, what exactly will change?

    Titles, Descriptions and capture date - Yes.

    Select the images you want to change the title or the description and to set-up the info (command-i) pane.  Enter the title or the description in the appropriate field and he will be assigned to all selected pictures.

    If you want to batch, change the title with sequential use attached many Applescripts provided by users in the Photos for Mac user tips section.

    Batch change/correction of dates is provided by the Image ➙ setting Date and time menu option:

  • Someone else has volume function keys stop working?  If so, I know a fix?

    Sometimes, my function keys stop working.  The small volume box appears and the volume is shown to change but there is no real effect on the volume.  Anyone know a fix for this other than to restart the computer?

    you have speakers connected, secure, powered?

    helmet?

     > System Preferences > Sound

    What is your output on?

  • How can I move the tab bar to the bottom, and how can I get my reload and stop buttons back?

    The new version of Firefox are repositioned my bar tabs at the top and I can't move it to the bottom. I tried everything: config, but browser.tabs.ontop was already set to false - very curious, because this should have resolved my problem in the first place.

    In the new version of Firefox, I can't get my reload and stop buttons back once again.

    Hi narab.

    You can use the classic theme restaurateur to bring all back them again. You can find more details here: https://support.mozilla.org/en-US/kb/how-to-make-new-firefox-look-like-old-firefox

  • Satellite U500-176: Impossible to get an HDMI output to work on television or monitor

    Hello

    I have a new Satellite U500-176 but impossible to get the HDMI to work on a TV or monitor.

    Usually, when the monitor is connected and I press Fn + F5 I get only the 1 option (LCD).
    Occasionally, the HDMI options work but when I select one it goes to the screen and runs successfully for a few seconds then automatically returns.

    Any ideas?

    See you soon,.
    Roy.

    Hello

    Hmm, what operating system are you using?
    Was - this operating system preinstalled by Toshiba?

    Please take a look in the BIOS. There should be HDMI settings. Please check if it is enabled.
    In addition, I would recommend checking the graphics card driver update.

    What version of BIOS you are using the most recent?

  • I no longer get suggested words when composing a message text on my iphone 5.  How to get back to get this function works

    I no longer get suggested words when composing a message text on my iphone 5.  How to get back to get this function works

    Make sure that the text is on. You can do this on the keyboard (if you have several) by pressing and holding down the button to change between them.

    Alternatively you can go to settings > general > keyboard and make sure predictive is turned on (the switch must be green).

    If you see the image below, press the small white bar above the buttons T and Y and slide upward slightly.

  • Encryttion I get "Task Scheduler engine stopped" several times. Is there a way to fix this?

    I get "Task Scheduler engine stopped" several times. Is there a way to fix this?

    have you tried the steps outlined in this thread http://answers.microsoft.com/en-us/windows/forum/windows_vista-windows_programs/task-scheduler-engine-has-stopped-working/042f8325-f07c-41d7-9ff9-49c43ff9e2b0

  • Impossible to get Vista SP2 installed

    Impossible to get SP2 to install on my windows vista 32 bit

    Download the SP2 installation file in a folder on your hard drive, then double-click it to start the installation.

    Windows Server 2008 Service Pack 2 and Windows Vista Service Pack 2-five language standalone (KB948465)
    http://www.Microsoft.com/downloads/en/details.aspx?FamilyId=a4dd31d5-F907-4406-9012-a5c3199ea2b3&displaylang=en

    Service Pack 2 for Windows Server 2008 and Windows Vista
    http://TechNet.Microsoft.com/en-us/Windows/dd262148

    JS
    http://www.PAGESTART.com

    Never be afraid to ask. This forum has some of the best people in the world to help.

  • The mouse graphic error, impossible to get rid of him, until I restart. Loading screen error, video included.

    OK, so here is the thing. I'm a gamer, I play Everquest right now and Im having problems with my computer 'new '. It was bought used, but when we test tried at home to the owner initial, everything worked perfectly. Since then, my husband has reformatted and put on Windows Vista Buisness on it. After a post on the game forums, Kevin helped me to get the PC to stop locking up. Yet, I still have the other problem with the mouse pointer.

    First thing first: computer information!
    Edition of Windows: Windows Vista Business Service Pack 2
    System:
    -Processor: AMD Athlon (TM) 64 X 2 Dual Core Processor 5000 + 2.61 GHz
    -RAM memory (RAM) 3.00 GB
    -System type: 32-bit operating system
    Graphics card: Radeon HD 4850
    Motherboard: nForce 590 SLI

    Next: I am 100% positive that there is no update pending for the operating system. There are things in option that I can install it, but they are not relevant to the problem that I currently have.

    So here's the question:

    (1) for the loading of Windows Vista Business. I see the text channel 0 Slave and in the lower right of my two monitors, both monitors so it is important, there is a rectangle that is 1/2 at the bottom of the screen.
    I included a video of him: [URL = http://tinypic.com/r/jhae14/5] View My video [url]
    (2) sometimes when the games, I see a square box that resembles film developed that appears randomly on the screen.
    Note: I only see the error all in game, because when the PC is on that's what I do. Here is the screenshot [IMG] [line] http://i44.tinypic.com/2evqekg.jpg
    (3) I have experience this behavior in and out of the game, but the screenshots in EQ are easier and faster to make and Vista does not see the problematic mouse pointer when you take a screenshot of it. Sometimes I will be able to tab in and out of what I do and it will go away, othertimes it requires a complete closed system and then it will go away. Here is the screenshot: [IMG] [line] http://i43.tinypic.com/qqswtx.jpg With the image that I just linked, there are three examples of the problem. The upper left corner has the double serrated edge, the other two posted on a character's head to make it easier to see. (Not sure if the 2nd link works or not. List of URL to Tinypic to show errors: http://tinypic.com/r/qqswtx/5)

    These problems don't always cause me down, but there are moments where I feel this graphic glitch, so the computer has locked up. It's incredibly less frequent that another EQ crashing the computer problem, I had. He posted the question here, happens once or twice every two days, when it isn't something I can deal. In the 2nd picture the edge serrated turning into that, you can always click in the right place. One would think that you would use just the tip to click on something, but sometimes this does not work and must continue to go upward or downward a bit to get to what you were tryin to close / open / whatever.

    Thank you for your time!

    Hello Dewifey,

    Thank you for posting.  I checked the other thread just so that I would have a complete understanding of the problem.  I studied him this strongly and I came up with some possible solutions for you.  As seems to be more than a gliche graph, I will propose common fixes first.  The first is to check the site ati.amd.com for updated for your video card drivers.  The second is to check for updates or patches for the game Everquest game.  Now we can get right to my search results.

    The only problem with EQ is really changes to security of XP to Vista.  EQ always assumes that users will run as administrator with full access to all under the directory %ProgramFiles%.  In Vista, even if logged in as an administrator, you don't actually run as administrator.  You must explicitly elevate your rights before becoming administrator (such as right click, run as administrator, or configure the program to run as administrator).  Just put the game to run in compatibility mode for Windows XP Service Pack 2 and run in administrator mode.
    If you forget to do this, the patch cannot connect records and will be silently _ it's short films before leaving.

    This step applies only if you run the game in windowed mode.

    One way to expedite EQ in Vista is to click right on eqgame.exe and on one of the tabs that you can disable "desktop composition" that disables the interface Aero and stop the GUI running on your video card.

    Please let me know if this helps you.

    Zack
    Engineer Microsoft Support answers visit our Microsoft answers feedback Forum and let us know what you think.

  • In Windows Media Player 11 when spend to add songs, how get the list to stop starting at the top?

    With WMP11, when adding pieces of the current reading library, I often change between two tabs. My question is every time I switch back to the library to add more songs, tab how can I get the list to stop starting at the top? I have a number of songs scrolling on there where I left last can be very inconvenient. I remember with an older version when you leave the library, that he would stay where you left it. Yet once, how can I stop the library always start at the top and instead pick up where I left off?

    Thank you very much

    Reinstalling wmp11

  • Help - Tablet Iconia B1 - get messages "Email service stopped because of the weak campaigns"

    Hello

    When switching on my B1 Iconia Tablet I get message "Email service stopped because of the weak campaigns" and "you can delete the unused e-mail or applications to retrieve campaigns."  Also when trying to download a new application, which is not allowing them installed indicating the space of campaigns.

    However, there is much space of campaigns as the shelf a time the built in memory and an extra memory card. Details under settings under campaigns shows:
    Space total 0.98 GB
    Apps (content data & media app) 792 MB

    SD INTERNAL
    12,39 GB total space
    Apps (content data & media app) 332MB
    Photos, video 9.48 MB
    Audio (music, ringtones, podcasts, etc.) 20,00 KB
    Download 7.25 MB
    Available 12,03 GB

    SD EXTERNAL
    29,49 GB total space
    Available 27,00 GB

    As you can see from the above information there are plenty available storage space on the shelf.
    Also I changed nothing with regard to the settings since the Tablet (about 3 months) so it still has factory settings.

    Please can you advice how to fix this problem so that email and download installation restored to the tablet.  I would appreciate it if all instructions to solve the problem can be detailed step by step easy to follow.

    Thank you

    If you go into settings, on the Tablet, which is listed under the device information?

    I think that the main problem you see is that the email app is eager store items in the 'main' part of the files, not the SD card internal or external space.  If you are looking to ~ 200 MB total space, which may be too weak so that it can consider the space of "viable."  (1 GB-800 MB = 200 MB)

    I suggest you move the extra apps, etc. from the main space on the SD storage.

Maybe you are looking for