Mailing List
Home
Forum Home
Flash Pro
Subjects
Firework Effect
setInterval bug identified and fixed
setInterval bug identified and fixed
ScrollPane component doesn 't auto update
Help: MX 2004 How to script a print button to print the entire sli
Event Dispatcher between classes
memory management removeMovieClip /
MX2004 Dataset itemClassName
Order of events per frame
XML to Object help
Textfield prototype question
Flash and QuickTime VR
Reading and displaying RSS feeds in Flash MX
Flash MX 2004 Sucks
AW: [Flashcoders] Switch/Case vs If/else
AW: [Flashcoders] Switch/Case vs If/else
Flash Interface with 10mb xml file
Web Service Results
Listener Object 's best practice
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
Variable scope in AS2

Variable scope in AS2

2004-03-11       - By Liam Egan

 Back
Reply:     1     2     3     4     5     6  

That makes sense to me, try this instead;

  private function doSomething() {
    trace("2 _"+someNumber);
    trace("2.1 _"+someOtherNumber);
    var objParent=this;
    var interval = setInterval(function () {
      trace("3 _"+ objParent.someNumber);
      trace("3.1 _"+ objParent.someOtherNumber);
      clearInterval(interval);
    }, 100);
  }

-- --Original Message-- --
From: janis@(protected) [mailto:janis@(protected)]
Sent: Friday, March 12, 2004 10:01 AM
To: flashcoders@(protected)
Subject: [Flashcoders] Variable scope in AS2

Just found IMO veirdnes while working with AS2:
class someClass {
  private var someNumber:Number = 1;
  public var someOtherNumber:Number = 2;
  function someClass() {
    trace("1 _"+someNumber);
    trace("1.1 _"+someOtherNumber);
    doSomething();
  }
  private function doSomething() {
    trace("2 _"+someNumber);
    trace("2.1 _"+someOtherNumber);
    var interval = setInterval(function () {
      trace("3 _"+someNumber);
      trace("3.1 _"+someOtherNumber);
      clearInterval(interval);
    }, 100);
  }
}
will return
1 _1
1.1 _2
2 _1
2.1 _2
3 _undefined
3.1 _undefined

Seems that second level functions, intervals(wich are same actually)
cannt
see class body variables and it doesnt depend on variable type.
I havent spend mutch time on AS2 so I can imagine this been
misunderstanding bcouse of lack of AS2 expierience ... or this is a way
it
should be?


Janis


=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106693
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)


=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:106695
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)




Earn $52 per hosting referral at Lunarpages.