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.
tree data structure

tree data structure

2004-03-11       - By Jim Cheng

 Back
Reply:     1     2  

Millie Niss on eathlink wrote:

> I need a tree data structure (probably augmented to have a linked list of
> its leaves) for a program I am writing to generate poetry.  I am planning to
> write a tree class, but I haven'ty used AS 2.0 much (I have done some C++,
> Java, etc. and a lot of the old Actionscript).  Are there any pitfalls I
> should avoid?  I gather objects are passed by refernce, so if I want a
> reference to the same object (not a cloned object) I can just say
> obj2:Object = obj1.  Can I treat everything as type object and cast it when
> I need to as in C++, or do I need to keep referring to things by  their
> actual class, instead of a parent class that contains all the types I am
> dealing with?

Hmm, with respect to object types in AS 2, you can cast
objects into different types as well as create non-type
checked references.  In practice, AS 2 only cares about
type at compile-time.  At run-time, so long the member
variable or method is there, you're fine.

Here's some tricks you can play:

<code>

  // Create an instance of Foo
  var fooInstance:Foo = new Foo();

  // Cast it into an instance of Bar
  var barInstance:Bar = Bar(foo);

  // This won't work though...
  var barInstance:Bar = foo;

  // This is fine, since k is untyped
  var k = 'some string';
  k = fooInstance;

</code>

Regards,
Jim

=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
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:106630
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
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.