[mtasc] Question

Brett Errington brett at opensearch.com
Fri Nov 5 07:59:37 CET 2004


Yeah ok maybe it does, but then again I don't think this is good practice

In this situation I think it would be more appropriate to have the following
because you are not actually modifying the content mc directly when you set
the property. From an API p.o.v I think your current way would be
misleading.

         public function get content():MovieClip
         {
                 var userContent_mc:MovieClip = _content_mc.userContent_mc;

                 return userContent_mc ? userContent_mc : _content_mc;
         };

         public function setNewContent(content_str:String):Void
         {
                 _content_mc.attachMovie(content_str, "userContent_mc", 0);

                 update();
         };

P.S. just as a helpful note: in your getter you should check that
userContent_mc != undefined rather than with the syntax you've currently
got. I've found in the past that ActionScript doesn't always work this way
(like JavaScript).

- Brett 

-----Original Message-----
From: mtasc-bounces at lists.motion-twin.com
[mailto:mtasc-bounces at lists.motion-twin.com] On Behalf Of EECOLOR
Sent: Friday, 5 November 2004 5:12 AM
To: MotionTwin ActionScript2 Compiler List
Subject: Re: [mtasc] Question

 From your documentation:

>with MTASC, getter return type and setter type parameter are required to 
>be same (if specified).


This forms a problem when it comes to my scrollPane component. The code is 
as folows:

         public function get content():MovieClip
         {
                 var userContent_mc:MovieClip = _content_mc.userContent_mc;

                 return userContent_mc ? userContent_mc : _content_mc;
         };

         public function set content(content_str:String):Void
         {
                 _content_mc.attachMovie(content_str, "userContent_mc", 0);

                 update();
         };


Greetz Erik




--
MTASC : no more coffee break while compiling




More information about the mtasc mailing list