Does not work just means it isn't showing up on screen - something is wrong 
with how I am adding stuff to the display list.

MainApp has the canvas object, and the content object -> creates an instance of 
any class that extends my ContentTemplate class.
I don't see why canvas.addChild(contentObject) does not work.
Passing a reference of that canvas to the constructor, then 
canvasReference.addChild(anyObject) works.

So in MainApp I have something like this:

contentHolder = new Canvas();
this.addChild(contentHolder);
contentScreen = new SampleScreen(contentHolder);
// SampleScreen extends a template class that extends UIComponent

Inside SampleScreen:
question = new Text();
question.text = "some text";
contentHolder.addChild(question);

All this works....

But, with all these classes that are going to extend SampleScreen I really 
don't want to pass that reference to contentHolder around.
What is confusing me, is why I couldn't do this:

MainApp
contentHolder = new Canvas();
this.addChild(contentHolder);
contentScreen =  new SampleScreen();
contentHolder.addChild(contentScreen); // HERE is what I want to work, 
contentScreen extends UIComponent - so in my mind it should work (show up on 
screen).

SampleScreen
question = new Text();
question.text = "some text";
this.addChild(question); // HERE is the other change from the working version. 
Since SampleScreen extends UIComponent, and above I have added it to the 
canvas' display list, why is it not showing up?


Thanks much for looking... Jason





  ----- Original Message ----- 
  From: Manish Jethani 
  To: flexcoders@yahoogroups.com 
  Sent: Wednesday, April 25, 2007 4:11 PM
  Subject: Re: [flexcoders] addChild problems


  If you can show the heirarchy of your objects and which one you're
  trying to add that's failing, that'll help. Also explain what "does
  not work" means (do you get an error?).

  On 4/26/07, Jason C Reynolds <[EMAIL PROTECTED]> wrote:
  >
  >
  > Sorry for the vauge subject... here's what I'm trying to do that does not
  > work.
  >
  > I am creating a MainApp class instance in my mxml project file. I want to
  > use this to control the basic common stuff throughout the application, and I
  > have made an instance of a Canvas object that I will be using as a container
  > to the constantly changing part of the screen. I made a ContentTemplate
  > class that extends UIComponent (I had problems with addChild in actionscript
  > before I realized if it's not pure as3 it needs to be a UIComponent to
  > work). From this ContentTemplate class, I have created several classes that
  > extend it and want to use addChild/removeChild to change that canvas part of
  > the program.
  >
  > So, in MainApp I have a variable contentScreen of type ContentTemplate. Lets
  > just say all ContentTemplate is doing is making a new text control. I tried
  > to make this text control in the ContentTemplate, and since it is extending
  > UIComponent - I thought just a this.addChild would work... Then in mainApp
  > just add it to the display list of the Canvas object. This does not work.
  >
  > If I pass a reference to that canvas object in the constructor, then
  > addChild from there it works.
  >
  > Hopefully I somewhat clear what I'm trying to do - and anyone have any
  > suggestions why this would not work?
  >
  > Thanks for any response, Jason
  >
  >
  >
  > 


   

Reply via email to