English 中文(简体)
Got an error 1120 ~ Access of undefined property
原标题:

This is not your typical 1120. I know better than to have buttons/MCs without instance names on the timeline.

Nope, this problem resides in a I timer I built from script I found online. The undefined property is related to the timer class delay I want to implement.

What I m trying to achieve is have the user click the next button, wait 1 sec., then scroll through the next content. I have the code sitting inside a conditional statement to reduce the amount of code.

One thing to note, I am using TweenLite for the transitions, if that makes any difference

Now, the following code will show you the timer only working work one next position. I want to eventually add this to the remaining next position and all the previous positions so that there will be a slight delay when scrolling through the content.

Also, I want to reuse the same code so when the user reaches a particular position, there will be a slight delay and load, and/or, make an image or text visible.

How would I solve my initial problem and then simplify the code to reuse the code throughout the project?

Thanks for the help in advance!

import gs.TweenLite;
import gs.easing.*;

var timer:Timer = new Timer(1500, 1);

next_mc.addEventListener(MouseEvent.CLICK, nextListener);
prev_mc.addEventListener(MouseEvent.CLICK, prevListener);
timer.addEventListener(TimerEvent.TIMER, delay); //I get the error here with "delay" 

prev_mc.visible = false;

function nextListener(event:MouseEvent):void {

 if (this.content_mc.slider_mc.x == 0) {

  function delay(event:TimerEvent):void {
   TweenLite.to(this.content_mc.slider_mc, 1, {x:-923.2, y:0, ease:Quart.easeInOut});
   prev_mc.visible = true;
  }
 } else {
  TweenLite.to(this.content_mc.slider_mc, 1, {x:-1872, y:0, ease:Quart.easeInOut});
  next_mc.visible = false;
 }
}

function prevListener(event:MouseEvent):void {
 if (this.content_mc.slider_mc.x == -1872) {
  TweenLite.to(this.content_mc.slider_mc, 1, {x:-923.2, y:0, ease:Quart.easeInOut});
  next_mc.visible = true;
 } else {
  TweenLite.to(this.content_mc.slider_mc, 1, {x:0, y:0, ease:Quart.easeInOut});
  prev_mc.visible = false;
 }
}

next_mc.buttonMode = true;
prev_mc.buttonMode = true;

timer.start();
问题回答

The problem is that the "delay" function is defined within your nextListener function, so it is not accessible in your timer.addEventListener(TimerEvent.TIMER, delay); code. I think you meant to move the timer.addEventListener(TimerEvent.TIMER, delay) inside of the next button handler.

This is a scoping issue. You are calling the delay function from this line:

timer.addEventListener(TimerEvent.TIMER, delay); //I get the error here with "delay" 

but the delay function is defined in another function, nextListener.

That means that this line cannot see the delay function. To fix this issue, just put this line inside the nextListener function:

function nextListener(event:MouseEvent):void {
// newly added ---v
timer.addEventListener(TimerEvent.TIMER, delay); //I get the error here with "delay" 
// rest of code
}




相关问题
Disable button tooltip in AS3

I want to disable the tooltip on certain buttons. The tooltip manager seems to be an all or nothing solution. Is it possible to disable the tooltip for just one or two buttons?

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

Red5 Security Tutorial

I am looking for a step by step tutorial on securing Red5 from intrusion. This seems to be a question that comes up alot in a google search, but is never really answered in a way that makes sense to ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

visible property of DisplayObject

For example I have a hierarchy of movie clips. mc1 is a child of mc, and mc2 is a child of mc1. Turns out that when I set mc1.visible = false; mc2.visible stays true. Is that supposed to happen?...

热门标签