Jump to content

JavaScript function collision?


pctechtv

Recommended Posts

I have an Adobe Animate CC project that I have changed to make it better. It is problematic because Adobe has not done a good job of generating code that can run simultaneously on a page. I manipulated the code to be able to do this. Understanding a good amount of JavaScript but not everything I can get this to work. The Adobe Animate CC program generates code that is native Create JS. The local script connects to Create JS to make things animate. When I run the code without a JavaScript timer I think that both functions try to fire at the same time. At this point only, one animation works and shows up. Throwing them into a set Interval fixes this because they are not starting at the same time. I am using jQuery to load and run them on my page. I have seen some jQuery functions, that can run two functions simultaneously. I can’t remember which one.  Does anybody know of way jQuery can call two functions in a way where they do not collide? I am interested in knowing how can get a function to fire and not collide in theory also. So any help for that is appreciated. But I would like to know how jQuery would handle functions totaling two, three, four etc. Thanks
Doberman-German.zip
 
Link to comment
Share on other sites

If you can paste the relevant code directly on the forum that would be better than asking people to download a zip file.

If you want to actually run functions simultaneously, I would imagine that using setTimeout with a timeout of 0 would create a child thread to run each one.  I don't know what you're thinking about in jQuery, but jQuery does use method chaining quite a bit.  That's not simultaneous though, that's sequential.

Link to comment
Share on other sites

Is the $.when() function what you are looking for?  This function provides a way to execute callback functions based on zero or more Thenable objects. These latter are usually Deferred objects that represent asynchronous events.

Roddy

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...