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.
Array property of MoveClip subclass problem

Array property of MoveClip subclass problem

2004-03-12       - By Pranav Verma

 Back
Reply:     1     2     3     4  

Hi Ingo,
check this!

class testClass extends MovieClip {    
   // properties:
    var test:Array = new Array();    
   // constructor:
   function testClass() {
  test=[];
      test.push("hi");
      onRollOver = function(){trace(test)};
   }    
}
Now EXPLANATION...

I am not an expert with other OOP languages but as far as AS is concern ,
multiple instances of an Array object always always refer to one array only.
so...

a= [];
b=[];
b =a;
b.push("junk");

this will add the "junk" in array 'b'.... array 'b' will be blank, ya if you
talk of Number string then it's ok . the moment you created a new var.. new
reference is created.


so in case of array u need to define the array inside the constructor so
that the flash compiler will create diff. refrence for each array objects.
otherwise all array object will refer to one ref only...( thats why in ur
example the array was appending itself on each push )

I hope it all make sense.... please revert back with queries if any.

HTH,
Pranav





> -- --Original Message-- --
> From: Ingo Weiss [mailto:ingo01@(protected)]
> Sent: Friday, March 12, 2004 11:42 AM
> To: flashcoders@(protected)
> Subject: [Flashcoders] Array property of MoveClip subclass problem
>
>
> I am having a strange problem that I finally narrowed down to
> this:
>
> In a movieClip subclass, I have a property "test" of type Array:
>
>
> class testClass extends MovieClip {
>    
>     // properties:
>     var test:Array = new Array();
>    
>     // constructor:
>     function testClass() {
>         test.push("hi");
>         onRollOver = function(){trace(test)};
>     }
>    
> }
>
>
>
> Now if I place 3 instances of the clip on the stage, first of all
> "test" doesn't show up in the Debugger's "variables" pane (why?).
> Then, I would expect the "test" of each instance to have one
> member, "hi". Instead, they have 3 (one for each instance, ["hi",
> "hi", "hi"])? it's as if the instances would share one property
> "test". Why is that?
>
> Thanks for any help!!
> Ingo
>
> =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
> -- ------
> 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:106718
> =-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---
> -- ------
> To unsubscribe send a blank e-mail to:
> Normal Mode: flashcoders-unsubscribe@(protected)
> Digest Mode: flashcoders-digest-unsubscrive@(protected)
>



****************************************************************************
This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged
information. If you are not the intended recipient, please contact the
sender by reply e-mail and destroy all copies of the original message. Any
unauthorised review, use, disclosure, dissemination, forwarding, printing or
copying of this email or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful.
Visit us @ http://www.masconit.com
****************************************************************************




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