[Flashcoders] slight delay prevents stack overflow in recursive function

2006-12-29 Thread Matt Garland

Hi,

I'm working on a background loading queue. It consists of a bunch of  
iterators and iterator composites. To find the next thing to load, a  
"has next" function recursively propagates down the tree, as it were,  
until it reports back that there is another thing to load, or not.


The problem: When I debug, the queue works dandy, but the vanilla  
Flash 9 player reports a stack overflow originating with "has next".


I have no idea what's going on, because I can't debug! But I do know  
this strange fact: a trace statement in the "has next" function  
corrects the problem, and queue is formed as it should be.


So if you've worked with recursion before: under what circumstances  
would a slight delay in a recursive function prevent it from going  
off the tracks?


Here's the relevant code:

public class SortIteratorComposite extends SortIterator implements  
ISortIterableComposite

{
protected var curLeaf:ISortIterable;

public function SortIteratorComposite()
{
curLeaf=null;
}
public override function 
hasNext(leaf:ISortIterable=null):Boolean
{
var more:Boolean=false;
//the superclass keeps track of the children
trace ("create a delay"+numChildren);
for (var i:uint=0; ihttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] just one ContextMenu right/control-click accessible from anywhere

2007-01-15 Thread Matt Garland

Hi

I'm trying to create a context menu that can be controlled  
dynamically (these commands are available now) AND does not depend on  
cursor location (where it is clicked does not matter). (AS3)


I want the menu logic tied to the app logic, not the current display  
list.


I have a background sprite whose contextMenu property changes with  
the nav. But different content is constantly loading and unloading,  
and if you right-click on these transient sprites, their uncustomized  
menu drops down instead of my default dynamic/global menu.


Short of setting the contextMenu property of every single sprite that  
appears, what can I do to ensure that my menu comes up every time?


I have some unpromising ideas (like capturing bubbling mouseDowns,  
sifting for right-clicks, getting the original target, changing its  
contextMenu...) but before I go down the garden path, I was hoping  
that I missed something obvious (I'm new to ContextMenu).


Thanks

Matt




___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Re: just one ContextMenu right/control-click accessible from anywhere

2007-01-15 Thread Matt Garland

Self-update:

I just realized I CAN just set the main container contextMenu  
property and get a global ContextMenu, as I had expected at first.


There is a curious reason why this did not work before. My background  
sprite was one big bitmap.


Once I changed the bitmap to a rectangle shape, the global menu  
worked...EXCEPT for the content that contains dynamically generated  
bitmaps.


Wrapping bitmaps in interactive sprites does not change this. So my  
question now is, why do bitmaps--and sprites wrapping bitmaps--impede  
the main container's right click capability? And how to stop this?


/
Hi

I'm trying to create a context menu that can be controlled  
dynamically (these commands are available now) AND does not depend on  
cursor location (where it is clicked does not matter). (AS3)


I want the menu logic tied to the app logic, not the current display  
list.


I have a background sprite whose contextMenu property changes with  
the nav. But different content is constantly loading and unloading,  
and if you right-click on these transient sprites, their uncustomized  
menu drops down instead of my default dynamic/global menu.


Short of setting the contextMenu property of every single sprite that  
appears, what can I do to ensure that my menu comes up every time?


I have some unpromising ideas (like capturing bubbling mouseDowns,  
sifting for right-clicks, getting the original target, changing its  
contextMenu...) but before I go down the garden path, I was hoping  
that I missed something obvious (I'm new to ContextMenu).


Thanks

Matt
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] re: loadMovie question ([p e r c e p t i c o n])

2007-02-02 Thread Matt Garland

p

you can skew without the transform matrix by passing a negative value  
for x or y scale.


I'll bet you have a negative value in there--look for it


matt


Message: 1
Date: Fri, 2 Feb 2007 09:19:31 -0800
From: "[p e r c e p t i c o n]" <[EMAIL PROTECTED]>
Subject: [Flashcoders] loadMovie question
To: flashcoders 
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

Hi Alain,
I would think that would work too, but i tried that as well...not sure
what's happening...

in fact all of my coordinates are all screwed up...plus i've  
noticed that
when i change the width of some clips it literally skews the clip  
as if i
used the transform tool...very strange as i haven't touched the  
matrix of

the clip...

i've never had this happen before so i quite baffled

thanks

p


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] for...in property access replacement in AS3?

2007-02-15 Thread Matt Garland

Hi,

I'm converting some AS2 code to AS3. The code manipulates several  
big, complicated data containers to produce an animation.


In AS2, the data container was a vanilla object. In AS3, for  
performance gains, I turned these containers into several classes.


The problem is, at various points, I am transferring all the values  
from one container to another. The variables have the same names, but  
the data containers are different. For instance, in the first  
container, there are points. In the second container,the  
corresponding points are actually a subclass of points, one with more  
properties.


Before, I could just lay the two containers side by side, then use  
recursive for...in loops to transfer all the values. But for...in  
loops don't work for class instances in AS3. Class info is baked into  
the compiled class, and no longer stored in a memory- and cycle- 
wasting object hash.


What to do?

Anyway I can access the compiled class info (looping through a  
class's properties), or is that contra the entire point of AS3?


Save me from writing a long, convoluted one-off conversion function.

Thanks

Matt
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Re: for...in property access replacement in AS3?

2007-02-16 Thread Matt Garland

Thanks Mike, you are the man.

I didn't use setPropertyIsEnumerable, because adding that for every  
property would be as much typing as writing a custom conversion  
function.


But describeType, that's the trick. It converts class info into XML.  
Info is easily accessible with EX4 syntax, one of the many things  
that makes AS3 a joy.


Message: 17
Date: Thu, 15 Feb 2007 21:24:28 -0800
From: "T. Michael Keesey" <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] for...in property access replacement in
AS3?
To: "Flashcoders mailing list" 
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=UTF-8; format=flowed

You can use Object.setPropertyisEnumerable(propName).

flash.utils.describeType() might be another way.

--
Mike Keesey

On 2/15/07, Matt Garland <[EMAIL PROTECTED]> wrote:


Hi,

I'm converting some AS2 code to AS3. The code manipulates several
big, complicated data containers to produce an animation.

In AS2, the data container was a vanilla object. In AS3, for
performance gains, I turned these containers into several classes.

The problem is, at various points, I am transferring all the values
from one container to another. The variables have the same names, but
the data containers are different. For instance, in the first
container, there are points. In the second container,the
corresponding points are actually a subclass of points, one with more
properties.

Before, I could just lay the two containers side by side, then use
recursive for...in loops to transfer all the values. But for...in
loops don't work for class instances in AS3. Class info is baked into
the compiled class, and no longer stored in a memory- and cycle-
wasting object hash.

What to do?

Anyway I can access the compiled class info (looping through a
class's properties), or is that contra the entire point of AS3?

Save me from writing a long, convoluted one-off conversion function.

Thanks

Matt


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] pattern fever: composing dynamic object and knowing them remotely

2006-10-09 Thread Matt Garland

I have a design problem:

A site I'm working up has a shell/module structure. Each module  
composes an instance of a Navigation class.


This instance mixes and matches various navigation functionality.  
Some modules might have last/next methods, some might have last/next  
and direct goto (buttons) methods, some might have just goto  
(buttons), or buttons and browser-like, history-based forwards/ 
backwards methods. Some will have pause/play. Some might have no  
navigation at all. All would have an index property and an abstract  
"goTo" method, which would be handled/implemented by the module itself.


When the module is focused, a controller bar in the shell redraws  
itself according to the module's navigation.


Here's two questions:

1) How do I make this navigation object? It mixes and matches a set  
of methods almost randomly. It this even a candidate for a class?


Having just read Head First Design Patterns, my first thought was  
that decorator could help. But how do you access added methods if the  
basic object is wrapped more than once:


NextLast(History(new Navigation())).goBackward() wouldn't work  
because goBackward is not a method of the outermost wrapper, NextLast.


Should I then make the decorator specify ALL possible methods? That  
seems perverse.


Instead, it would be easier to supply a full-fledged navigation  
object and selectively enable parts of it. But then the class would  
turn into a mess of conditionals:


function next() {
currentIndex++
if (this navigation instance has a history) {
history.push(currentIndex);
}

This is stumping me. Having pattern fever (I recommend the book), the  
only alternative I can think of is: turn each piece of navigation  
functionality into a class (history, nextLast, etc), then compose a  
navigation object as an array of objects, which would each in term  
handle a message from the controller in the shell (chain of  
responsibility?).


2) Once I manage to compose a navigation object, how can the shell's  
controller bar interrogate it? That is, how to know which methods are  
defined or enabled for it? Is there a more direct way than looping  
through the object and looking at its properties and methods (and  
since I'm doing this in AS3, I'm not sure I can even do this). I  
suppose I could store a bunch os strings for verification, but as  
with the last problem, I can't believe that smarter programmers  
haven't solved this problem in an better way.


I should say that the site is mine and the only constraint is the  
spec I'm giving myself, which is: give every module a navigation  
module, so that the module's navigation will be easy to create (new  
History(new Navigation)), without having to create a bunch of new  
classes (HistoryNextLast extends History). In addition, I want the  
the navigation object to refer back to other navigations objects so  
that they form a XML-like nodal structure. This would be convenient  
for retrieving navigation information, but even more for creating an  
easy add-on structure. Basically, I want any combination of nav  
functions to be able to lead to any other kind of combination, module  
after module. How to achieve this I don't know yet.

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] re: pattern fever

2006-10-09 Thread Matt Garland

Thanks Reuben.

Yes, I think I'll do what you suggest: just parameterize a full-dress  
Navigation with a custom object, then have the controller retrieve  
it. It will be make it the Navigation difficult to extend and write,  
but I see no alternative for now...except maybe using a dynamic  
class, and building up an object with snapped-on methods?


As for patterns--in this case, I'm definitely grasping for a  
solution. But in my short experience, patterns have been hugely  
useful, as well as just neat. I think I would eventually have  
approximated some patterns (state, observer)..but composite,  
decorator, factory? Never. I'm still excited.


>>
Why not use a initialization NavigationSettings class for your
Navigation that has its own methods that can be interrogated by your
controller? ie - new Navigation(new NavigationSettings(params));

The "controller bar" could access the NavigationSettings instance to
find out its necessary settings.

IMHO, patterns are only useful where they actually solve problems,
not create additional ones. "Pattern Fever" does no good for
anyone.If you can't find a pattern that fits your requirements, maybe
patterns are the wrong way to go about it. You shouldn't need to
twist your requirements to try and fit into a particular pattern.

Hope this helps.
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] re: tweening distortions using BitmapData and transformMatrix

2006-10-10 Thread Matt Garland

A couple pointers:

--you don't need to continually reattach a BitmapData, changes you  
make directly to it are automatically rendered (it's not like  
modifying and reassigning a filter to a movieclip)


--however, at times, you might want to remove the BitmapData from the  
stage so that multiple changes applied to it aren't rendered blow-by- 
blow (double buffering, or you can "lock" a rendered BitmapData in AS3)


--the transform matrix is limited for your larger purposes: you can  
only scale and skew with the matrix, and tint and brighten/darken  
with ColorTransform


--you're mostly going to be incrementing a filter property and  
reassigning that filter to a movieclip (AS3: Bitmap) with a  
bitmapData in it


--FlashGuru, Grant Skinner and especially Quasimodo have .fla and .as  
examples available


--some useful correspondences: convolution filter-->sharpen, blur,  
find edges; displacement filter-->liquify, distort; colorMatrix  
filter-->contrast,brightness, tint, saturation;  
BitmapData.paletteMap-->levels; BitmapData.merge-->blend modes;  
channels-->BitmapData.copyChannel, BitmapData.copyPixels-->cut and  
paste, masking; floodFill-->bucket tool, BitmapData.threshold-->color  
range, BitmapData.noise-->noise, of course...


--filters don't actually change underlying BitmapData data, they are  
like "adjustment layers" in Photoshop...if you want successive (and  
irreversible, unless you leave bread crumbs of your own devising,  
like a "History" panel) changes, then use BitmapData.applyFilter


Hope that helps
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] Re: Flashcoders Digest, Vol 21, Issue 51

2006-10-19 Thread Matt Garland

Yes, you can copy only the visible pixels of a bitmap.

To do this, you must pass the optional AlphaBitmap parameter for  
copyPixels:


public copyPixels(sourceBitmap:BitmapData, sourceRect:Rectangle,  
destPoint:Point, [alphaBitmap:BitmapData], [alphaPoint:Point],  
[mergeAlpha:Boolean]) : Void


piece_bd.copyPixels(piece_mc,new
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height- 
borderSize*2),new

Point(borderSize,borderSize), ALPHA BITMAP);


I'm not sure what's going on in your code, so I can't say what should  
be the ALPHA BITMAP, piece_mc?


If you do that, the copied parts of piece_mc would be basically "self- 
masked."



On Oct 19, 2006, at 8:01 AM, flashcoders- 
[EMAIL PROTECTED] wrote:



Thanks the help everyone.

Ok i'm slowly getting my head around this bitdata.

If I wanted to mask a bg pic using setmask.

Can i then copy the visible area using copypixels? and use this a
fixed image ("snapshot") ? Seem to be stuck a little

here is my code as far:-

import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;

//create blank movieclip, create bd object. put pic into bd object,
then put object into movieclip.
var picture:BitmapData = BitmapData.loadBitmap("rawbg");
_root.createEmptyMovieClip("pictureMc",this.getNextHighestDepth());
pictureMc.attachBitmap(picture,1);
///

//create blank mc, attach piecepic to mc.
piece_mc = this.createEmptyMovieClip("orig",  
this.getNextHighestDepth());

piece_mc.attachMovie("piece0",piece0,this.getNextHighestDepth());
//
// create bd for peice. draw the piece into the bd object.
		piece_bd = new BitmapData (this.piece_mc.width,  
this.piece_mc.height, true);

piece_bd.draw (this.piece_mc, this.matrix);

//apply mask
pictureMc.setMask(_root.piece_mc)

//HELP HERE - I dont understand this section, althougj think i'm on
the right lines.
piece_bd.copyPixels(piece_mc,new
Rectangle(xPos,yPos,subPicture.width-borderSize*2,subPicture.height- 
borderSize*2),new

Point(borderSize,borderSize));


//drag the fixed snapshot piece around
piece_mc.onRelease = function() {

 this.startDrag();
}


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] off-display mouse listeners still listen in AS3?

2006-11-12 Thread Matt Garland

Hi,

I'm making a site in AS3 with lots and lots of buttons.

I'm worried that all the listeners on the buttons will clog the memory.

I realize that sprites that are not in the display list cannot  
receive mouse events, but do they still listen for them, taking up  
memory?


I'm not sure how to test that.

If they do, then in the buttons I'll

1) add listeners for "added" and "removed" events to detect when the  
buttons are added to the display list, and


2) handle these events by toggling the mouseEnabled and mouseChildren  
properties off and on (that will kill and revive the listeners)


But it seems funny to kill listeners that cannot hear anything, and a  
hassle to add this code to all the button species I'm working with.


Thanks

Matt

On Nov 12, 2006, at 9:00 AM, flashcoders- 
[EMAIL PROTECTED] wrote:



Send Flashcoders mailing list submissions to
flashcoders@chattyfig.figleaf.com

To subscribe or unsubscribe via the World Wide Web, visit
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
or, via email, send a message with subject or body 'help' to
[EMAIL PROTECTED]

You can reach the person managing the list at
[EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Flashcoders digest..."


Today's Topics:

   1. Re: functions outside a class (Helmut Granda)
   2. Re: Faking 3D perspective of a 2D map in Flash 8..? (Zeh  
Fernando)

   3. Re: OO way to start RIA app (Mark Lapasa)
   4. Re: Faking 3D perspective of a 2D map in Flash 8..? (Hans  
Wichman)

   5. Re: Faking 3D perspective of a 2D map in Flash8..? (Mike Nowak)
   6. RE: functions outside a class (Mike Keesey)
   7. Re: Faking 3D perspective of a 2D map in Flash8..? (Mike Nowak)
   8. Noob question: Text effects, apps/components? (Micky Hulse)
   9. Google queries / iweb services / API in A.S. 2.0. (Millie Niss)
  10. frustrated with textFields: getting height while text isn't
  fully 'there' (grimmwerks)


--

Message: 1
Date: Fri, 10 Nov 2006 13:45:34 -0600
From: "Helmut Granda" <[EMAIL PROTECTED]>
Subject: [Flashcoders] Re: functions outside a class
To: "Flashcoders mailing list" 
Message-ID:
<[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

ok, i figured it out.

it works if i make reference to where the function is.

this.function();
_parent.function();

if i just call the function:

function();

it is where I was getting stuck, but it all works now.

...

On 11/10/06, Helmut Granda <[EMAIL PROTECTED]> wrote:


I have several classes that will use a function. for scope reasons  
i have
placed the function in a different file but i would like to be  
able to

access that file from within the classes.

If the function has been declared outside the class, what is the  
best way

to accces those functions?

sample:

utils.controls:
classA
classB

utils/functions:
functionA
functionB

main timeline:
include functionA
include functionB

now I would like to access functionA or functionB within the class...

TIA

--
...helmut





--
...helmut
helmutgranda.com


--

Message: 2
Date: Fri, 10 Nov 2006 17:46:11 -0200
From: "Zeh Fernando" <[EMAIL PROTECTED]>
Subject: Re: [Flashcoders] Faking 3D perspective of a 2D map in Flash
8..?
To: "Flashcoders mailing list" 
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; format=flowed; charset="iso-8859-1";
reply-type=original

So far I've only been able to achieve that in Illustrator and then  
saving
the perspectively squished vectors as a .swf  What I'd love to do  
is to

get
that perspective squish done within Flash 8 using script.
I know about 3D program extensions for Flash like Sandy, but I  
find them

cryptic (at best) and over kill for my simple needs.


Using something like Sandy is the only choice you have. For example:

http://sandy.media-box.net/blog/distortimage-20-the-fastest-way-to- 
freely-distort-image-with-flash-in-actionscript.html
http://sandy.media-box.net/blog/distordimage-the-way-to-distord- 
bitmaps-by-code.html


You need something like this. This is done by dividing an image in  
triangles

and then projecting them.

But you'd still have to be careful, as simple distortion ISN'T  
perspective.
The above examples are simply distorting the image, but not  
accounting for
proximity (it's just squishing the texture). If you get a side too  
thin,

it'll just look thin, not "far".

This is an old example, but uses a similar approach but with correct
calculation (each side of the box is made of 4 triangles):

http://www.nkag.co.jp/

For something like that, you'd need to either build a complex plane  
with
Sandy, using a bunch of squares (so it will do correct perspective,  
or close
to it anyways), or build the whole calculation and projection  
yourself.

Which can be done, but will probably take some time.

[Flashcoders] upcasting causes overridden superclasses methods to be called

2006-11-14 Thread Matt Garland

I was hunting a bug when I found this out:

class SuperClass {
public function init() {
trace ("superclass init");
}
}

class SubClass extends SuperClass{
public override function init(){
trace ("subclass init");
}
}

if you create a subclass instances and cast it (or type its variable)  
to the superclass, when init is invoked, the superclass init is called.


var aInstance:SuperClass=new SubClass();
aInstance.init();//"superclass init"

Makes senses, now how about a way around this? I want to make sure  
the instance's OWN init() is called.


Here's the context: I'm upcasting in a button factory class, when  
SubClass is a variable:


public function ButtonFactory(graphicsFactory:graphicFactory,  
buttonClass:Class) {


//the compiler won't let me cast to an unknown class, so
//since I know buttonClass is a descendent of BaseButton, which has  
all the relevant graphics-setting methods, I upcast it

//buttonClass-->BaseButton

aButton:BaseButton=new buttonClass()
//the graphics settings methods are in BaseButton, so I'm fine to  
build up the graphics

aButton.disabledState=graphicsFactory.makeDisabledState()
//but this calls BaseButton.init(), not buttonClass.init()
aButton.init()

}

Thanks

matt

___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


[Flashcoders] RE:upcasting

2006-11-14 Thread Matt Garland
Whoops! I didn't actually run this test code, just abstracted from my  
problem and spat it out.


I guess my buttons are not instantiated like I thought they were.  
I'll take another look.


Thanks JC--"override" must be applied to any protected or public  
method that is overridden in a subclass, in AS3.


Hi,
running your example shows: subclass init, as it should.

public override function init(){
trace ("subclass init");
}

whats the override keyword doing there?

greetz
JC

On 11/14/06, Matt Garland <[EMAIL PROTECTED]> wrote:



I was hunting a bug when I found this out:

class SuperClass {
public function init() {
trace ("superclass init");
}
}

class SubClass extends SuperClass{
public override function init(){
trace ("subclass init");
}
}

if you create a subclass instances and cast it (or type its variable)
to the superclass, when init is invoked, the superclass init is  
called.


var aInstance:SuperClass=new SubClass();
aInstance.init();//"superclass init"

Makes senses, now how about a way around this? I want to make sure
the instance's OWN init() is called.

Here's the context: I'm upcasting in a button factory class, when
SubClass is a variable:

public function ButtonFactory(graphicsFactory:graphicFactory,
buttonClass:Class) {

//the compiler won't let me cast to an unknown class, so
//since I know buttonClass is a descendent of BaseButton, which has
all the relevant graphics-setting methods, I upcast it
//buttonClass-->BaseButton

aButton:BaseButton=new buttonClass()
//the graphics settings methods are in BaseButton, so I'm fine to
build up the graphics
aButton.disabledState=graphicsFactory.makeDisabledState()
//but this calls BaseButton.init(), not buttonClass.init()
aButton.init()

}


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com