Re: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread Dave Watts
> Refersh my memory.  What was the name of that AS3 class method to get a class 
> definition
> from a string? Something like getObjectByDefinition("MyClass") or something 
> like that, but that's not it.
> Our proxy server is down and I can't Google it, and the help docs are no help.
>
> Basically, I'm tring to remember the AS3 method to dynamically instantiate a 
> class from a string definition - i.e.
>
> var ClassDefinition:Class = getClassByDefinition("Apple");
> var newClassInstance:* = new ClassDefinition();
>
> Something like that, I've done it before, I just can't find the syntax or 
> remember the method.

I think it's flash.utils.getDefinitionByName.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread Ian Thomas
ApplicationDomain.currentDomain.getDefinition(className)

(or whatever ApplicationDomain you are using...)

(it's flash.system.ApplicationDomain)

Ian

On Thu, Nov 20, 2008 at 9:52 PM, Merrill, Jason
<[EMAIL PROTECTED]> wrote:
> Refersh my memory.  What was the name of that AS3 class method to get a class 
> definition from a string? Something like getObjectByDefinition("MyClass") or 
> something like that, but that's not it.  Our proxy server is down and I can't 
> Google it, and the help docs are no help.
>
> Basically, I'm tring to remember the AS3 method to dynamically instantiate a 
> class from a string definition - i.e.
>
> var ClassDefinition:Class = getClassByDefinition("Apple");
> var newClassInstance:* = new ClassDefinition();
>
> Something like that, I've done it before, I just can't find the syntax or 
> remember the method.
>
> Jason Merrill
> Bank of America Instructional Technology & Media   ·   GCIB & Staff 
> Support L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash 
> Platform Developer Community
> Interested in innovative ideas in Learning?  Check out the Innovative 
> Learning Blog and subscribe.
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread Merrill, Jason
That was it!  Thanks Dave!


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.






-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dave Watts
Sent: Thursday, November 20, 2008 5:05 PM
To: Flash Coders List
Subject: Re: [Flashcoders] get class by definition - or something like that

> Refersh my memory.  What was the name of that AS3 class method to get a class 
> definition
> from a string? Something like getObjectByDefinition("MyClass") or something 
> like that, but that's not it.
> Our proxy server is down and I can't Google it, and the help docs are no help.
>
> Basically, I'm tring to remember the AS3 method to dynamically instantiate a 
> class from a string definition - i.e.
>
> var ClassDefinition:Class = getClassByDefinition("Apple");
> var newClassInstance:* = new ClassDefinition();
>
> Something like that, I've done it before, I just can't find the syntax or 
> remember the method.

I think it's flash.utils.getDefinitionByName.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/

Fig Leaf Software provides the highest caliber vendor-authorized
instruction at our training centers in Washington DC, Atlanta,
Chicago, Baltimore, Northern Virginia, or on-site at your location.
Visit http://training.figleaf.com/ for more information!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread David Hershberger
You want ApplicationDomain.getDefinition(className: String)
and also ApplicationDomain.hasDefinition(className: String) is handy.

Dave

On Thu, Nov 20, 2008 at 1:52 PM, Merrill, Jason <
[EMAIL PROTECTED]> wrote:

> Refersh my memory.  What was the name of that AS3 class method to get a
> class definition from a string? Something like
> getObjectByDefinition("MyClass") or something like that, but that's not it.
>  Our proxy server is down and I can't Google it, and the help docs are no
> help.
>
> Basically, I'm tring to remember the AS3 method to dynamically instantiate
> a class from a string definition - i.e.
>
> var ClassDefinition:Class = getClassByDefinition("Apple");
> var newClassInstance:* = new ClassDefinition();
>
> Something like that, I've done it before, I just can't find the syntax or
> remember the method.
>
> Jason Merrill
> Bank of America Instructional Technology & Media   ·   GCIB & Staff
> Support L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash
> Platform Developer Community
> Interested in innovative ideas in Learning?  Check out the Innovative
> Learning Blog and subscribe.
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread Merrill, Jason
Ian and David - interesting. So what is the difference between getDefinition 
and getDefinitionByName?

What I ended up using was this, which works well:

var ClassReference:Class = 
getDefinitionByName("people."+_associates[_associateCount]) as Class;
var instance = new ClassReference();

If I need it to be cast as the class it subclasses, like a MovieClip, so it can 
be added to the stage, I do: 

addChild(MovieClip(instance));

is there any particular reason to use getDefinition instead?  At first glance, 
seems to accomplish the same thing.

Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.






-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David Hershberger
Sent: Thursday, November 20, 2008 5:22 PM
To: Flash Coders List
Subject: Re: [Flashcoders] get class by definition - or something like that

You want ApplicationDomain.getDefinition(className: String)
and also ApplicationDomain.hasDefinition(className: String) is handy.

Dave

On Thu, Nov 20, 2008 at 1:52 PM, Merrill, Jason <
[EMAIL PROTECTED]> wrote:

> Refersh my memory.  What was the name of that AS3 class method to get a
> class definition from a string? Something like
> getObjectByDefinition("MyClass") or something like that, but that's not it.
>  Our proxy server is down and I can't Google it, and the help docs are no
> help.
>
> Basically, I'm tring to remember the AS3 method to dynamically instantiate
> a class from a string definition - i.e.
>
> var ClassDefinition:Class = getClassByDefinition("Apple");
> var newClassInstance:* = new ClassDefinition();
>
> Something like that, I've done it before, I just can't find the syntax or
> remember the method.
>
> Jason Merrill
> Bank of America Instructional Technology & Media   ·   GCIB & Staff
> Support L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash
> Platform Developer Community
> Interested in innovative ideas in Learning?  Check out the Innovative
> Learning Blog and subscribe.
>
>
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread Ian Thomas
To be honest, I don't know - but I suspect
flash.utils.getDefinitionByName() is an alias for
ApplicationDomain.currentDomain.getDefinition(). Whereas you can also
use getDefinition() to retrieve class definitions from within other
ApplicationDomain objects - such as loaded Flex modules.

Essentially ApplicationDomains are all about code segregation. You
remember how in AS2 if you loaded in a second SWF none of its class
definitions would overwrite the ones in the loading movie i.e. it
'inherited' the classes of the parent? i.e. if you had a class called
myapp.ClassA in both the movie doing the loading and the movie getting
loaded, the first definition encountered would be the one that won. A
pain if the movie you're loading in was compiled later, say, with a
different version of ClassA.

In AS3 in the flash.display.Loader class (or Flex ModuleManager or
various other loading classes) you can specify different
ApplicationDomains to use for the .swf you're loading in. It's almost
like namespacing.

If you pass null i.e. the default, from memory that means that the
loading .swf gets loaded into a _child_ ApplicationDomain i.e. gets
all the parent classes, but none of the new classes are directly
instantiable in the parent movie. From memory again, I think that's
the same as saying new
ApplicationDomain(ApplicationDomain.currentDomain), the latter
creating a child domain of the current one.

If you pass ApplicationDomain.currentDomain, the loading .swf gets all
the parents classes and the new classes it loads are instantiable in
the parent movie.

If you pass new ApplicationDomain(), the loading .swf is completely
isolated. It has its own versions of all classes, and won't
accidentally inherit definitions from the parent.

This is just for the purposes of direct use of the class/package name
i.e. new com.mypack.ClassA(). However, you can get to different class
definitions (even different definitions of class with the same
name/package as each other) by using getDefinition() on the
appropriate ApplicationDomain.

I hope that makes sense!

My only irritation with it - currently - is that the Flex framework
doesn't support running inside a completely separate
ApplicationDomain. So loading a Flex .swf into a self-contained
ApplicationDomain just doesn't work; which is a shame, as it would
have meant that running a Flex 2 app inside a Flex 3 app was perfectly
viable or vice versa (useful for legacy; also useful for the project
I'm working on at the moment which has one set of CSS in the parent
app, a different set in the child...). Apparently that's on the cards
to be fixed for Gumbo.

That was probably far more detail than you wanted. :-D

Ian

On Thu, Nov 20, 2008 at 10:26 PM, Merrill, Jason
<[EMAIL PROTECTED]> wrote:
> Ian and David - interesting. So what is the difference between getDefinition 
> and getDefinitionByName?
>
> What I ended up using was this, which works well:
>
> var ClassReference:Class = 
> getDefinitionByName("people."+_associates[_associateCount]) as Class;
> var instance = new ClassReference();
>
> If I need it to be cast as the class it subclasses, like a MovieClip, so it 
> can be added to the stage, I do:
>
> addChild(MovieClip(instance));
>
> is there any particular reason to use getDefinition instead?  At first 
> glance, seems to accomplish the same thing.
>
> Jason Merrill
> Bank of America Instructional Technology & Media   ·   GCIB & Staff 
> Support L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash 
> Platform Developer Community
> Interested in innovative ideas in Learning?  Check out the Innovative 
> Learning Blog and subscribe.
>
>
>
>
>
>
> -Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David 
> Hershberger
> Sent: Thursday, November 20, 2008 5:22 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] get class by definition - or something like that
>
> You want ApplicationDomain.getDefinition(className: String)
> and also ApplicationDomain.hasDefinition(className: String) is handy.
>
> Dave
>
> On Thu, Nov 20, 2008 at 1:52 PM, Merrill, Jason <
> [EMAIL PROTECTED]> wrote:
>
>> Refersh my memory.  What was the name of that AS3 class method to get a
>> class definition from a string? Something like
>> getObjectByDefinition("MyClass") or something like that, but that's not it.
>>  Our proxy server is down and I can't Google it, and the help docs are no
>> help.
>>
>> Basically, I'm tring to remember the AS3 method to dynamically instantiate
>> a class from a string definition - i.e.
>>
>> var ClassDefinition:Class = getClassByDefinition("Apple");
>> var newCla

Re: [Flashcoders] get class by definition - or something like that

2008-11-20 Thread Joel Stransky
This may be considered kinda nutty but I use this to dynamically detect
Document classes in loaded .swfs.

loader.contentLoaderInfo.addEventListener(Event.INIT, onInit);

private function onInit(e:Event):void
{
addChild(loader);
contentClass =
getDefinitionByName(getQualifiedClassName(loader.content));
contentClass(loader.content).startUp();
}

On Thu, Nov 20, 2008 at 5:48 PM, Ian Thomas <[EMAIL PROTECTED]> wrote:

> To be honest, I don't know - but I suspect
> flash.utils.getDefinitionByName() is an alias for
> ApplicationDomain.currentDomain.getDefinition(). Whereas you can also
> use getDefinition() to retrieve class definitions from within other
> ApplicationDomain objects - such as loaded Flex modules.
>
> Essentially ApplicationDomains are all about code segregation. You
> remember how in AS2 if you loaded in a second SWF none of its class
> definitions would overwrite the ones in the loading movie i.e. it
> 'inherited' the classes of the parent? i.e. if you had a class called
> myapp.ClassA in both the movie doing the loading and the movie getting
> loaded, the first definition encountered would be the one that won. A
> pain if the movie you're loading in was compiled later, say, with a
> different version of ClassA.
>
> In AS3 in the flash.display.Loader class (or Flex ModuleManager or
> various other loading classes) you can specify different
> ApplicationDomains to use for the .swf you're loading in. It's almost
> like namespacing.
>
> If you pass null i.e. the default, from memory that means that the
> loading .swf gets loaded into a _child_ ApplicationDomain i.e. gets
> all the parent classes, but none of the new classes are directly
> instantiable in the parent movie. From memory again, I think that's
> the same as saying new
> ApplicationDomain(ApplicationDomain.currentDomain), the latter
> creating a child domain of the current one.
>
> If you pass ApplicationDomain.currentDomain, the loading .swf gets all
> the parents classes and the new classes it loads are instantiable in
> the parent movie.
>
> If you pass new ApplicationDomain(), the loading .swf is completely
> isolated. It has its own versions of all classes, and won't
> accidentally inherit definitions from the parent.
>
> This is just for the purposes of direct use of the class/package name
> i.e. new com.mypack.ClassA(). However, you can get to different class
> definitions (even different definitions of class with the same
> name/package as each other) by using getDefinition() on the
> appropriate ApplicationDomain.
>
> I hope that makes sense!
>
> My only irritation with it - currently - is that the Flex framework
> doesn't support running inside a completely separate
> ApplicationDomain. So loading a Flex .swf into a self-contained
> ApplicationDomain just doesn't work; which is a shame, as it would
> have meant that running a Flex 2 app inside a Flex 3 app was perfectly
> viable or vice versa (useful for legacy; also useful for the project
> I'm working on at the moment which has one set of CSS in the parent
> app, a different set in the child...). Apparently that's on the cards
> to be fixed for Gumbo.
>
> That was probably far more detail than you wanted. :-D
>
> Ian
>
> On Thu, Nov 20, 2008 at 10:26 PM, Merrill, Jason
> <[EMAIL PROTECTED]> wrote:
> > Ian and David - interesting. So what is the difference between
> getDefinition and getDefinitionByName?
> >
> > What I ended up using was this, which works well:
> >
> > var ClassReference:Class =
> getDefinitionByName("people."+_associates[_associateCount]) as Class;
> > var instance = new ClassReference();
> >
> > If I need it to be cast as the class it subclasses, like a MovieClip, so
> it can be added to the stage, I do:
> >
> > addChild(MovieClip(instance));
> >
> > is there any particular reason to use getDefinition instead?  At first
> glance, seems to accomplish the same thing.
> >
> > Jason Merrill
> > Bank of America Instructional Technology & Media   ·   GCIB & Staff
> Support L&LD
> >
> > Interested in Flash Platform technologies?  Join the Bank of America
> Flash Platform Developer Community
> > Interested in innovative ideas in Learning?  Check out the Innovative
> Learning Blog and subscribe.
> >
> >
> >
> >
> >
> >
> > -Original Message-
> > From: [EMAIL PROTECTED] [mailto:
> [EMAIL PROTECTED] On Behalf Of David Hershberger
> > Sent: Thursday, November 20, 2008 5:22 PM
> > To: Flash Coders List
> > Subject: Re: [Fla

Re: [Flashcoders] get class by definition - or something like that

2008-11-21 Thread Ian Thomas
oading .swf is completely
>> isolated. It has its own versions of all classes, and won't
>> accidentally inherit definitions from the parent.
>>
>> This is just for the purposes of direct use of the class/package name
>> i.e. new com.mypack.ClassA(). However, you can get to different class
>> definitions (even different definitions of class with the same
>> name/package as each other) by using getDefinition() on the
>> appropriate ApplicationDomain.
>>
>> I hope that makes sense!
>>
>> My only irritation with it - currently - is that the Flex framework
>> doesn't support running inside a completely separate
>> ApplicationDomain. So loading a Flex .swf into a self-contained
>> ApplicationDomain just doesn't work; which is a shame, as it would
>> have meant that running a Flex 2 app inside a Flex 3 app was perfectly
>> viable or vice versa (useful for legacy; also useful for the project
>> I'm working on at the moment which has one set of CSS in the parent
>> app, a different set in the child...). Apparently that's on the cards
>> to be fixed for Gumbo.
>>
>> That was probably far more detail than you wanted. :-D
>>
>> Ian
>>
>> On Thu, Nov 20, 2008 at 10:26 PM, Merrill, Jason
>> <[EMAIL PROTECTED]> wrote:
>> > Ian and David - interesting. So what is the difference between
>> getDefinition and getDefinitionByName?
>> >
>> > What I ended up using was this, which works well:
>> >
>> > var ClassReference:Class =
>> getDefinitionByName("people."+_associates[_associateCount]) as Class;
>> > var instance = new ClassReference();
>> >
>> > If I need it to be cast as the class it subclasses, like a MovieClip, so
>> it can be added to the stage, I do:
>> >
>> > addChild(MovieClip(instance));
>> >
>> > is there any particular reason to use getDefinition instead?  At first
>> glance, seems to accomplish the same thing.
>> >
>> > Jason Merrill
>> > Bank of America Instructional Technology & Media   ·   GCIB & Staff
>> Support L&LD
>> >
>> > Interested in Flash Platform technologies?  Join the Bank of America
>> Flash Platform Developer Community
>> > Interested in innovative ideas in Learning?  Check out the Innovative
>> Learning Blog and subscribe.
>> >
>> >
>> >
>> >
>> >
>> >
>> > -Original Message-
>> > From: [EMAIL PROTECTED] [mailto:
>> [EMAIL PROTECTED] On Behalf Of David Hershberger
>> > Sent: Thursday, November 20, 2008 5:22 PM
>> > To: Flash Coders List
>> > Subject: Re: [Flashcoders] get class by definition - or something like
>> that
>> >
>> > You want ApplicationDomain.getDefinition(className: String)
>> > and also ApplicationDomain.hasDefinition(className: String) is handy.
>> >
>> > Dave
>> >
>> > On Thu, Nov 20, 2008 at 1:52 PM, Merrill, Jason <
>> > [EMAIL PROTECTED]> wrote:
>> >
>> >> Refersh my memory.  What was the name of that AS3 class method to get a
>> >> class definition from a string? Something like
>> >> getObjectByDefinition("MyClass") or something like that, but that's not
>> it.
>> >>  Our proxy server is down and I can't Google it, and the help docs are
>> no
>> >> help.
>> >>
>> >> Basically, I'm tring to remember the AS3 method to dynamically
>> instantiate
>> >> a class from a string definition - i.e.
>> >>
>> >> var ClassDefinition:Class = getClassByDefinition("Apple");
>> >> var newClassInstance:* = new ClassDefinition();
>> >>
>> >> Something like that, I've done it before, I just can't find the syntax
>> or
>> >> remember the method.
>> >>
>> >> Jason Merrill
>> >> Bank of America Instructional Technology & Media   ·   GCIB & Staff
>> >> Support L&LD
>> >>
>> >> Interested in Flash Platform technologies?  Join the Bank of America
>> Flash
>> >> Platform Developer Community
>> >> Interested in innovative ideas in Learning?  Check out the Innovative
>> >> Learning Blog and subscribe.
>> >>
>> >>
>> >> ___
>> >> Flashcoders mailing list
>> >> Flashcoders@chattyfig.figleaf.com
>> >> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >>
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >
>> > ___
>> > Flashcoders mailing list
>> > Flashcoders@chattyfig.figleaf.com
>> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>> >
>>
>> ___
>> Flashcoders mailing list
>> Flashcoders@chattyfig.figleaf.com
>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>
>
>
> --
> --Joel Stransky
> stranskydesign.com
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] get class by definition - or something like that

2008-11-21 Thread Joel Stransky
 loaded Flex modules.
> >>
> >> Essentially ApplicationDomains are all about code segregation. You
> >> remember how in AS2 if you loaded in a second SWF none of its class
> >> definitions would overwrite the ones in the loading movie i.e. it
> >> 'inherited' the classes of the parent? i.e. if you had a class called
> >> myapp.ClassA in both the movie doing the loading and the movie getting
> >> loaded, the first definition encountered would be the one that won. A
> >> pain if the movie you're loading in was compiled later, say, with a
> >> different version of ClassA.
> >>
> >> In AS3 in the flash.display.Loader class (or Flex ModuleManager or
> >> various other loading classes) you can specify different
> >> ApplicationDomains to use for the .swf you're loading in. It's almost
> >> like namespacing.
> >>
> >> If you pass null i.e. the default, from memory that means that the
> >> loading .swf gets loaded into a _child_ ApplicationDomain i.e. gets
> >> all the parent classes, but none of the new classes are directly
> >> instantiable in the parent movie. From memory again, I think that's
> >> the same as saying new
> >> ApplicationDomain(ApplicationDomain.currentDomain), the latter
> >> creating a child domain of the current one.
> >>
> >> If you pass ApplicationDomain.currentDomain, the loading .swf gets all
> >> the parents classes and the new classes it loads are instantiable in
> >> the parent movie.
> >>
> >> If you pass new ApplicationDomain(), the loading .swf is completely
> >> isolated. It has its own versions of all classes, and won't
> >> accidentally inherit definitions from the parent.
> >>
> >> This is just for the purposes of direct use of the class/package name
> >> i.e. new com.mypack.ClassA(). However, you can get to different class
> >> definitions (even different definitions of class with the same
> >> name/package as each other) by using getDefinition() on the
> >> appropriate ApplicationDomain.
> >>
> >> I hope that makes sense!
> >>
> >> My only irritation with it - currently - is that the Flex framework
> >> doesn't support running inside a completely separate
> >> ApplicationDomain. So loading a Flex .swf into a self-contained
> >> ApplicationDomain just doesn't work; which is a shame, as it would
> >> have meant that running a Flex 2 app inside a Flex 3 app was perfectly
> >> viable or vice versa (useful for legacy; also useful for the project
> >> I'm working on at the moment which has one set of CSS in the parent
> >> app, a different set in the child...). Apparently that's on the cards
> >> to be fixed for Gumbo.
> >>
> >> That was probably far more detail than you wanted. :-D
> >>
> >> Ian
> >>
> >> On Thu, Nov 20, 2008 at 10:26 PM, Merrill, Jason
> >> <[EMAIL PROTECTED]> wrote:
> >> > Ian and David - interesting. So what is the difference between
> >> getDefinition and getDefinitionByName?
> >> >
> >> > What I ended up using was this, which works well:
> >> >
> >> > var ClassReference:Class =
> >> getDefinitionByName("people."+_associates[_associateCount]) as Class;
> >> > var instance = new ClassReference();
> >> >
> >> > If I need it to be cast as the class it subclasses, like a MovieClip,
> so
> >> it can be added to the stage, I do:
> >> >
> >> > addChild(MovieClip(instance));
> >> >
> >> > is there any particular reason to use getDefinition instead?  At first
> >> glance, seems to accomplish the same thing.
> >> >
> >> > Jason Merrill
> >> > Bank of America Instructional Technology & Media   ·   GCIB &
> Staff
> >> Support L&LD
> >> >
> >> > Interested in Flash Platform technologies?  Join the Bank of America
> >> Flash Platform Developer Community
> >> > Interested in innovative ideas in Learning?  Check out the Innovative
> >> Learning Blog and subscribe.
> >> >
> >> >
> >> >
> >> >
> >> >
> >> >
> >> > -Original Message-
> >> > From: [EMAIL PROTECTED] [mailto:
> >> [EMAIL PROTECTED] On Behalf Of David
> Hershberger
> >> > Sent: Thursday, November 20, 2008 5:22 

Re: [Flashcoders] get class by definition - or something like that

2008-11-21 Thread Ian Thomas
What I'd do to retain type-checking in this case is to define an interface:

public interface IMyModule   (or whatever)
{
function startUp():void;
// and maybe other functions...
}

Make your document class implement IMyModule (i.e. it must define
function startUp()).

Then in your loading code:

private function onInit(e:Event):void
{
addChild(loader);
var myModule:IMyModule=loader.content as IMyModule;
myModule.startUp();
}

Does that make sense? Each and every one of your loadable document
classes MUST implement IMyModule. (Using interfaces like this to talk
across module boundaries are very handy.)

(Obviously, myModule.startUp() will still throw a runtime error if
your document class doesn't implement IMyModule.)

In terms of your preloader/loading different modules, I'm less sure
exactly what you're after. I haven't done much with preloaders
(because most of our content is desktop rather than web-based).

Ian

On Fri, Nov 21, 2008 at 1:56 PM, Joel Stransky <[EMAIL PROTECTED]> wrote:
> I love this list so far. Thanks for highlighting that Ian.
> I think you explained clearly that I'm bypassing good type checking so maybe
> you could help me with an alternative.
> The issue arose from Lee Brimelow's AS3 preloading
> video.
> He basically defends that the best way to preload in as3 is by creating a
> parent .swf who's only job is to load the main content movie into it
> sighting issues with document classes being forced into frame 1. He doesn't
> cover however how to call a function inside the newly loaded content so I
> thought I'd dynamically cast one. Ok, it does sound nutty when I type it
> out.
>
> What I'm struggling with is a clean way to preload a container who can turn
> around and load content without the user having to see two sequential load
> bars. Further, the nav in container should be switch out the content movies
> preferably utilizing the parent preloader again. This was a piece of cake in
> as2 by putting the preloader in frame 1 and the start of content a few
> frames later.
>
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] get class by definition - or something like that

2008-11-21 Thread Joel Stransky
Wow I really should have thought of interfaces. That will work perfectly.

On Fri, Nov 21, 2008 at 9:11 AM, Ian Thomas <[EMAIL PROTECTED]> wrote:

> What I'd do to retain type-checking in this case is to define an interface:
>
> public interface IMyModule   (or whatever)
> {
>function startUp():void;
>// and maybe other functions...
> }
>
> Make your document class implement IMyModule (i.e. it must define
> function startUp()).
>
> Then in your loading code:
>
> private function onInit(e:Event):void
> {
>addChild(loader);
> var myModule:IMyModule=loader.content as IMyModule;
>myModule.startUp();
> }
>
> Does that make sense? Each and every one of your loadable document
> classes MUST implement IMyModule. (Using interfaces like this to talk
> across module boundaries are very handy.)
>
> (Obviously, myModule.startUp() will still throw a runtime error if
> your document class doesn't implement IMyModule.)
>
> In terms of your preloader/loading different modules, I'm less sure
> exactly what you're after. I haven't done much with preloaders
> (because most of our content is desktop rather than web-based).
>
> Ian
>
> On Fri, Nov 21, 2008 at 1:56 PM, Joel Stransky <[EMAIL PROTECTED]>
> wrote:
> > I love this list so far. Thanks for highlighting that Ian.
> > I think you explained clearly that I'm bypassing good type checking so
> maybe
> > you could help me with an alternative.
> > The issue arose from Lee Brimelow's AS3 preloading
> > video.
> > He basically defends that the best way to preload in as3 is by creating a
> > parent .swf who's only job is to load the main content movie into it
> > sighting issues with document classes being forced into frame 1. He
> doesn't
> > cover however how to call a function inside the newly loaded content so I
> > thought I'd dynamically cast one. Ok, it does sound nutty when I type it
> > out.
> >
> > What I'm struggling with is a clean way to preload a container who can
> turn
> > around and load content without the user having to see two sequential
> load
> > bars. Further, the nav in container should be switch out the content
> movies
> > preferably utilizing the parent preloader again. This was a piece of cake
> in
> > as2 by putting the preloader in frame 1 and the start of content a few
> > frames later.
> >
> ___
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
--Joel Stransky
stranskydesign.com
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] get class by definition - or something like that

2008-11-21 Thread Merrill, Jason
Thanks Ian, very interesting.  Thanks everyone - good discussion.


Jason Merrill
Bank of America Instructional Technology & Media   ·   GCIB & Staff Support 
L&LD

Interested in Flash Platform technologies?  Join the Bank of America Flash 
Platform Developer Community 
Interested in innovative ideas in Learning?  Check out the Innovative Learning 
Blog and subscribe.






-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ian Thomas
Sent: Thursday, November 20, 2008 5:49 PM
To: Flash Coders List
Subject: Re: [Flashcoders] get class by definition - or something like that

To be honest, I don't know - but I suspect
flash.utils.getDefinitionByName() is an alias for
ApplicationDomain.currentDomain.getDefinition(). Whereas you can also
use getDefinition() to retrieve class definitions from within other
ApplicationDomain objects - such as loaded Flex modules.

Essentially ApplicationDomains are all about code segregation. You
remember how in AS2 if you loaded in a second SWF none of its class
definitions would overwrite the ones in the loading movie i.e. it
'inherited' the classes of the parent? i.e. if you had a class called
myapp.ClassA in both the movie doing the loading and the movie getting
loaded, the first definition encountered would be the one that won. A
pain if the movie you're loading in was compiled later, say, with a
different version of ClassA.

In AS3 in the flash.display.Loader class (or Flex ModuleManager or
various other loading classes) you can specify different
ApplicationDomains to use for the .swf you're loading in. It's almost
like namespacing.

If you pass null i.e. the default, from memory that means that the
loading .swf gets loaded into a _child_ ApplicationDomain i.e. gets
all the parent classes, but none of the new classes are directly
instantiable in the parent movie. From memory again, I think that's
the same as saying new
ApplicationDomain(ApplicationDomain.currentDomain), the latter
creating a child domain of the current one.

If you pass ApplicationDomain.currentDomain, the loading .swf gets all
the parents classes and the new classes it loads are instantiable in
the parent movie.

If you pass new ApplicationDomain(), the loading .swf is completely
isolated. It has its own versions of all classes, and won't
accidentally inherit definitions from the parent.

This is just for the purposes of direct use of the class/package name
i.e. new com.mypack.ClassA(). However, you can get to different class
definitions (even different definitions of class with the same
name/package as each other) by using getDefinition() on the
appropriate ApplicationDomain.

I hope that makes sense!

My only irritation with it - currently - is that the Flex framework
doesn't support running inside a completely separate
ApplicationDomain. So loading a Flex .swf into a self-contained
ApplicationDomain just doesn't work; which is a shame, as it would
have meant that running a Flex 2 app inside a Flex 3 app was perfectly
viable or vice versa (useful for legacy; also useful for the project
I'm working on at the moment which has one set of CSS in the parent
app, a different set in the child...). Apparently that's on the cards
to be fixed for Gumbo.

That was probably far more detail than you wanted. :-D

Ian

On Thu, Nov 20, 2008 at 10:26 PM, Merrill, Jason
<[EMAIL PROTECTED]> wrote:
> Ian and David - interesting. So what is the difference between getDefinition 
> and getDefinitionByName?
>
> What I ended up using was this, which works well:
>
> var ClassReference:Class = 
> getDefinitionByName("people."+_associates[_associateCount]) as Class;
> var instance = new ClassReference();
>
> If I need it to be cast as the class it subclasses, like a MovieClip, so it 
> can be added to the stage, I do:
>
> addChild(MovieClip(instance));
>
> is there any particular reason to use getDefinition instead?  At first 
> glance, seems to accomplish the same thing.
>
> Jason Merrill
> Bank of America Instructional Technology & Media   ·   GCIB & Staff 
> Support L&LD
>
> Interested in Flash Platform technologies?  Join the Bank of America Flash 
> Platform Developer Community
> Interested in innovative ideas in Learning?  Check out the Innovative 
> Learning Blog and subscribe.
>
>
>
>
>
>
> -Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of David 
> Hershberger
> Sent: Thursday, November 20, 2008 5:22 PM
> To: Flash Coders List
> Subject: Re: [Flashcoders] get class by definition - or something like that
>
> You want ApplicationDomain.getDefinition(className: String)
> and also ApplicationDomain.hasDefinition(className: String) is handy.
>
> Dave
>
> On Thu, Nov 20, 2008 at 1:52 PM, Merrill, Jason <
> [