?
Solved

Statement must appear within on handler????

Posted on 2005-03-30
3
Medium Priority
?
15,674 Views
Last Modified: 2011-08-18
I have the following code attached to a button, but I get this error when I publish it:

Statement must appear within on handler
     this.onRelease = function(){
////////////////////////////////////////


this.onRelease = function(){
//create the value object to pass to analytics facade
      var valueObj = new Object();
trace("entering call");
//create the callback object
      var callback=new Object();
      callback.scope = this;
      callback.func = function(){
            trace("onGetURL function worked");
}

valObj.s_pageName = "My : Downloads";
valObj.s_event = "navigation selected";
_level0.myAnalyticsFacade.registerView(valObj, callback);
}

on (release) {
      gotoAndPlay("trailer");
}
0
Comment
Question by:894359
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 18

Accepted Solution

by:
Billystyx earned 2000 total points
ID: 13666589
buttons use this method
on(release){
//code here
}
on(rollOver){
//code here
}
etc
on the clip itself, like an mc uses
onClipEvent(enterFrame){
}
on the clip itself
replace your function header with
on(release){
//create the value object to pass to analytics facade
     var valueObj = new Object();
trace("entering call");
//create the callback object
     var callback=new Object();
     callback.scope = this;
     callback.func = function(){
          trace("onGetURL function worked");
}

valObj.s_pageName = "My : Downloads";
valObj.s_event = "navigation selected";
_level0.myAnalyticsFacade.registerView(valObj, callback);
}

and you won't get that error

Billystyx
0
 

Author Comment

by:894359
ID: 13667348
So I did this:

///////
on (release) {
      gotoAndPlay("trailer");
      //create the value object to pass to analytics facade
      var valueObj = new Object();
      trace("entering call");
      //create the callback object
      var callback=new Object();
      callback.scope = this;
      callback.func = function(){
            trace("onGetURL function worked");
      }

valObj.s_pageName = "My : Downloads";
valObj.s_event = "navigation selected";
_level0.myAnalyticsFacade.registerView(valObj, callback);
}

/////////////but what if I want to do it on a getURL??? The do I do this???

this.onGetURL = function(){
0
 
LVL 18

Expert Comment

by:Billystyx
ID: 13669141
You must give the clip an instance name (I think you may have already done that - if not there is a field in properties when you click onthe clip that is greyed out and says 'instancename', you click in that field and type a name for it, like myMov or something), and put the code on the timeline, not on the clip (the original code)).
But I'm not sure - I think that myMov.onRelease=function(){
}
functions are reserved for movieclips and the on(release) method for buttons. So you may need to change your button to a mc to do this. Sorry I can't test this right now - not time before going out:)
In any case it is a good rule of thumb to work by - making a mc work like a button use a function, for buttons stick to the on() method.

Billystyx
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question