Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1121
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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