Ah, thanks. The event handler containing the conditional was being called 
twice, I had an unnecessary dispatchEvent(e) in another class.

PS: I replaced the actual conditional with (1 == 1) when simplifying the code 
to see where what was going wrong, ha. It actually checks to see if at least 
five seconds of a video have played.

_ _ _
Erik Mattheis
Senior Web Developer
Minneapolis
T  952 346 6610
C 612 377 2272

Weber Shandwick
Advocacy starts here.

PRWeek Global Agency Report Card 2009 - Gold Medal Winner
The Holmes Report Global Agency of the Year
PR News Agency of the Year


-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Merrill, Jason
Sent: Tuesday, May 04, 2010 2:39 PM
To: Flash Coders List
Subject: RE: [Flashcoders] RE: Timer object created twice in class

_tracker is not null - so you must be creating it somewhere else, or the below 
code has already run.


Jason Merrill 

Bank of  America  Global Learning 
Learning & Performance Solutions

Join the Bank of America Flash Platform Community  and visit our Instructional 
Technology Design Blog
(note: these are for Bank of America employees only)






-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Mattheis, Erik 
(MIN - WSW)
Sent: Tuesday, May 04, 2010 3:33 PM
To: Flash Coders List
Subject: [Flashcoders] RE: Timer object created twice in class

Figured out part of it, but don't understand what I figured out - "fixed" with -


if (_tracker == null) {
 _tracker = new Tracker(_videoScreen);
}
else {
_tracker.init();
}

There's no call to init() in my constructor, yet it's being called. How is this 
happening?

_ _ _
Erik Mattheis
Senior Web Developer
Minneapolis
T  952 346 6610
C 612 377 2272

Weber Shandwick
Advocacy starts here.

PRWeek Global Agency Report Card 2009 - Gold Medal Winner The Holmes Report 
Global Agency of the Year PR News Agency of the Year

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Mattheis, Erik 
(MIN - WSW)
Sent: Tuesday, May 04, 2010 1:59 PM
To: Flash Coders List
Subject: [Flashcoders] Timer object created twice in class

Here's a snippit and a timeline version of it - when I run it on the timeline, 
it works as expected, but when I run it within my class it acts as though there 
are two instances of the _timer object.

On the timeline, it works as expected, tracing,

1 1
True

But when I have it inside my class, it traces,

1 0
false
1 1
True

What am I not seeing or understanding here? Thanks..

//********  Version on timeline:

var _timer:Timer;

function init() {
 _timer = new Timer(250, 0);
 _timer.addEventListener(TimerEvent.TIMER, checkPlaying);  _timer.start(); }

function checkPlaying(e:TimerEvent) : void {  if (1 == 1) {
  e.target.stop();
  trace(e.target.currentCount, _timer.currentCount);
  trace(e.target == _timer);
 }
}

init();

//******** Version in class:

public function Tracker(video) {
 _video = video;
}

public function init() {
 _timer = new Timer(250, 0);
 _timer.addEventListener(TimerEvent.TIMER, checkPlaying);  _timer.start(); }

function checkPlaying(e:TimerEvent) : void  if (1 == 1) {
  e.target.stop();
  trace(e.target.currentCount, _timer.currentCount);
  trace(e.target == _timer);
 }
}

I'm instantiating it from another class like this:

if (_tracker == null) {
 _tracker = new Tracker(_videoScreen);
}
_tracker.init();
_ _ _
Erik Mattheis
Senior Web Developer
Minneapolis
T  952 346 6610
C 612 377 2272

Weber Shandwick
Advocacy starts here.

PRWeek Global Agency Report Card 2009 - Gold Medal Winner The Holmes Report 
Global Agency of the Year PR News Agency of the Year

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to