[flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread danfrap767
Hey mike, 

I received your posts after I posted that. Thanks for the info though.
very helpful. It's difficult starting to understand the change from a
movieclip-based view architecture where I would create classes that
push to a view and now this architecture. 

Baby steps...

--- In flexcoders@yahoogroups.com, "Michael Schmalle"
<[EMAIL PROTECTED]> wrote:
>
> > danfrap767
> 
> Have you been reading my posts? From the thread it dosn't look like
you are
> seeing them or something.
> 
> You need to create a skin class from ProgrammaticSkin.
> 
> Subclass it.
> 
> Peace, Mike
> 
> 
> On 8/11/06, danfrap767 <[EMAIL PROTECTED]> wrote:
> >
> >   I thought so too, as it even says in the addChild for a Canvas
> > documentation that it takes a display object.
> >
> > but for some reason when I test and after attaching the canvas I then
> > attach the sprite I still get that same error:
> >
> >
> > "TypeError: Error #1034: Type Coercion failed: cannot convert
> > flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent."
> >
> > Why would it try to convert that?
> >
> > this is the bit of code from the function , and the drawn bg and the
> > button show up totally fine.
> >
> > contentBg = new Canvas();
> > contentBg.graphics.beginFill(0xFF);
> > contentBg.graphics.lineStyle(2, 0xFF);
> >
> > contentBg.graphics.drawRoundRect(0, 0, 150, 400, 10, 10);
> > contentBg.graphics.endFill();
> > addChild(contentBg);
> >
> > changeButton = new Button();
> > changeButton.label = returnData.buttons.button.label;
> > changeButton.move(30, 30);
> > changeButton.addEventListener(MouseEvent.CLICK, someFunction);
> > contentBg.addChild(changeButton);
> >
> > mySprite = new Sprite();
> > mySprite.graphics.beginFill(0xFF);
> > mySprite.graphics.drawRoundRect(300, 0, 150, 400, 10, 10);
> > mySprite.graphics.endFill();
> > contentBg.addChild(mySprite);
> >
> > any ideas?
> >
> >
> > --- In flexcoders@yahoogroups.com ,
> > "dadrobson"  wrote:
> > >
> > > You should be able to use Canvas.addChild(Sprite), because it
takes a
> > > DisplayObject, and Sprite does exted DisplayObject.
> > >
> > > I don't have time to test it right now, but based on the inheritance
> > > outlined in the docs, it looks like it should work. I'll try to
run a
> > > test later; meanwhile, if you have a chance to test it, please
let me
> > > know what you learn.
> > >
> > > -Jim
> > >
> >
> >  
> >
> 
> 
> 
> -- 
> What goes up, does come down.
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread Michael Schmalle



> danfrap767Have you been reading my posts? From the thread it dosn't look like you are seeing them or something.You need to create a skin class from ProgrammaticSkin.
Subclass it.Peace, MikeOn 8/11/06, danfrap767 <
[EMAIL PROTECTED]> wrote:












  



I thought so too, as it even says in the addChild for a Canvas
documentation that it takes a display object. 

but for some reason when I test and after attaching the canvas I then
attach the sprite I still get that same error:

"TypeError: Error #1034: Type Coercion failed: cannot convert
flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent."

Why would it try to convert that?

this is the bit of code from the function , and the drawn bg and the
button show up totally fine.

contentBg = new Canvas();
contentBg.graphics.beginFill(0xFF);
contentBg.graphics.lineStyle(2, 0xFF);
contentBg.graphics.drawRoundRect(0, 0, 150, 400, 10, 10);
contentBg.graphics.endFill();
addChild(contentBg);
			
changeButton = new Button();
changeButton.label = returnData.buttons.button.label;
changeButton.move(30, 30);
changeButton.addEventListener(MouseEvent.CLICK, someFunction);
contentBg.addChild(changeButton);
			
mySprite = new Sprite();
mySprite.graphics.beginFill(0xFF);
mySprite.graphics.drawRoundRect(300, 0, 150, 400, 10, 10);
mySprite.graphics.endFill();
contentBg.addChild(mySprite);

any ideas?

--- In flexcoders@yahoogroups.com, "dadrobson" <[EMAIL PROTECTED]> wrote:
>
> You should be able to use Canvas.addChild(Sprite), because it takes a
> DisplayObject, and Sprite does exted DisplayObject.
> 
> I don't have time to test it right now, but based on the inheritance
> outlined in the docs, it looks like it should work. I'll try to run a
> test later; meanwhile, if you have a chance to test it, please let me
> know what you learn.
> 
> -Jim
>


  













-- What goes up, does come down.

__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



Re: [flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread Tom Bray



Here's a response from Gordon to a similar question I had way back:What does your component extend? If you're
extending a Container, you can only use addChild() to content children which implement
the IUIComponent interface. In order to support the LayoutManager, a content
child has to implement things like measure(), etc.

 

However you should able to add it as a
non-content or "chrome" child by doing rawChildren.addChild(myButton).
Non-content children don't undergo automatic sizing and layout, so you'll have
to set the size and position of myButton yourself.

 

- Gordon

 On 8/11/06, danfrap767
 <[EMAIL PROTECTED]> wrote:













  



I thought so too, as it even says in the addChild for a Canvas
documentation that it takes a display object. 

but for some reason when I test and after attaching the canvas I then
attach the sprite I still get that same error:

"TypeError: Error #1034: Type Coercion failed: cannot convert
flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent."

Why would it try to convert that?

this is the bit of code from the function , and the drawn bg and the
button show up totally fine.

contentBg = new Canvas();
contentBg.graphics.beginFill(0xFF);
contentBg.graphics.lineStyle(2, 0xFF);
contentBg.graphics.drawRoundRect(0, 0, 150, 400, 10, 10);
contentBg.graphics.endFill();
addChild(contentBg);
			
changeButton = new Button();
changeButton.label = returnData.buttons.button.label;
changeButton.move(30, 30);
changeButton.addEventListener(MouseEvent.CLICK, someFunction);
contentBg.addChild(changeButton);
			
mySprite = new Sprite();
mySprite.graphics.beginFill(0xFF);
mySprite.graphics.drawRoundRect(300, 0, 150, 400, 10, 10);
mySprite.graphics.endFill();
contentBg.addChild(mySprite);

any ideas?

--- In flexcoders@yahoogroups.com, "dadrobson" <[EMAIL PROTECTED]> wrote:
>
> You should be able to use Canvas.addChild(Sprite), because it takes a
> DisplayObject, and Sprite does exted DisplayObject.
> 
> I don't have time to test it right now, but based on the inheritance
> outlined in the docs, it looks like it should work. I'll try to run a
> test later; meanwhile, if you have a chance to test it, please let me
> know what you learn.
> 
> -Jim
>


  















__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



[flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread danfrap767
I thought so too, as it even says in the addChild for a Canvas
documentation that it takes a display object. 

but for some reason when I test and after attaching the canvas I then
attach the sprite I still get that same error:

"TypeError: Error #1034: Type Coercion failed: cannot convert
flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent."

Why would it try to convert that?

this is the bit of code from the function , and the drawn bg and the
button show up totally fine.

contentBg = new Canvas();
contentBg.graphics.beginFill(0xFF);
contentBg.graphics.lineStyle(2, 0xFF);
contentBg.graphics.drawRoundRect(0, 0, 150, 400, 10, 10);
contentBg.graphics.endFill();
addChild(contentBg);

changeButton = new Button();
changeButton.label = returnData.buttons.button.label;
changeButton.move(30, 30);
changeButton.addEventListener(MouseEvent.CLICK, someFunction);
contentBg.addChild(changeButton);

mySprite = new Sprite();
mySprite.graphics.beginFill(0xFF);
mySprite.graphics.drawRoundRect(300, 0, 150, 400, 10, 10);
mySprite.graphics.endFill();
contentBg.addChild(mySprite);

any ideas?

--- In flexcoders@yahoogroups.com, "dadrobson" <[EMAIL PROTECTED]> wrote:
>
> You should be able to use Canvas.addChild(Sprite), because it takes a
> DisplayObject, and Sprite does exted DisplayObject.
> 
> I don't have time to test it right now, but based on the inheritance
> outlined in the docs, it looks like it should work. I'll try to run a
> test later; meanwhile, if you have a chance to test it, please let me
> know what you learn.
> 
> -Jim
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread Michael Schmalle



Hi Jim,> Canvas.addChild(Sprite),You cannot do this because "The DisplayObject to add as a child of this Container.  It must implement the IUIComponent interface."Sprite does not implement IUIComponent. Basically all children of a container have to be a IUIComponent becasue of the way Flex lays them out.
Example, Sprite does not have a measuredWidth property. That would kill the Canvas's layout engine.This release of AS3 is really misleading when it comes to things like this. Using;child:DisplayObject
as the param means it MUST be a DisplayObject. The 'catch' is that in as3 you can not change the type of a parameter in a subclass.If you could the addChild() method of Container would look likeaddChild(child:IUIComponent)
That is a misunderstanding I see a lot of people running into these days.This part of Container inforces the IUIComponent interface rule;        // Throw an RTE if child is not an IUIComponent.
        var uiChild:IUIComponent = IUIComponent(child);You will get the runtime exception there.Peace, MikeOn 8/11/06, dadrobson <
[EMAIL PROTECTED]> wrote:












  



I stand corrected:

I wrote "extend" instead of "implement".

Thanks Mike!

-Jim


  













-- What goes up, does come down.

__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



[flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread dadrobson
You should be able to use Canvas.addChild(Sprite), because it takes a
DisplayObject, and Sprite does exted DisplayObject.

I don't have time to test it right now, but based on the inheritance
outlined in the docs, it looks like it should work. I'll try to run a
test later; meanwhile, if you have a chance to test it, please let me
know what you learn.

-Jim





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




[flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread dadrobson
I stand corrected:

I wrote "extend" instead of "implement".

Thanks Mike!

-Jim






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 




Re: [flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread Michael Schmalle



> extend mx.core.IUIComponent,A DisplayObject dosn't have to extend UIComponent it just has to implement the IUIComponent interface which ProgrammaticSkin does.ProgrammaticSkin is a Shape/FlexShape subclass.
Peace, MikeOn 8/11/06, dadrobson <[EMAIL PROTECTED]> wrote:













  



Sprite doesn't extend mx.core.IUIComponent, and so you can't use it as
a parameter in the addChild() method of the Panel class. Instead of
using Sprite, try Canvas instead.

HTH
Jim


  













-- What goes up, does come down.

__._,_.___





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com








   






  
  
SPONSORED LINKS
  
  
  

Web site design development
  
  
Computer software development
  
  
Software design and development
  
  


Macromedia flex
  
  
Software development best practice
  

   
  







  
  
  YAHOO! GROUPS LINKS



   Visit your group "flexcoders" on the web. 
   To unsubscribe from this group, send an email to: [EMAIL PROTECTED] 
   Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



  






__,_._,___



[flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread danfrap767
Thanks, Jim. That worked! 

After considering myself a very advanced actionscripter I feel like an
idiot with these questions, but...

So than how are you supposed to go about attaching a sprite? since I
can't attach that to the Canvas either. 

like I said, I know these are very newbie questions but it doesn't
seem clear from any of the limited documentation online. Thanks for
having any of the patience to address this. 

-cb

--- In flexcoders@yahoogroups.com, "dadrobson" <[EMAIL PROTECTED]> wrote:
>
> Sprite doesn't extend mx.core.IUIComponent, and so you can't use it as
> a parameter in the addChild() method of the Panel class. Instead of
> using Sprite, try Canvas instead.
> 
> HTH
> Jim
>






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





[flexcoders] Re: Newbie Question - attaching a Sprite

2006-08-11 Thread dadrobson
Sprite doesn't extend mx.core.IUIComponent, and so you can't use it as
a parameter in the addChild() method of the Panel class. Instead of
using Sprite, try Canvas instead.

HTH
Jim






--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/