• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1130
  • Last Modified:

Calling a function from inside a switch gives error

Folks
I am tring to call the playv2 function from inside the switch(code below) all runs fine but uncommenting //playv2(event:MouseEvent); gives me a 1084:Syntax error: Expecting right paren before colon. Driving me nuts any suggestions greatly appreciated ! Please bear in mind Im a novice learner !!!



var myReturnv:returnv = new returnv();
myReturnv.addEventListener(MouseEvent.CLICK, removeVidAndReturn);

/*var to hold the video name*/
var currentVidName:String


/*Put video on stage*/
function playv2(event:MouseEvent) {
var myVideo:Video = new Video(320, 276);
addChild(myVideo);
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
myVideo.attachNetStream(ns);
ns.play(currentVidName);
addReturnBtn();
}

/*Add AND position the return to map button*/
function addReturnBtn() {
addChild(myReturnv);
myReturnv.x=100;
myReturnv.y=300;

}


/******************The switch**************/

switch(theBtn){
case oneBtn:
//button one actions;

trace("pushed1");
//addReturnBtn();
break;

case twoBtn:
//button two actions;
trace("pushed2");
currentVidName="view2.flv";
//playv2(event:MouseEvent);
break;

case threeBtn:
//button three actions;
trace("pushed3");
break;
}
}
0
mrmad1966
Asked:
mrmad1966
1 Solution
 
asavahCommented:
playv2(event.MouseEvent);

Open in new window


its a DOT not a COLON
0
 
mrmad1966Author Commented:
Thanks, changed as you suggested but now get 1120:Access of undefined property event

Should have mentioned when checking the syntax, all checks out OK . The 1120 error only occurs on publishing the file.
0
 
RoonaanCommented:
Why not just use 'event'? I don't think there should be a type definition, when calling a method, just only when you define it.

Regards,

-r-
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
mrmad1966Author Commented:
Same error !
0
 
blue-genieCommented:
I'm making the assumption that your switch code exists in a function which you call when a button (s) is clicked - you don't use the button click event in your playv2 function so you can change your function to not have any parameters

function playv2():void
{//etc

and just call it with playv2();
0
 
mrmad1966Author Commented:
blue-genie
You are correct in your assumption however calling it with playv2() gives me:
1136: Incorrect number of arguments. Expected 1

Sorry !!

:-(
0
 
blue-genieCommented:
YOu need to remove the arguments from the function

function playv2():void
{//etc

rather than

function playv2(event:MouseEvent) {
0
 
mrmad1966Author Commented:
Thank you v much !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now