Papervision Event Listener Idea

0 min read 115 words

The problem:
While working on a Papervision3D Flash Project I had a problem where a back button that sits above the 3d canvas and acts as a main navigational item was required to change Events according to where the site was in 3d space at the time.

The solution:
Everytime I’m about to add a new EventListener to the back button movieclip I call the function “delBB()” and then add my event listener using addBB(with the event here).

It seems to work correctly and is a faster way of working.

var currentBackListener = null;
function addBB(whatever) {
back_mc.addEventListener(MouseEvent.CLICK,whatever);
currentBackListener = whatever;
}
function delBB() {
if (currentBackListener!=null) back_mc.removeEventListener(MouseEvent.CLICK,currentBackListener);
currentBackListener = null;
}

Usage:

delBB();
addBB(CLOSE_OBJECT_CLICK_MC);
Andrew
Andrew

Andrew is a visionary software engineer and DevOps expert with a proven track record of delivering cutting-edge solutions that drive innovation at Ataiva.com. As a leader on numerous high-profile projects, Andrew brings his exceptional technical expertise and collaborative leadership skills to the table, fostering a culture of agility and excellence within the team. With a passion for architecting scalable systems, automating workflows, and empowering teams, Andrew is a sought-after authority in the field of software development and DevOps.

Tags