views:

163

answers:

2

How do I resolve the error of duplicate variable definitions? There has to be separate namespaces and use for each definition, but I'm just not seeing it.

CODE

I didn't write this, but I've been trying to unpackage it and change the classes and seem to have broken it. I want to use this for time-scaling the playback of my movies.There's cool math in here for time-scaling.

//time-scaling script
import flash.display.*; 
import flash.events.Event.*;

var _time_scale:Number = .25; 
var _frames_elapsed:int = 0; 
var _clip:MovieClip; 

function Main():void { 
            _clip = new SomeClip; 
            addEventListener(Event.ENTER_FRAME, handleEnterFrame);

//integer?? 
function handleEnterFrame(e:Event):void { 
            _frames_elapsed ++; 
}
            // we multiply the "real" time with our timescale to get the scaled time 
            // we also need to make sure we give an integer as a parameter, so we use Math.round() to round the value off 
            _clip.gotoAndStop(Math.round(_clip.totalFrames * _frames_elapsed * _time_scale )); 
}

var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);
function timerListener (e:TimerEvent):void{
ball1.rotationY += 5;/////////replace function///////////
}
myTimer.start();

ERRORS

**3596**
Warning: Duplicate variable definition.

**1151**
A conflict exists with definition _clip in namespace internal

NOTES

integers, non nested loop

A: 

'_clip' is a reserved key word, you'll have to use something else.

Tyler Egeto
I see, that that makes sense!
VideoDnd
_clip does conflict with an existing definition in animatorFactory. Thanks
VideoDnd
+1  A: 

It's because you are missing the ending "}" of the constructor, after this line:

addEventListener(Event.ENTER_FRAME, handleEnterFrame);

And the two following lines should probably be in your constructor, not just in the class declaration:

var myTimer:Timer = new Timer(10);
myTimer.addEventListener(TimerEvent.TIMER, timerListener);

If you are using the Timer and TimerEvent classes, you should import them:

import flash.utils.Timer;
import flash.events.TimerEvent;

Also, you don't need the .* at the end of the Event import.

Another "also". You should have access modifiers on your members ie. vars, and functions. So you should really say:

private var _clip:MovieClip;

It sounds to me like you need to look into the basics of AS3. Here is a really good starting point: http://www.actionscript.org/resources/articles/611/1/Getting-started-with-Actionscript-3/Page1.html

TandemAdam