Highlighted

TypeError: Error #2007: Parameter listener must be non-null.

New Here ,
Apr 24, 2011

Copy link to clipboard

Copied

Here is my code:

// Click Section
var nextSection;
var sectionName;

btnHome.addEventListener(MouseEvent.CLICK, fn_NextSection("home"));
btnAbout.addEventListener(MouseEvent.CLICK, fn_NextSection("about"));
btnProjects.addEventListener(MouseEvent.CLICK, fn_NextSection("projects"));
btnContact.addEventListener(MouseEvent.CLICK, fn_NextSection("contact"));
function fn_NextSection(sectionName:String) {
nextSection = sectionName;
play();
}

This is the error:

TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at player_fla::MainTimeline/frame361()

You have to supply just function name. Parameters passing is not allowed:

btnHome.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnAbout.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnProjects.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnContact.addEventListener(MouseEvent.CLICK, fn_NextSection);

And listeners accept only one parameter and dattype - Event:

function fn_NextSection(e:MouseEvent):void

Topics

ActionScript

Views

5.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

TypeError: Error #2007: Parameter listener must be non-null.

New Here ,
Apr 24, 2011

Copy link to clipboard

Copied

Here is my code:

// Click Section
var nextSection;
var sectionName;

btnHome.addEventListener(MouseEvent.CLICK, fn_NextSection("home"));
btnAbout.addEventListener(MouseEvent.CLICK, fn_NextSection("about"));
btnProjects.addEventListener(MouseEvent.CLICK, fn_NextSection("projects"));
btnContact.addEventListener(MouseEvent.CLICK, fn_NextSection("contact"));
function fn_NextSection(sectionName:String) {
nextSection = sectionName;
play();
}

This is the error:

TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at player_fla::MainTimeline/frame361()

You have to supply just function name. Parameters passing is not allowed:

btnHome.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnAbout.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnProjects.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnContact.addEventListener(MouseEvent.CLICK, fn_NextSection);

And listeners accept only one parameter and dattype - Event:

function fn_NextSection(e:MouseEvent):void

Topics

ActionScript

Views

5.4K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
LEGEND ,
Apr 24, 2011

Copy link to clipboard

Copied

You have to supply just function name. Parameters passing is not allowed:

btnHome.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnAbout.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnProjects.addEventListener(MouseEvent.CLICK, fn_NextSection);
btnContact.addEventListener(MouseEvent.CLICK, fn_NextSection);

And listeners accept only one parameter and dattype - Event:

function fn_NextSection(e:MouseEvent):void

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Apr 02, 2018

Copy link to clipboard

Copied

Hi Andrei1,

what to do if parameter passing is necessary?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
LEGEND ,
Apr 02, 2018

Copy link to clipboard

Copied

What parameter would be necessary to pass to the event listener function - it only needs to know that the interaction occured?    You should be able to use the event listener function to call some other function and pass whatever parameter you need to there.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...