?
Solved

Statement must appear within on handler????

Posted on 2005-03-30
3
Medium Priority
?
15,757 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
  • 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses
Course of the Month12 days, 19 hours left to enroll

578 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