If it's not marked dynamic, you'll always get an exception when you try to
dereference something that's not explicitly declared. If not, you've found a
compiler bug :) However, if you're casting to something that's marked
dynamic (such as Object, or *), it won't. And you can always use
foo["field"] without a compiler warning.

-Josh

On Tue, Jan 6, 2009 at 6:56 AM, cadisella <[email protected]> wrote:

> I've seen some issues like that as well.  We just ported a large Java
> project to Flash and came across all sorts of this stuff.  If you're
> interested at all, there are a series of posts I wrote up at
> http://blog.sharendipity.com/.
>
> I even wrote one about using the Proxy class for implementing a few
> design patterns: http://blog.sharendipity.com/moving-to-flash-part-4.
>  Although, it turns out it's not as efficient as creating an inner
> class, but that poses problems with non-public access as well.  I
> digress...
>
> Glad I could help,
>
> Dale
>
> --- In [email protected], "Nate Beck" <n...@...> wrote:
> >
> > Hey Dale,
> > That makes sense... and thanks for your reply.
> >
> > Making the DateTime class dynamic fixed the issue.
> >
> > Weird thing is that without the dynamic keyword sometimes it will
> compile,
> > and sometimes it won't.
> >
> > Anyways thanks!
> >
> > On Mon, Jan 5, 2009 at 11:40 AM, cadisella <beerm...@...> wrote:
> >
> > >   I've ran into this before. I think that you just want to declare
> your
> > > class as dynamic.
> > >
> > > -Dale
> > >
> > >
> > > --- In [email protected] <flexcoders%40yahoogroups.com>,
> "Nate
> > > Beck" <nate@> wrote:
> > > >
> > > > So this is kind of annoying, I have a proxy Class that I am working
> > > with...
> > > > here is a trimmed down version of it.
> > > >
> > > > -- DateTime.as (Trimmed version) --
> > > >
> > > > package net.natebeck.core
> > > > {
> > > > import com.flexoop.utilities.dateutils.DaylightSavingTimeUS;
> > > > import flash.utils.Proxy;
> > > > import flash.utils.flash_proxy;
> > > > public class DateTime extends Proxy
> > > > {
> > > > // Instance Variables
> > > > protected var _date:Date;
> > > > protected var _timezone:Timezone;
> > > >
> > > > public function DateTime(... args)
> > > > {
> > > > super();
> > > > _date = new Date(args[0]);
> > > > if(args[0] is String)
> > > > setTimezone(parseTimezone(args[0]));
> > > > }
> > > > public function setTimezone(value:Timezone):void
> > > > {
> > > > trace("Setting Timezone: "+value);
> > > > _timezone = value;
> > > > }
> > > > public function getTimezone():Timezone
> > > > {
> > > > trace("Getting Timezone: "+_timezone);
> > > > return _timezone;
> > > > }
> > > > public function getTimezoneOffset():Number
> > > > {
> > > > return _timezone.offset;
> > > > }
> > > > override flash_proxy function callProperty(methodName:*, ... args):*
> > > > {
> > > > var res:*;
> > > > switch (methodName.toString())
> > > > {
> > > > case 'toString':
> > > > res = "foobar";
> > > > break;
> > > > default:
> > > > res = _date[methodName].apply(_date, args);
> > > > break;
> > > > }
> > > > return res;
> > > > }
> > > > override flash_proxy function getProperty(name:*):* {
> > > > trace("getting property: "+name);
> > > > return _date[name];
> > > > }
> > > > override flash_proxy function setProperty(name:*, value:*):void {
> > > > _date[name] = value;
> > > > }
> > > > }
> > > > }
> > > >
> > > > I've written a simple test application to test my DateTime Proxy
> > > class while
> > > > I'm developing.
> > > >
> > > > -- TestDateTime.as --
> > > >
> > > > package
> > > > {
> > > > import flash.display.Sprite;
> > > > import net.natebeck.core.DateTime;
> > > > import net.natebeck.core.Timezone;
> > > > public class TestDateTime extends Sprite
> > > > {
> > > > public function TestDateTime()
> > > > {
> > > > var create:Object = "Jun 17 12:00:00 GMT-0500 2009";
> > > > var oldDate:Date = new Date(create);
> > > > var strDate:DateTime = new DateTime(create);
> > > > trace("old: "+oldDate);
> > > > trace("new: "+strDate);
> > > >
> > > > strDate.getTimezone();
> > > > strDate.setTimezone(Timezone.PST);
> > > > strDate.getTimezone();
> > > > trace(strDate.toString());
> > > > }
> > > > }
> > > > }
> > > >
> > > > When trying to compile using FlexBuilder I get this error.
> > > >
> > > > 1061: Call to a possibly undefined method toString through a
> > > reference with
> > > > static type net.natebeck.core:DateTime.
> > > >
> > > > Well that's dumb... the whole reason I'm using the Proxy class is so
> > > I don't
> > > > have to re-write every method within my class.
> > > >
> > > > Am I missing something?
> > > >
> > > > --
> > > >
> > > > Cheers,
> > > > Nate
> > > > ----------------------------------------
> > > > http://blog.natebeck.net
> > > >
> > >
> > >
> > >
> >
> >
> >
> > --
> >
> > Cheers,
> > Nate
> > ----------------------------------------
> > http://blog.natebeck.net
> >
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location:
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives:
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups
> Links
>
>
>
>


-- 
"Therefore, send not to know For whom the bell tolls. It tolls for thee."

Like the cut of my jib? Check out my Flex blog!

:: Josh 'G-Funk' McDonald
:: 0437 221 380 :: [email protected]
:: http://flex.joshmcdonald.info/
:: http://twitter.com/sophistifunk

Reply via email to