[flexcoders] addChild doesn't effect for some reason REFdn2065133102
In small test application I have the follow object. stack The Main.mxml loads the EntryClass.as - class EntryClass (that doesn't extends anything) - public static function Main(). This EntryClass.Main() function is doing the follow: var mxmlApp:Application = Application(Application.application); var mainAppClass:MainAppClass=new MainAppClass(); mxmlApp.addChild(mainAppClass); So the mainAppClass is loaded. Now the MainAppClass extends the UIComponent and in its constructor does this: var buttonFromMainClass:Button=new Button(); buttonFromMainClass.x=20;buttonFromMainClass.y=20;buttonFromMainClass.label= hello world; to add it to stage I call addChild(buttonFromMainClass); and here is the problem! The button is not appeared on the stage, but using this code: Application(Application.application).addChild(buttonFromMainClass); the button is added to the stage and it is visible. Why the button is not added to the stage with the simple addChild? Where am I wrong? Something that might be help, in EntryClass.Main() if I create a button and add it with the mxmlApp.addChild the button is added and appeared on the stage normally, so there is no problem with the use of mxmlApp.addChild. Best regards dennis
[flexcoders] addChild using actionscript
hi guys. i was reading flex3 for dummies page 221 on containers and it gave an example of adding childen using actionscript. it worked fine. but i thought about adding a removeChild function. but it doesnt seem to be working. can someone tell me why? i apologize if this is a stupid mistake. - ?xml version='1.0' encoding='utf-8'? mx:Application xmlns:mx='http://www.adobe.com/2006/mxml' layout='vertical' mx:Script ![CDATA[ import mx.controls.CheckBox; private function addCheckBox():void { var checkBox:CheckBox = new CheckBox(); checkBox.label = Checkbox + (myVBox.numChildren + 1); myVBox.addChild(checkBox); } private function removeCheckBox():void { var checkBox1:CheckBox = new CheckBox(); checkBox1.label = Checkbox + (myVBox.numChildren - 1); myVBox.removeChild(checkBox1); } ]] /mx:Script mx:Button label='Add Checkbox' click='addCheckBox()' / mx:Button label='Remove Checkbox' click='removeCheckBox()' / mx:VBox id='myVBox' / /mx:Application
Re: [flexcoders] addChild using actionscript
You are trying to remove a child that has never been added. In your addCheckBox function you are creating a new CheckBox and then adding it which is fine but then in your removeCheckBox function you are again creating a brand new CheckBox and trying to remove it. This will not work because the new CheckBox in removeCheckBox has never been added. What you need to do is reference the CheckBox that you created in yoru addCheckBox function. You could do this by moving the checkBox var outside of the functions and just make it a public var. Or when you create the CheckBox you could set it's name property in addCheckBox and then in your removeCheckBox do myVBox.removeChild)myVBox.removeChild.getChildByName(whatevername)); On Mon, Jun 29, 2009 at 5:30 AM, ew6014 ew6...@yahoo.com wrote: hi guys. i was reading flex3 for dummies page 221 on containers and it gave an example of adding childen using actionscript. it worked fine. but i thought about adding a removeChild function. but it doesnt seem to be working. can someone tell me why? i apologize if this is a stupid mistake. - ?xml version='1.0' encoding='utf-8'? mx:Application xmlns:mx='http://www.adobe.com/2006/mxml' layout='vertical' mx:Script ![CDATA[ import mx.controls.CheckBox; private function addCheckBox():void { var checkBox:CheckBox = new CheckBox(); checkBox.label = Checkbox + (myVBox.numChildren + 1); myVBox.addChild(checkBox); } private function removeCheckBox():void { var checkBox1:CheckBox = new CheckBox(); checkBox1.label = Checkbox + (myVBox.numChildren - 1); myVBox.removeChild(checkBox1); } ]] /mx:Script mx:Button label='Add Checkbox' click='addCheckBox()' / mx:Button label='Remove Checkbox' click='removeCheckBox()' / mx:VBox id='myVBox' / /mx:Application
[flexcoders] addChild and transition issue
I have two states and possibility to jump between them. All works fine until one click inadvertently goes faster than the transition... then I get an already parented error on the addchild... To explain better: If I go from state a to state b and viceversa waiting the transition times no problem occurs... If I jump from state a to state b then back to state a without waiting the full time of the transition the already parented error occurs. from what I understood if you jump from one state to another in the middle of a transition the played effect gets stopped and the new one starts... shouldn't there be a similar mechanism for child adding/removing? Any idea how to bypass the problem or stop the error from blocking/messing all the GUI structure? thanks Gio
[flexcoders] addChild() (not addChildAt) throws RangeError: Error #2006: The supplied index is out of bounds
The stack trace follows. I'm curious as to how addChild() can be throwing a range error, when it's clearly determining the range itself. Is it that the component is somehow not ready to accept children or something? Thanks, Maciek Sakrejda Stacktrace:RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/addChildAt() at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal:: $addChildAt()[E:\dev\flex_201_borneo\sdk\frameworks\mx\core \UIComponent.as:4680] at mx.core::Container/addChildAt()[C:\dev\flex_201_gmc\sdk\frameworks \mx\core\Container.as:2278] at mx.core::Container/addChild()[C:\dev\flex_201_gmc\sdk\frameworks\mx \core\Container.as:2214] at com.truviso.application.ui.visualization.visualizer::Visualizer/com.truviso.application.ui.visualization.visualizer:Visualizer::initButtonBar()[/home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/application/WEB-INF/flex/user_classes/com/truviso/application/ui/visualization/visualizer/Visualizer.as:405] at com.truviso.application.ui.visualization.visualizer::Visualizer/postInit()[/home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/application/WEB-INF/flex/user_classes/com/truviso/application/ui/visualization/visualizer/Visualizer.as:168] at com.truviso.application.ui.visualization::VisualizationController/launchVisualizationWithParamValues()[/home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/application/WEB-INF/flex/user_classes/com/truviso/application/ui/visualization/VisualizationController.as:383] at com.truviso.application.ui.visualization.visualizer::Visualizer/openDrilldown()[/home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/application/WEB-INF/flex/user_classes/com/truviso/application/ui/visualization/visualizer/Visualizer.as:613]
RE: [flexcoders] addChild() (not addChildAt) throws RangeError: Error #2006: Thesupplied index is out of bounds
The number of children in a container is virtualized so if you've fooled it somehow, it will use the wrong index. You'll have to figure out how it got fooled From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Maciek Sakrejda Sent: Monday, June 02, 2008 7:24 PM To: flexcoders Subject: [flexcoders] addChild() (not addChildAt) throws RangeError: Error #2006: Thesupplied index is out of bounds The stack trace follows. I'm curious as to how addChild() can be throwing a range error, when it's clearly determining the range itself. Is it that the component is somehow not ready to accept children or something? Thanks, Maciek Sakrejda Stacktrace:RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/addChildAt() at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal:: http://www.adobe.com/2006/flex/mx/internal:: $addChildAt()[E:\dev\flex_201_borneo\sdk\frameworks\mx\core \UIComponent.as:4680] at mx.core::Container/addChildAt()[C:\dev\flex_201_gmc\sdk\frameworks \mx\core\Container.as:2278] at mx.core::Container/addChild()[C:\dev\flex_201_gmc\sdk\frameworks\mx \core\Container.as:2214] at com.truviso.application.ui.visualization.visualizer::Visualizer/com.truv iso.application.ui.visualization.visualizer:Visualizer::initButtonBar()[ /home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/application/W EB-INF/flex/user_classes/com/truviso/application/ui/visualization/visual izer/Visualizer.as:405] at com.truviso.application.ui.visualization.visualizer::Visualizer/postInit ()[/home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/applicatio n/WEB-INF/flex/user_classes/com/truviso/application/ui/visualization/vis ualizer/Visualizer.as:168] at com.truviso.application.ui.visualization::VisualizationController/launch VisualizationWithParamValues()[/home/maciek/svn/scripts/packaging/trunk/ build/blank/xdeps/application/WEB-INF/flex/user_classes/com/truviso/appl ication/ui/visualization/VisualizationController.as:383] at com.truviso.application.ui.visualization.visualizer::Visualizer/openDril ldown()[/home/maciek/svn/scripts/packaging/trunk/build/blank/xdeps/appli cation/WEB-INF/flex/user_classes/com/truviso/application/ui/visualizatio n/visualizer/Visualizer.as:613]
Re: [flexcoders] addChild vs. addRawChild and performance
So you are saying that instead of using a Canvas as the container inside of my app, I could just use UIComponent or ScrollControlBase? Any idea of how much performance gain this could be? On 1/22/08, Alex Harui [EMAIL PROTECTED] wrote: It would be best to not use containers and just use UIComponent or ScrollControlBase -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Steve Mathews *Sent:* Tuesday, January 22, 2008 12:52 PM *To:* flexcoders@yahoogroups.com *Subject:* [flexcoders] addChild vs. addRawChild and performance Someone posted recently describing that addRawChild adds DisplayObject in a way that they are not included in the size and layout of the container (if I understood correctly). Does anyone know if this would be better or worse for the overall performance of a Flex app? So if you did not need layout features of the framework, would it be better to add everything as raw children?
RE: [flexcoders] addChild vs. addRawChild and performance
It depends, but UIComponent doesn't care about clipping, scrollbars, etc. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Wednesday, January 23, 2008 8:02 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild vs. addRawChild and performance So you are saying that instead of using a Canvas as the container inside of my app, I could just use UIComponent or ScrollControlBase? Any idea of how much performance gain this could be? On 1/22/08, Alex Harui [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: It would be best to not use containers and just use UIComponent or ScrollControlBase From: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com ] On Behalf Of Steve Mathews Sent: Tuesday, January 22, 2008 12:52 PM To: flexcoders@yahoogroups.com mailto:flexcoders@yahoogroups.com Subject: [flexcoders] addChild vs. addRawChild and performance Someone posted recently describing that addRawChild adds DisplayObject in a way that they are not included in the size and layout of the container (if I understood correctly). Does anyone know if this would be better or worse for the overall performance of a Flex app? So if you did not need layout features of the framework, would it be better to add everything as raw children?
[flexcoders] addChild vs. addRawChild and performance
Someone posted recently describing that addRawChild adds DisplayObject in a way that they are not included in the size and layout of the container (if I understood correctly). Does anyone know if this would be better or worse for the overall performance of a Flex app? So if you did not need layout features of the framework, would it be better to add everything as raw children?
RE: [flexcoders] addChild vs. addRawChild and performance
It would be best to not use containers and just use UIComponent or ScrollControlBase From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Mathews Sent: Tuesday, January 22, 2008 12:52 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] addChild vs. addRawChild and performance Someone posted recently describing that addRawChild adds DisplayObject in a way that they are not included in the size and layout of the container (if I understood correctly). Does anyone know if this would be better or worse for the overall performance of a Flex app? So if you did not need layout features of the framework, would it be better to add everything as raw children?
[flexcoders] addchild
I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild(ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ?
Re: [flexcoders] addchild
Here is an example of this sort of thing. I have seen it over and over again. http://www.actionscript.com/Article/tabid/54/ArticleID/ActionScript-3-0-Display-Lists-and-Display-Object/Default.aspx it shows the shape class and function public class CircleShape extends Sprite { public function CircleShape() But nowhere is any code for actually using this class. When I try it I get private var myball:CircleShape; myball=new CircleShape Cannot access a property or method of a null object reference. It would all be so much simpler if they would just show the complete example. [EMAIL PROTECTED] wrote: I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild(ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ?
Re: [flexcoders] addchild
addChild not addchild - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Thursday, January 17, 2008 11:03:15 PM Subject: [flexcoders] addchild I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild( ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ? Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs
Re: [flexcoders] addchild
OK thanks. Now when I try to use addChild, I get this error. What does it mean ? myball=new Ball; addChild(myball); TypeError: Error #1034: Type Coercion failed: cannot convert com.oreilly.programmingflex.states::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild() at mx.core::Container/addChildAt() at mx.core::Container/addChild() at Main/::initializeHandler() at Main/___Application1_initialize() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.core::UIComponent/set processedDescriptors() at mx.core::Container/createComponentsFromDescriptors() Sherif Abdou wrote: addChild not addchild - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Thursday, January 17, 2008 11:03:15 PM Subject: [flexcoders] addchild I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild( ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ? Never miss a thing. Make Yahoo your homepage. http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs
Re: [flexcoders] addchild
it means that the ball is not a IUIcomponenet which it is required for it to be added on stage, show me a bit of the ball class code so i can know - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Thursday, January 17, 2008 11:38:26 PM Subject: Re: [flexcoders] addchild OK thanks. Now when I try to use addChild, I get this error. What does it mean ? myball=new Ball; addChild(myball) ; TypeError: Error #1034: Type Coercion failed: cannot convert com.oreilly. programmingflex. states::Ball@ 5787299 to mx.core.IUIComponen t. at mx.core::Container/http://www.adobe. com/2006/ flex/mx/internal ::addingChild() at mx.core::Container/ addChildAt( ) at mx.core::Container/ addChild( ) at Main/::initializeHa ndler() at Main/___Application 1_initialize( ) at flash.events: :EventDispatcher /flash.events: EventDispatcher: :dispatchEventFu nction() at flash.events: :EventDispatcher /dispatchEvent( ) at mx.core::UIComponen t/dispatchEvent( ) at mx.core::UIComponen t/set processedDescriptor s() at mx.core::Container/ createComponents FromDescriptors( ) Sherif Abdou wrote: addChild not addchild - Original Message From: [EMAIL PROTECTED] org [EMAIL PROTECTED] org To: [EMAIL PROTECTED] ups.com Sent: Thursday, January 17, 2008 11:03:15 PM Subject: [flexcoders] addchild I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild( ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ? - - - - - - Never miss a thing. Make Yahoo your homepage. http://us.rd. yahoo.com/ evt=51438/ *http://www. yahoo.com/ r/hs Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
Re: [flexcoders] addchild
This is the entire ball class package com.oreilly.programmingflex.states { import flash.display.Sprite; public class Ball extends Sprite { private var radius:Number; private var color:uint; public function Ball(radius:Number=40, color:uint=0xff) { this.radius = radius; this.color = color; init(); } public function init():void { graphics.beginFill(color); graphics.drawCircle(0, 0, radius); graphics.endFill(); } } } Sherif Abdou wrote: it means that the ball is not a IUIcomponenet which it is required for it to be added on stage, show me a bit of the ball class code so i can know - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Thursday, January 17, 2008 11:38:26 PM Subject: Re: [flexcoders] addchild OK thanks. Now when I try to use addChild, I get this error. What does it mean ? myball=new Ball; addChild(myball) ; TypeError: Error #1034: Type Coercion failed: cannot convert com.oreilly. programmingflex. states::Ball@ 5787299 to mx.core.IUIComponen t. at mx.core::Container/http://www.adobe. com/2006/ flex/mx/internal ::addingChild http://www.adobe.com/2006/flex/mx/internal::addingChild() at mx.core::Container/ addChildAt( ) at mx.core::Container/ addChild( ) at Main/::initializeHa ndler() at Main/___Application 1_initialize( ) at flash.events: :EventDispatcher /flash.events: EventDispatcher: :dispatchEventFu nction() at flash.events: :EventDispatcher /dispatchEvent( ) at mx.core::UIComponen t/dispatchEvent( ) at mx.core::UIComponen t/set processedDescriptor s() at mx.core::Container/ createComponents FromDescriptors( ) Sherif Abdou wrote: addChild not addchild - Original Message From: [EMAIL PROTECTED] org mailto:info1%40reenie.org [EMAIL PROTECTED] org mailto:info1%40reenie.org To: [EMAIL PROTECTED] ups.com mailto:flexcoders%40yahoogroups.com Sent: Thursday, January 17, 2008 11:03:15 PM Subject: [flexcoders] addchild I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild( ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ? - - - - - - Never miss a thing. Make Yahoo your homepage. http://us.rd. yahoo.com/ evt=51438/ *http://www. yahoo.com/ r/hs http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20
Re: [flexcoders] addchild
never mind, elaborate a bit more ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute creationComplete=initApp() mx:Script ![CDATA[ private function initApp():void{ vbox.addChild(/*whatever u want*/); } ]] /mx:Script mx:VBox id=vbox/ /mx:Application - Original Message From: [EMAIL PROTECTED] [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Thursday, January 17, 2008 11:03:15 PM Subject: [flexcoders] addchild I have a ball class. I can make a ball. How do I add it to the stage ? I have seem plenty of examples, and they use addchild. Every time I try to use addchild, I get this error: Error: Call to a possibly undefined method addChild. or if I try to attach it to an existing element such as mx:VBox id=vbox vbox.addchild( ball); I get :Error: Access of undefined property vbox. So what can I put addchild on ? Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
RE: [flexcoders] addChild(bitmap) problems
Was this ever resolved? I seems like it's not the right behavior. If it is, how would Jason accomplish his goal (and I know the answer isn't FlexBitmap...) Is it off to rawChildren? Can anyone see the error in this setup? //drawTest.mxml file: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=init() backgroundColor=0xFF mx:Script ![CDATA[ import src.DrawBitmap; private function init():void { var spiral:DrawBitmap = new DrawBitmap(myCanvas); } ]] /mx:Script mx:Canvas id=myCanvas x=10 y=10 width=774 height=463 borderColor=0xD4001A borderStyle=solid/ /mx:Application // DrawBitmap.as class: package src { import mx.containers.Canvas; import flash.display.BitmapData; import flash.display.Bitmap; import flash.geom.Rectangle; public class DrawBitmap { private var _canvas:Canvas; private var _bitmap:Bitmap; private var _imgData:BitmapData; public function DrawBitmap(canvas:Canvas):void { _canvas = canvas; _imgData = new BitmapData(20, 20, false, 0xFF00FF00); _imgData.fillRect(new Rectangle(5, 5, 10, 10), 0xFFFF); _bitmap = new Bitmap(_imgData); _canvas.addChild(_bitmap); //Produces error } } } At runtime, I get this error in the debugger: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal: :addingChild()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:3303] Seems to appear on the last line of the DrawBitmap class when I do _canvas.addChild(_bitmap). That seems legal to me - add a bitmap display object to a canvas display object. No? What am I missing? If that's not legal, then how to add my bitmap object to the canvas? Thanks, Jason Merrill Bank of America LLD GTO eTools Multimedia Research Development
RE: [flexcoders] addChild(bitmap) problems
Crazy... I just opened my email client to send a similar email. The only difference is that I want to add a FlexShape. -Original Message- Can anyone see the error in this setup? //drawTest.mxml file: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute applicationComplete=init() backgroundColor=0xFF mx:Script ![CDATA[ import src.DrawBitmap; private function init():void { var spiral:DrawBitmap = new DrawBitmap(myCanvas); } ]] /mx:Script mx:Canvas id=myCanvas x=10 y=10 width=774 height=463 borderColor=0xD4001A borderStyle=solid/ /mx:Application // DrawBitmap.as class: package src { import mx.containers.Canvas; import flash.display.BitmapData; import flash.display.Bitmap; import flash.geom.Rectangle; public class DrawBitmap { private var _canvas:Canvas; private var _bitmap:Bitmap; private var _imgData:BitmapData; public function DrawBitmap(canvas:Canvas):void { _canvas = canvas; _imgData = new BitmapData(20, 20, false, 0xFF00FF00); _imgData.fillRect(new Rectangle(5, 5, 10, 10), 0xFFFF); _bitmap = new Bitmap(_imgData); _canvas.addChild(_bitmap); //Produces error } } } At runtime, I get this error in the debugger: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal: :addingChild()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:3303] Seems to appear on the last line of the DrawBitmap class when I do _canvas.addChild(_bitmap). That seems legal to me - add a bitmap display object to a canvas display object. No? What am I missing? If that's not legal, then how to add my bitmap object to the canvas? Thanks, Jason Merrill Bank of America LLD GTO eTools Multimedia Research Development
RE: [flexcoders] addChild(bitmap) problems
Canvas.addChild() only accepts UIComponents? No, it wants a DisplayObject.
[flexcoders] addChild(bitmap) problems
Can anyone see the error in this setup? //drawTest.mxml file: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=init() backgroundColor=0xFF mx:Script ![CDATA[ import src.DrawBitmap; private function init():void { var spiral:DrawBitmap = new DrawBitmap(myCanvas); } ]] /mx:Script mx:Canvas id=myCanvas x=10 y=10 width=774 height=463 borderColor=0xD4001A borderStyle=solid/ /mx:Application // DrawBitmap.as class: package src { import mx.containers.Canvas; import flash.display.BitmapData; import flash.display.Bitmap; import flash.geom.Rectangle; public class DrawBitmap { private var _canvas:Canvas; private var _bitmap:Bitmap; private var _imgData:BitmapData; public function DrawBitmap(canvas:Canvas):void { _canvas = canvas; _imgData = new BitmapData(20, 20, false, 0xFF00FF00); _imgData.fillRect(new Rectangle(5, 5, 10, 10), 0xFFFF); _bitmap = new Bitmap(_imgData); _canvas.addChild(_bitmap); //Produces error } } } At runtime, I get this error in the debugger: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChi ld()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:3303] Seems to appear on the last line of the DrawBitmap class when I do _canvas.addChild(_bitmap). That seems legal to me - add a bitmap display object to a canvas display object. No? What am I missing? If that's not legal, then how to add my bitmap object to the canvas? Thanks, Jason Merrill Bank of America LLD GTO eTools Multimedia Research Development
Re: [flexcoders] addChild(bitmap) problems
Canvas.addChild() only accepts UIComponents? On 11/12/2007, at 10:01 AM, Merrill, Jason wrote: Can anyone see the error in this setup? //drawTest.mxml file: ?xml version=1.0 encoding=utf-8? mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; layout=absolute applicationComplete=init() backgroundColor=0xFF mx:Script ![CDATA[ import src.DrawBitmap; private function init():void { var spiral:DrawBitmap = new DrawBitmap(myCanvas); } ]] /mx:Script mx:Canvas id=myCanvas x=10 y=10 width=774 height=463 borderColor=0xD4001A borderStyle=solid/ /mx:Application // DrawBitmap.as class: package src { import mx.containers.Canvas; import flash.display.BitmapData; import flash.display.Bitmap; import flash.geom.Rectangle; public class DrawBitmap { private var _canvas:Canvas; private var _bitmap:Bitmap; private var _imgData:BitmapData; public function DrawBitmap(canvas:Canvas):void { _canvas = canvas; _imgData = new BitmapData(20, 20, false, 0xFF00FF00); _imgData.fillRect(new Rectangle(5, 5, 10, 10), 0xFFFF); _bitmap = new Bitmap(_imgData); _canvas.addChild(_bitmap); //Produces error } } } At runtime, I get this error in the debugger: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. at mx.core::Container/http://www.adobe.com/2006/flex/mx/ internal::addingChild()[C:\dev\GMC\sdk\frameworks\mx\core \Container.as:3303] Seems to appear on the last line of the DrawBitmap class when I do _canvas.addChild(_bitmap). That seems legal to me - add a bitmap display object to a canvas display object. No? What am I missing? If that's not legal, then how to add my bitmap object to the canvas? Thanks, Jason Merrill Bank of America LLD GTO eTools Multimedia Research Development
[flexcoders] AddChild
Hi guys, need your help. kinda stuck i need to create an addchild of an accordian with a vbox containing a datagrid. i have successfully created this however, due to project restriction, the header of the accordian when created needs to prompt the user to enter the title which will show up on the accordian's header and choose an icon that would show up to the left of the header's text! anyways you guys can help. i am unable to do this. thanks all
RE: [flexcoders] AddChild
Not sure I understand how you want it to look. Do you want the title entry and icon selection to happen in an accordion 'panel'? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of kareemisk Sent: Tuesday, October 23, 2007 7:13 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] AddChild Hi guys, need your help. kinda stuck i need to create an addchild of an accordian with a vbox containing a datagrid. i have successfully created this however, due to project restriction, the header of the accordian when created needs to prompt the user to enter the title which will show up on the accordian's header and choose an icon that would show up to the left of the header's text! anyways you guys can help. i am unable to do this. thanks all
[flexcoders] addChild creationCompleteEffect
Hi all, I create a TitleWindow with the PopupManager. The titlewindow should dynamically contain a canvas. So how did I do that. I gave the titlewindow a property called 'contentForm' which contains a canvas. Then in the creationComplete-event of the titlewindow, addChild(contentForm) is called for adding the canvas to the titlewindow. So far, so good... Next I wanted to create some popup/popout effect on the titlewindow. So I set creationCompleteEffect to 'popup', a mx:Parallel of zoom/move/fade. I also set the removedEffect to 'popout', a mx:Sequence. What's the problem? The 'popup'-effect should move the titlewindow from the top to the center of the application. I figured this move-tag would give me what needed: mx:Move yFrom={-this.height} yTo={(Application.application.height - this.height) / 2} xFrom={Application.application.width / 2} xTo={(Application.application.width - this.width) / 2} / However, this isn't working as expected. The only logical explanation I can come up with is the following: creationComplete and creationCompleteEffect both get executed when the creationcomplete-Event is fired. Since the childComponent is only added during the handling of that event, the effect playing is not yet aware of the change in size. This lead me into the FlexDocs, where I learned that adding children should be part of the initialisationEvent. So I assigned my init()method to the initialize-listener instead of creationComplete. However, this is giving me the following errors: TypeError: Error #1009: Cannot access a property or method of a null object reference. at mx.containers::Panel/::showTitleBar() at mx.containers::Panel/mx.containers:Panel::layoutChrome() at mx.core::Container/mx.core:Container::updateDisplayList() ... TypeError: Error #1009: Cannot access a property or method of a null object reference. at components::PopupFormWindow/::init() at components::PopupFormWindow/___TitleWindow1_initialize() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction() ... My init-method is as follows: private function init():void { //create inner form contentForm.currentState = this.currentState; (contentForm as customerPopupForm).ac = this.ac; this.addChild(contentForm); } Any help, push in the right direction is really appreciated. I will provide the full errormsgs/more code if needed, but I consider this to be a long post already ;) --Johan
Re: [flexcoders] addChild to UITextField?
Jon, Any way we can see the code on the way you did this? I have a need for it, but it is on the back burner for now. Any insight would be a world of help. Thanks for any insight, Tony Jon Bradley wrote: Thanks for all your help on this guys. I finally figured it all out. Jeez - took long enough. Now I just have to optimize it a bit. The end solution was to wrap it in UIComponent (dumb style propagation). UIComponent is just beefy and way more than I need for this, but it works so I'll live with it for now. All the work was worth it though, I have a relatively high quality bitmap representation of text that can be rotated, scaled realtime by an end user and I don't have to load a dang font to do it. Finally. rock on! - jon -- 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/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * 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] addChild to UITextField?
Tony, Check out my last post titled Techniques for rotating non-embedded fonts. I detailed a bit more of the solution and included parts of a setTransform method that breaks up the processes. My draw method for the text is pretty straightforward - draw the text field into a bitmap (but make sure it's visible, then draw, then invisible). The hardest part to all this will be dealing with the runtime CSS and font loading, if you want to use that in conjunction with device fonts. Right now I have a FontCollection model that stores are loaded and device fonts in a list (separate VOs for each). The UIComponent does the heavy lifting here. Also, you may run into issues with the antialias property warnings - regenerateStyleCache(false) will be your friend here. good luck, jon On Aug 31, 2007, at 11:53 AM, Tony Alves wrote: Jon, Any way we can see the code on the way you did this? I have a need for it, but it is on the back burner for now. Any insight would be a world of help. Thanks for any insight, Tony Jon Bradley wrote: Thanks for all your help on this guys. I finally figured it all out. Jeez - took long enough. Now I just have to optimize it a bit. The end solution was to wrap it in UIComponent (dumb style propagation). UIComponent is just beefy and way more than I need for this, but it works so I'll live with it for now. All the work was worth it though, I have a relatively high quality bitmap representation of text that can be rotated, scaled realtime by an end user and I don't have to load a dang font to do it. Finally. rock on! - jon -- 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
RE: [flexcoders] addChild to UITextField?
For what it's worth, if you have a registered copy of the charting components, there's a class that does essentially what jon is describing: mx.charts.chartClasses.ChartLabel. It's what the charts use for axis titles. It uses native font rendering if the font is embedded or if the label's composite transform is unscaled and unrotated, or blits the text field into a bitmap for display otherwise. (You'll get higher quality rendering if you avoid the bitmap issue, since blitting into a bitmap turns off sub pixel antialiasing, so it's best to avoid that code path whenever possible). Ely. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Friday, August 31, 2007 10:18 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild to UITextField? Tony, Check out my last post titled Techniques for rotating non-embedded fonts. I detailed a bit more of the solution and included parts of a setTransform method that breaks up the processes. My draw method for the text is pretty straightforward - draw the text field into a bitmap (but make sure it's visible, then draw, then invisible). The hardest part to all this will be dealing with the runtime CSS and font loading, if you want to use that in conjunction with device fonts. Right now I have a FontCollection model that stores are loaded and device fonts in a list (separate VOs for each). The UIComponent does the heavy lifting here. Also, you may run into issues with the antialias property warnings - regenerateStyleCache(false) will be your friend here. good luck, jon On Aug 31, 2007, at 11:53 AM, Tony Alves wrote: Jon, Any way we can see the code on the way you did this? I have a need for it, but it is on the back burner for now. Any insight would be a world of help. Thanks for any insight, Tony Jon Bradley wrote: Thanks for all your help on this guys. I finally figured it all out. Jeez - took long enough. Now I just have to optimize it a bit. The end solution was to wrap it in UIComponent (dumb style propagation). UIComponent is just beefy and way more than I need for this, but it works so I'll live with it for now. All the work was worth it though, I have a relatively high quality bitmap representation of text that can be rotated, scaled realtime by an end user and I don't have to load a dang font to do it. Finally. rock on! - jon -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders% http://www.mail-archive.com/flexcoders%25 40yahoogroups.com Yahoo! Groups Links image001.jpgimage002.jpg
[flexcoders] addChild to UITextField?
Has anyone ever tried to do this? Is there any available hacks using _internal or something so that children can be added to a UITextField (either by multiple inheritance or something with a Sprite?). Yargh.
Re: [flexcoders] addChild to UITextField?
Well, I believe TextField's are leaf nodes, meaning they can't have children. Also, if you'll look at the Object Heirarchy, there's no DisplayObjectContainer in there -- so I doubt you're going to get much traction. You're better off making a UIComponent and putting a text field inside of it. -Kyle
RE: [flexcoders] addChild to UITextField?
Not possible. It is not a DisplayObjectContainer. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Thursday, August 30, 2007 8:46 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] addChild to UITextField? Has anyone ever tried to do this? Is there any available hacks using _internal or something so that children can be added to a UITextField (either by multiple inheritance or something with a Sprite?). Yargh.
Re: [flexcoders] addChild to UITextField?
Thanks Kyle. Yea, I assumed that already. What I'm trying to figure out is if it's possible to create a combination of a UITextField and a sprite as a single class. flash.display.DisplayObjectContainer isnt' available anywhere to look at, and I'm wondering if that's an intrinsic class to begin with... On Aug 30, 2007, at 12:17 PM, Kyle Neath wrote: Well, I believe TextField's are leaf nodes, meaning they can't have children. Also, if you'll look at the Object Heirarchy, there's no DisplayObjectContainer in there -- so I doubt you're going to get much traction. You're better off making a UIComponent and putting a text field inside of it. -Kyle
Re: [flexcoders] addChild to UITextField?
Yea, but the question would then be can I decorate a UITextField with the capabilities of a Sprite, or is the DisplayObjectContainer intrinsic and that's not possible. If I can, I'd extend TextField/FlexTextField/UITextField if necessary to put in the _children property. Mainly trying to figure out an effective way to rotate system level text. Scale and all that works great (up to the 2880 size, then the text disappears). Tricky... and a fair amount of code so far. Just trying not to get a big bloated piece of code to do a bitmap representation of the text field to just handle rotation. :) On Aug 30, 2007, at 4:26 PM, Alex Harui wrote: Not possible. It is not a DisplayObjectContainer.
RE: [flexcoders] addChild to UITextField?
You can add a _children property, but you can't get it to render children. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Thursday, August 30, 2007 1:55 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild to UITextField? Yea, but the question would then be can I decorate a UITextField with the capabilities of a Sprite, or is the DisplayObjectContainer intrinsic and that's not possible. If I can, I'd extend TextField/FlexTextField/UITextField if necessary to put in the _children property. Mainly trying to figure out an effective way to rotate system level text. Scale and all that works great (up to the 2880 size, then the text disappears). Tricky... and a fair amount of code so far. Just trying not to get a big bloated piece of code to do a bitmap representation of the text field to just handle rotation. :) On Aug 30, 2007, at 4:26 PM, Alex Harui wrote: Not possible. It is not a DisplayObjectContainer.
Re: [flexcoders] addChild to UITextField?
On Aug 30, 2007, at 5:23 PM, Alex Harui wrote: You can add a _children property, but you can’t get it to render children. Well... at least I won't try to go down that route now. :) Related to the same problem ... do you know if there is an event triggered when the style of a UITextField is modified (and the result is applied/rendered)? I have it almost working but I can't seem to get the field to draw into the bitmap at the right time. It's always drawing before the text field itself is resized or the font or other properties change. closer...
RE: [flexcoders] addChild to UITextField?
I think if you override validateNow(), when it comes back it is pretty much done. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Thursday, August 30, 2007 4:04 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild to UITextField? On Aug 30, 2007, at 5:23 PM, Alex Harui wrote: You can add a _children property, but you can't get it to render children. Well... at least I won't try to go down that route now. :) Related to the same problem ... do you know if there is an event triggered when the style of a UITextField is modified (and the result is applied/rendered)? I have it almost working but I can't seem to get the field to draw into the bitmap at the right time. It's always drawing before the text field itself is resized or the font or other properties change. closer...
Re: [flexcoders] addChild to UITextField?
Thanks for all your help on this guys. I finally figured it all out. Jeez - took long enough. Now I just have to optimize it a bit. The end solution was to wrap it in UIComponent (dumb style propagation). UIComponent is just beefy and way more than I need for this, but it works so I'll live with it for now. All the work was worth it though, I have a relatively high quality bitmap representation of text that can be rotated, scaled realtime by an end user and I don't have to load a dang font to do it. Finally. rock on! - jon On Aug 30, 2007, at 8:01 PM, Alex Harui wrote: I think if you override validateNow(), when it comes back it is pretty much done. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jon Bradley Sent: Thursday, August 30, 2007 4:04 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild to UITextField? On Aug 30, 2007, at 5:23 PM, Alex Harui wrote: You can add a _children property, but you can’t get it to render children. Well... at least I won't try to go down that route now. :) Related to the same problem ... do you know if there is an event triggered when the style of a UITextField is modified (and the result is applied/rendered)? I have it almost working but I can't seem to get the field to draw into the bitmap at the right time. It's always drawing before the text field itself is resized or the font or other properties change. closer...
[flexcoders] AddChild problem
I am not sure this as much a problem as I am probably doing something wrong. I am adding child components at runtime to a vbox. These new components can be dragged to a new position. This all works. The 'problem' is that when anytime a new child is added, all the child components move the top left corner of the container they are added to. Code Below: public function creatObj(what:String):void{ var obj:UIComponent; switch(what){ case rssFirstName: obj = new textComponent; //container_vb.addChild(obj); break; case rssLastName: obj = new textComponent; //container_vb.addChild(obj); break; case rssEmail: break; case text: obj = new textComponent; //container_vb.addChild(obj); break; case textArea: obj = new textAreaComponent; //container_vb.addChild(obj); break; case checkBox: obj = new checkboxComponent; //container_vb.addChild(obj); break; default: break; } container_vb.addChild(obj); } I really need to figure out why this is happening, so any guidance is appreciated. Thanks -- I am not a diabetic, I have diabetes my blog - http://grumpee.instantspot.com/blog
RE: [flexcoders] AddChild problem
Adding children runs layout which for VBox will wrestle everything into a vertical stack. Canvas is better for random' positioning. From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Clint Tredway Sent: Friday, June 01, 2007 8:31 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] AddChild problem I am not sure this as much a problem as I am probably doing something wrong. I am adding child components at runtime to a vbox. These new components can be dragged to a new position. This all works. The 'problem' is that when anytime a new child is added, all the child components move the top left corner of the container they are added to. Code Below: public function creatObj(what:String):void{ var obj:UIComponent; switch(what){ case rssFirstName: obj = new textComponent; //container_vb.addChild(obj); break; case rssLastName: obj = new textComponent; //container_vb.addChild(obj); break; case rssEmail: break; case text: obj = new textComponent; //container_vb.addChild(obj); break; case textArea: obj = new textAreaComponent; //container_vb.addChild(obj); break; case checkBox: obj = new checkboxComponent; //container_vb.addChild(obj); break; default: break; } container_vb.addChild(obj); } I really need to figure out why this is happening, so any guidance is appreciated. Thanks -- I am not a diabetic, I have diabetes my blog - http://grumpee.instantspot.com/blog http://grumpee.instantspot.com/blog
Re: [flexcoders] AddChild problem
Good to know. I did find a work around by adding the children to the main app container and that now works. I will change my vbox to a canvas and see what happens. On 6/1/07, Alex Harui [EMAIL PROTECTED] wrote: Adding children runs layout which for VBox will wrestle everything into a vertical stack. Canvas is better for random' positioning. -- *From:* flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Clint Tredway *Sent:* Friday, June 01, 2007 8:31 AM *To:* flexcoders@yahoogroups.com *Subject:* [flexcoders] AddChild problem I am not sure this as much a problem as I am probably doing something wrong. I am adding child components at runtime to a vbox. These new components can be dragged to a new position. This all works. The 'problem' is that when anytime a new child is added, all the child components move the top left corner of the container they are added to. Code Below: public function creatObj(what:String):void{ var obj:UIComponent; switch(what){ case rssFirstName: obj = new textComponent; //container_vb.addChild(obj); break; case rssLastName: obj = new textComponent; //container_vb.addChild(obj); break; case rssEmail: break; case text: obj = new textComponent; //container_vb.addChild(obj); break; case textArea: obj = new textAreaComponent; //container_vb.addChild(obj); break; case checkBox: obj = new checkboxComponent; //container_vb.addChild(obj); break; default: break; } container_vb.addChild(obj); } I really need to figure out why this is happening, so any guidance is appreciated. Thanks -- I am not a diabetic, I have diabetes my blog - http://grumpee.instantspot.com/blog -- I am not a diabetic, I have diabetes my blog - http://grumpee.instantspot.com/blog
RE: [flexcoders] addChild problems
Hi You need to type cast the object/component to DisplayObject Just keep in mind: any container you want to add any object just typecast to DisplayObject(); i.e Here mainGrpHolder is some kind of holder container i.e canvas, VBox, HBox var gObj: ColumnChart = new ColumnChart (); mainGrpHolder.addChildAt(DisplayObject(gObj),i); or mainGrpHolder.addChild(DisplayObject(gObj)); For using any properties for component/object added use: reverse the type-cast . gObj = ColumnChart (mainGrpHolder.getChildAt(i)); trace(gObj.PropertName); trace(gObj.methodName()); This works very fine,I used it. Thanks Regards Jolly Life Fitness - A Division of Brunswick Corporation #09-02, The Signature, Changi Business Park Central 2, Singapore-486066 (Cell) 65 -96216408 (Tel) 65-62606409 (Fax) 65-62605150 http://www.lifefitness.com http://www.lifefitness.com/ | http://www.brunswick.com http://www.brunswick.com/ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Manish Jethani Sent: Saturday, April 28, 2007 10:20 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild problems On 4/26/07, Jason C Reynolds [EMAIL PROTECTED] mailto:jreynolds%40thewritesource.com wrote: 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. So if you add the Text object directly to the Canvas, it works, but, if there's a UIComponent in between, it doesn't. Canvas = UIComponent = Text // doesn't work Canvas = Text // works Suggestions: 1) Check question.parent.parent ... is it pointing to the Canvas? 2) Compile with -debug and see if you're getting a runtime error (and see the stack trace) 3) Are you overriding measure() in your UIComponent? If not, at least set its width and height explicitly.
RE: [flexcoders] addChild problems
Make sure the dynamically added component has a non-zero height and width. Tracy From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jason C Reynolds Sent: Wednesday, April 25, 2007 6:01 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] addChild problems 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 mailto:[EMAIL PROTECTED] To: flexcoders@yahoogroups.com mailto: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] mailto:[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
Re: [flexcoders] addChild problems
On 4/26/07, Jason C Reynolds [EMAIL PROTECTED] wrote: 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. So if you add the Text object directly to the Canvas, it works, but, if there's a UIComponent in between, it doesn't. Canvas = UIComponent = Text // doesn't work Canvas = Text // works Suggestions: 1) Check question.parent.parent ... is it pointing to the Canvas? 2) Compile with -debug and see if you're getting a runtime error (and see the stack trace) 3) Are you overriding measure() in your UIComponent? If not, at least set its width and height explicitly.
Re: [flexcoders] addChild problems
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
[flexcoders] addChild problems
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
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
[flexcoders] addchild error
I am having some trouble with addchild var thePrintView:FormPrintView = new FormPrintView(); //myHbox.addChild(thePrintView); var _caPan:Canvas = new Canvas(); _caPan.height=300; _caPan.width = 200; _caPan.addChild(thePrintView); _caPan.addChild(thePrintView); second addchild generate a error RangeError: Error #2006: L'index indiqué sort des limites. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt() at mx.core::UIComponent/set document() at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::addin gChild() at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingC hild() at mx.core::Container/addChildAt() at mx.core::Container/addChild() at MyLoginForm/process() at MyLoginForm/___TitleWindow1_initialize() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.core::UIComponent/set processedDescriptors() at mx.core::Container/createComponentsFromDescriptors() at mx.containers::Panel/createComponentsFromDescriptors() at mx.core::Container/mx.core:Container::createChildren() at mx.containers::Panel/mx.containers:Panel::createChildren() at mx.core::UIComponent/initialize() at mx.core::Container/initialize() at MyLoginForm/initialize() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: :childAdded() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: :rawChildren_addChildAt() at mx.managers::SystemManager/addChild() at mx.managers::PopUpManagerImpl/addPopUp() at mx.managers::PopUpManager$/addPopUp() at print/doPrint() at print/__printDG_click()
RE: [flexcoders] addchild error
You can't add a child twice. Did you mean to call addPage? From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of wifi19 Sent: Tuesday, March 27, 2007 1:57 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] addchild error I am having some trouble with addchild var thePrintView:FormPrintView = new FormPrintView(); //myHbox.addChild(thePrintView); var _caPan:Canvas = new Canvas(); _caPan.height=300; _caPan.width = 200; _caPan.addChild(thePrintView); _caPan.addChild(thePrintView); second addchild generate a error RangeError: Error #2006: L'index indiqué sort des limites. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt() at mx.core::UIComponent/set document() at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::addin http://www.adobe.com/2006/flex/mx/internal::addin gChild() at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingC http://www.adobe.com/2006/flex/mx/internal::addingC hild() at mx.core::Container/addChildAt() at mx.core::Container/addChild() at MyLoginForm/process() at MyLoginForm/___TitleWindow1_initialize() at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEv entFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent() at mx.core::UIComponent/set processedDescriptors() at mx.core::Container/createComponentsFromDescriptors() at mx.containers::Panel/createComponentsFromDescriptors() at mx.core::Container/mx.core:Container::createChildren() at mx.containers::Panel/mx.containers:Panel::createChildren() at mx.core::UIComponent/initialize() at mx.core::Container/initialize() at MyLoginForm/initialize() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: http://www.adobe.com/2006/flex/mx/internal: :childAdded() at mx.managers::SystemManager/http://www.adobe.com/2006/flex/mx/internal: http://www.adobe.com/2006/flex/mx/internal: :rawChildren_addChildAt() at mx.managers::SystemManager/addChild() at mx.managers::PopUpManagerImpl/addPopUp() at mx.managers::PopUpManager$/addPopUp() at print/doPrint() at print/__printDG_click()
[flexcoders] addChild doesn't work as dynamic, why?
Hi there Folks While trying to create a dynamic component into flex application then trying to include others, why such thing doesn't work. In the example bellow I create an PopUp titleWindow with children TextArea Component. But when I create again the same titleWindow, the last TextArea who is children of titleWindow is removed. ?xml version=1.0 encoding=utf-8? mx:Application creationComplete=createTextArea(); xmlns:mx= http://www.adobe.com/2006/mxml; layout=absolute mx:Script ![CDATA[ import mx.events.ChildExistenceChangedEvent; import mx.states.AddChild; import mx.controls.TextArea; import mx.managers.PopUpManager; import mx.containers.TitleWindow; import mx.core.IFlexDisplayObject; public var titleWindows:TitleWindow; public var MyTextArea:TextArea; public var i:Number = Math.random() *50; private function createTitleWindow():void { titleWindows = new TitleWindow(); titleWindows.title = Basic; titleWindows.width = 330; titleWindows.height = 200; titleWindows.showCloseButton = true; titleWindows.addChild(MyTextArea); mx.managers.PopUpManager.addPopUp (titleWindows,this,false,null); titleWindows.creationPolicy =all; titleWindows.createReferenceOnParentDocument(MyTextArea); } private function createTextArea():void { MyTextArea = new TextArea(); MyTextArea.uid = 'textA'; MyTextArea.width = 330; MyTextArea.height = 200; MyTextArea.text = Example of Dynamic Text Content; MyTextArea.cacheAsBitmap = true; addChild(titleWindows); } ]] /mx:Script mx:Button mouseDown=createTitleWindow() label=Add dynamic Title Window with content/ /mx:Application Regards. -- Igor Costa www.igorcosta.org www.igorcosta.com skype: igorpcosta
RE: [flexcoders] addChild doesn't work as dynamic, why?
I see three problems: 1. This code gives an RTE when I run it. When the Application's creationComplete handler calls createTextArea(), and this method executes addChild(titleWindows), titleWindows is null. You can't add a null child to a parent. 2. If you are using the PopUpManager to pop up TitleWindows on top of the Application, you don't want to be adding a TitleWindow as a child of the Application. 3. You create a single TextArea and then add it to multiple TitleWindows. When you add it to the second one, it gets automatically removed from the first one. A DisplayObject can only be parented by a single DisplayObjectContainer. - Gordon From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Igor Costa Sent: Saturday, February 17, 2007 8:32 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] addChild doesn't work as dynamic, why? Hi there Folks While trying to create a dynamic component into flex application then trying to include others, why such thing doesn't work. In the example bellow I create an PopUp titleWindow with children TextArea Component. But when I create again the same titleWindow, the last TextArea who is children of titleWindow is removed. ?xml version=1.0 encoding=utf-8? mx:Application creationComplete=createTextArea(); xmlns:mx=http://www.adobe.com/2006/mxml http://www.adobe.com/2006/mxml layout=absolute mx:Script ![CDATA[ import mx.events.ChildExistenceChangedEvent; import mx.states.AddChild; import mx.controls.TextArea ; import mx.managers.PopUpManager; import mx.containers.TitleWindow; import mx.core.IFlexDisplayObject; public var titleWindows:TitleWindow; public var MyTextArea:TextArea; public var i:Number = Math.random() *50; private function createTitleWindow():void { titleWindows = new TitleWindow(); titleWindows.title = Basic; titleWindows.width = 330; titleWindows.height = 200; titleWindows.showCloseButton = true; titleWindows.addChild(MyTextArea); mx.managers.PopUpManager.addPopUp(titleWindows,this,false,null); titleWindows.creationPolicy =all; titleWindows.createReferenceOnParentDocument (MyTextArea); } private function createTextArea():void { MyTextArea = new TextArea(); MyTextArea.uid = 'textA'; MyTextArea.width = 330; MyTextArea.height = 200; MyTextArea.text = Example of Dynamic Text Content; MyTextArea.cacheAsBitmap = true; addChild(titleWindows); } ]] /mx:Script mx:Button mouseDown=createTitleWindow() label=Add dynamic Title Window with content/ /mx:Application Regards. -- Igor Costa www.igorcosta.org http://www.igorcosta.org www.igorcosta.com http://www.igorcosta.com skype: igorpcosta
[flexcoders] addChild(myFriend) on the fly - possible?
I have a custom component myFriend.mxml I have a datagrid on the left filled with search results. What i was is, as I'm clicking Add Friend on the datagrid, for it to appear on the right (one under the other) automatically with the style and format of myFriend.mxml Is this possible? if so, I would appreciate any help. Thanks, Alexander
[flexcoders] addChild not showing!!
I'm trying to create a preloader for a flex application I'm making and I'm using Ted's Custom Preloader as a basis for a start point. The problem I'm having is when I try to add my child canvas to the screen that has the labels I added to that canvas it is not showing on the screen. Is there something more I need to do to be able to add the canvas to the stage? Any help would be much appreciated. Here is the following code I have that returns the canvas and does the addChild(). With this code I'm not returning any errors so kind of at a loss atm. // // *CREATE LOADER INFO METHOD** // public function createLoadInfo():Canvas { canvas = new Canvas(); canvas.width = 380, canvas.height = 115; canvas.setStyle(backgroundColor, 0xFF); label = new Label(); label.id = gatewayText; label.x = 0, label.y = 0; label.setStyle(color, 0xFF); label.setStyle(fontSize, 12); label.text = Initializing CFMX Gateway; canvas.addChild(label); label = new Label(); label.id = securityText; label.x = 0, label.y = 30; label.setStyle(color, 0xFF); label.setStyle(fontSize, 12); label.text = Initializing Security Checks; canvas.addChild(label); return canvas; } // // *UPDATE VIEW METHOD* // public function updateView(event:TimerEvent):void { if( this.alpha 1){ this.alpha = this.alpha + this.fadeInRate; } var loaderCanvas:Canvas = createLoadInfo(); loaderCanvas.x = loaderCanvas.y = 100; this.stage.addChild(loaderCanvas); this.stage.addChild(this); this.x = this.stage.stageWidth/2 - this.width/2 this.y = this.stage.stageHeight/2 - this.height/2 this.visible = true; if( this.ready timer.currentCount this.timeAutoClose ) gatewayHandler() }
Re: [flexcoders] AddChild() Exceptions
It just clicked. One of those realization moments... I'm guessing any instance of a child can only have one parent. Therefore this someContainer.addChild(imageVar); someOtherContainer.addChild(imageVar); Is not OK, because references to imageVar don't get cleaned up as Flex draws the screen. If the child were explicitly removed in the middle - someContainer.removeChild(imageVar) or the like - then this would be OK. I had this notion stuck in my head because I wasn't seeing a child as something that was exclusively owned, and in retrospect it seems daft not to see it as a two-way thing. Initially I believed every parent simply kept a reference to children rendered. If only I hadn't brushed over this line in the docs: Because a display object has only one parent container, you can add an instance of a display object to only one display object container. For example, the following code shows that the display object tf1 can exist in only one container (http://livedocs.macromedia.com/flex/2/docs/wwhelp/wwhimpl/js/html/wwhelp.htm?href=1853.html) I'm also guessing an arbitrary decision was made not to implicitly clean up the references when this happens, in order to inform the developer that there's something wrong. However, in the same doc: If you add a display object that is contained in one display object container to another display object container, it is removed from the first display object container's child list. So does anyone know if the behaviour above is intentional? Or is it a bug? Cheers, Ciarán On 11/6/06, Ciarán [EMAIL PROTECTED] wrote: Forgot to mention it doesn't really matter about the image name - it doesn't have to exist. I just had it as a test image in my project directory... -Ciarán On 11/6/06, Ciarán [EMAIL PROTECTED] wrote: I fixed the problem by changing the way I was using the Image control (calling load() instead of changing the reference in the container). callLater() would solve the issue if it were caused by event timings, and I tried using that, so I don't think my problem is related. After much tinkering around I've reduced what's going wrong to a few lines. I've got a feeling it's more fundamental to the behaviour of addChild() and the arguments supplied. Intuitively (in my twisted brain), this should work - all I'm doing is using a reference to a control twice (in different containers). Remove the comment slashes to make it balk. package testspace { import mx.controls.*; import mx.containers.*; public class TestImage extends VBox { private var mainImage:Image = new Image(); public function TestImage() { mainImage.load(images/dvd_1.jpg); } override protected function createChildren():void { super.createChildren(); var tileDisplay:Tile = new Tile(); tileDisplay.addChild(mainImage); //addChild(mainImage); addChild(tileDisplay); } } } The documentation doesn't seem to indicate what behaviour would make this throw an exception (or am I being blind here?). If anyone can point me to whatever explains it, I'd be most appreciative. Many Thanks, Ciarán On 11/2/06, Jason Hawryluk [EMAIL PROTECTED] wrote: I'm having the exact same type of problem swapping containers in a TabNavigator using this type of command main.setChildIndex(main.getChildAt(2),1); The behind code seems to choke on the getChildAt of the container. I had the some index problems on other things with this component and for that one found that using callLater solved part of it. Perhaps you could give that a try, failing that if you find a simple answer to your problem I' d be interested in hearing about your solution. I'll do likewise if I find a solution to the current index problem. Anyway Frustrating to say the least. jason -Message d'origine- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] la part de Ciarán Envoyé : jeudi 2 novembre 2006 14:29 À : flexcoders@yahoogroups.com Objet : [flexcoders] AddChild() Exceptions Hi All, I'm having a slight problem building a custom component. The basic idea is a combination of a primary image container, and a Tile() container providing a selection of images. When selected, each image would appear as a primary image. This sounds tediously simple. I'm implementing it upon the principle that a change event is broadcast when a setter is called, which has a registered listener that updates the component. It attempts to replace the at index 0. The annoying thing is that if I implement this from a vanilla perspective (blank text
Re: [flexcoders] AddChild() Exceptions
Forgot to mention it doesn't really matter about the image name - it doesn't have to exist. I just had it as a test image in my project directory... -Ciarán On 11/6/06, Ciarán [EMAIL PROTECTED] wrote: I fixed the problem by changing the way I was using the Image control (calling load() instead of changing the reference in the container). callLater() would solve the issue if it were caused by event timings, and I tried using that, so I don't think my problem is related. After much tinkering around I've reduced what's going wrong to a few lines. I've got a feeling it's more fundamental to the behaviour of addChild() and the arguments supplied. Intuitively (in my twisted brain), this should work - all I'm doing is using a reference to a control twice (in different containers). Remove the comment slashes to make it balk. package testspace { import mx.controls.*; import mx.containers.*; public class TestImage extends VBox { private var mainImage:Image = new Image(); public function TestImage() { mainImage.load(images/dvd_1.jpg); } override protected function createChildren():void { super.createChildren(); var tileDisplay:Tile = new Tile(); tileDisplay.addChild(mainImage); //addChild(mainImage); addChild(tileDisplay); } } } The documentation doesn't seem to indicate what behaviour would make this throw an exception (or am I being blind here?). If anyone can point me to whatever explains it, I'd be most appreciative. Many Thanks, Ciarán On 11/2/06, Jason Hawryluk [EMAIL PROTECTED] wrote: I'm having the exact same type of problem swapping containers in a TabNavigator using this type of command main.setChildIndex(main.getChildAt(2),1); The behind code seems to choke on the getChildAt of the container. I had the some index problems on other things with this component and for that one found that using callLater solved part of it. Perhaps you could give that a try, failing that if you find a simple answer to your problem I' d be interested in hearing about your solution. I'll do likewise if I find a solution to the current index problem. Anyway Frustrating to say the least. jason -Message d'origine- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] la part de Ciarán Envoyé : jeudi 2 novembre 2006 14:29 À : flexcoders@yahoogroups.com Objet : [flexcoders] AddChild() Exceptions Hi All, I'm having a slight problem building a custom component. The basic idea is a combination of a primary image container, and a Tile() container providing a selection of images. When selected, each image would appear as a primary image. This sounds tediously simple. I'm implementing it upon the principle that a change event is broadcast when a setter is called, which has a registered listener that updates the component. It attempts to replace the at index 0. The annoying thing is that if I implement this from a vanilla perspective (blank text file), it works fine (making things much harder to debug since I can't reproduce the behaviour) - however in the context of the application I'm developing, it throws an exception: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt()[C:\dev\GMC\sdk\frameworks\mx\core\Container. as:2384] at mx.core::UIComponent/notifyStyleChangeInChildren()[C:\dev\GMC\sdk\frameworks \mx\core\UIComponent.as:7099] at mx.core::Container/mx.core:Container::commitProperties()[C:\dev\GMC\sdk\fram eworks\mx\core\Container.as:2680] at mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\ UIComponent.as:5218] at mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C :\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517] at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation( )[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:628] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\ sdk\frameworks\mx\core\UIComponent.as:7789] at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\s dk\frameworks\mx\core\UIComponent.as:7732] This happens when the addChildAt() method gets called. Without divulging context, is there any obvious reason why I'm getting this exception? I've been battling this for hours now and it won't yield. If I'm not doing something incredibly stupid that would cause this, please let me know. Intuitively, it seems like
Re: [flexcoders] AddChild() Exceptions
I fixed the problem by changing the way I was using the Image control (calling load() instead of changing the reference in the container). callLater() would solve the issue if it were caused by event timings, and I tried using that, so I don't think my problem is related. After much tinkering around I've reduced what's going wrong to a few lines. I've got a feeling it's more fundamental to the behaviour of addChild() and the arguments supplied. Intuitively (in my twisted brain), this should work - all I'm doing is using a reference to a control twice (in different containers). Remove the comment slashes to make it balk. package testspace { import mx.controls.*; import mx.containers.*; public class TestImage extends VBox { private var mainImage:Image = new Image(); public function TestImage() { mainImage.load(images/dvd_1.jpg); } override protected function createChildren():void { super.createChildren(); var tileDisplay:Tile = new Tile(); tileDisplay.addChild(mainImage); //addChild(mainImage); addChild(tileDisplay); } } } The documentation doesn't seem to indicate what behaviour would make this throw an exception (or am I being blind here?). If anyone can point me to whatever explains it, I'd be most appreciative. Many Thanks, Ciarán On 11/2/06, Jason Hawryluk [EMAIL PROTECTED] wrote: I'm having the exact same type of problem swapping containers in a TabNavigator using this type of command main.setChildIndex(main.getChildAt(2),1); The behind code seems to choke on the getChildAt of the container. I had the some index problems on other things with this component and for that one found that using callLater solved part of it. Perhaps you could give that a try, failing that if you find a simple answer to your problem I' d be interested in hearing about your solution. I'll do likewise if I find a solution to the current index problem. Anyway Frustrating to say the least. jason -Message d'origine- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] la part de Ciarán Envoyé : jeudi 2 novembre 2006 14:29 À : flexcoders@yahoogroups.com Objet : [flexcoders] AddChild() Exceptions Hi All, I'm having a slight problem building a custom component. The basic idea is a combination of a primary image container, and a Tile() container providing a selection of images. When selected, each image would appear as a primary image. This sounds tediously simple. I'm implementing it upon the principle that a change event is broadcast when a setter is called, which has a registered listener that updates the component. It attempts to replace the at index 0. The annoying thing is that if I implement this from a vanilla perspective (blank text file), it works fine (making things much harder to debug since I can't reproduce the behaviour) - however in the context of the application I'm developing, it throws an exception: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt()[C:\dev\GMC\sdk\frameworks\mx\core\Container. as:2384] at mx.core::UIComponent/notifyStyleChangeInChildren()[C:\dev\GMC\sdk\frameworks \mx\core\UIComponent.as:7099] at mx.core::Container/mx.core:Container::commitProperties()[C:\dev\GMC\sdk\fram eworks\mx\core\Container.as:2680] at mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\ UIComponent.as:5218] at mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C :\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517] at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation( )[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:628] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\ sdk\frameworks\mx\core\UIComponent.as:7789] at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\s dk\frameworks\mx\core\UIComponent.as:7732] This happens when the addChildAt() method gets called. Without divulging context, is there any obvious reason why I'm getting this exception? I've been battling this for hours now and it won't yield. If I'm not doing something incredibly stupid that would cause this, please let me know. Intuitively, it seems like the addChild() is triggering something at the wrong moment in time, giving something similar to an Array out of bounds as it looks for stuff to render. I understand most of the trace atomically speaking, but on the whole I have no idea how to remedy it. Also, I have an annoying problem
[flexcoders] AddChild() Exceptions
Hi All, I'm having a slight problem building a custom component. The basic idea is a combination of a primary image container, and a Tile() container providing a selection of images. When selected, each image would appear as a primary image. This sounds tediously simple. I'm implementing it upon the principle that a change event is broadcast when a setter is called, which has a registered listener that updates the component. It attempts to replace the at index 0. The annoying thing is that if I implement this from a vanilla perspective (blank text file), it works fine (making things much harder to debug since I can't reproduce the behaviour) - however in the context of the application I'm developing, it throws an exception: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:2384] at mx.core::UIComponent/notifyStyleChangeInChildren()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7099] at mx.core::Container/mx.core:Container::commitProperties()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:2680] at mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:5218] at mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517] at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:628] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7789] at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7732] This happens when the addChildAt() method gets called. Without divulging context, is there any obvious reason why I'm getting this exception? I've been battling this for hours now and it won't yield. If I'm not doing something incredibly stupid that would cause this, please let me know. Intuitively, it seems like the addChild() is triggering something at the wrong moment in time, giving something similar to an Array out of bounds as it looks for stuff to render. I understand most of the trace atomically speaking, but on the whole I have no idea how to remedy it. Also, I have an annoying problem with Flexbuilder. Breakpoints dont seem to work for me at all. I can't find any setting that implies this might've been turned off, so I'm not sure what to do about it. Perhaps find the checkbox that says Don't work properly and untick it. Any clues would be much appreciated =) Kind Regards, Ciarán -- 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/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * 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] AddChild() Exceptions
Ciaarán where do you add your child? what container?This error that happens seems that out of bounds it's because you're trying to attach a new child in the not supported container.Regards On 11/2/06, Ciarán [EMAIL PROTECTED] wrote: Hi All, I'm having a slight problem building a custom component. The basic idea is a combination of a primary image container, and a Tile() container providing a selection of images. When selected, each image would appear as a primary image. This sounds tediously simple. I'm implementing it upon the principle that a change event is broadcast when a setter is called, which has a registered listener that updates the component. It attempts to replace the at index 0. The annoying thing is that if I implement this from a vanilla perspective (blank text file), it works fine (making things much harder to debug since I can't reproduce the behaviour) - however in the context of the application I'm developing, it throws an exception: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:2384] at mx.core::UIComponent/notifyStyleChangeInChildren()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7099] at mx.core::Container/mx.core:Container::commitProperties()[C:\dev\GMC\sdk\frameworks\mx\core\Container.as:2680] at mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:5218] at mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517] at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation()[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:628] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7789 ] at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\sdk\frameworks\mx\core\UIComponent.as:7732 ] This happens when the addChildAt() method gets called. Without divulging context, is there any obvious reason why I'm getting this exception? I've been battling this for hours now and it won't yield. If I'm not doing something incredibly stupid that would cause this, please let me know. Intuitively, it seems like the addChild() is triggering something at the wrong moment in time, giving something similar to an Array out of bounds as it looks for stuff to render. I understand most of the trace atomically speaking, but on the whole I have no idea how to remedy it. Also, I have an annoying problem with Flexbuilder. Breakpoints dont seem to work for me at all. I can't find any setting that implies this might've been turned off, so I'm not sure what to do about it. Perhaps find the checkbox that says Don't work properly and untick it. Any clues would be much appreciated =) Kind Regards, Ciarán -- Igor Costawww.igorcosta.com __._,_.___ -- 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 Software development tool Software development Software development services Home design software Software development company Your email settings: Individual Email|Traditional Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___
RE: [flexcoders] AddChild() Exceptions
I'm having the exact same type of problem swapping containers in a TabNavigator using this type of command main.setChildIndex(main.getChildAt(2),1); The behind code seems to choke on the getChildAt of the container. I had the some index problems on other things with this component and for that one found that using callLater solved part of it. Perhaps you could give that a try, failing that if you find a simple answer to your problem I d be interested in hearing about your solution. Ill do likewise if I find a solution to the current index problem. Anyway Frustrating to say the least. jason -Message d'origine- De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] la part de Ciarán Envoyé : jeudi 2 novembre 2006 14:29 À : flexcoders@yahoogroups.com Objet : [flexcoders] AddChild() Exceptions Hi All, I'm having a slight problem building a custom component. The basic idea is a combination of a primary image container, and a Tile() container providing a selection of images. When selected, each image would appear as a primary image. This sounds tediously simple. I'm implementing it upon the principle that a change event is broadcast when a setter is called, which has a registered listener that updates the component. It attempts to replace the at index 0. The annoying thing is that if I implement this from a vanilla perspective (blank text file), it works fine (making things much harder to debug since I can't reproduce the behaviour) - however in the context of the application I'm developing, it throws an exception: RangeError: Error #2006: The supplied index is out of bounds. at flash.display::DisplayObjectContainer/getChildAt() at mx.core::Container/getChildAt()[C:\dev\GMC\sdk\frameworks\mx\core\Container. as:2384] at mx.core::UIComponent/notifyStyleChangeInChildren()[C:\dev\GMC\sdk\frameworks \mx\core\UIComponent.as:7099] at mx.core::Container/mx.core:Container::commitProperties()[C:\dev\GMC\sdk\fram eworks\mx\core\Container.as:2680] at mx.core::UIComponent/validateProperties()[C:\dev\GMC\sdk\frameworks\mx\core\ UIComponent.as:5218] at mx.managers::LayoutManager/mx.managers:LayoutManager::validateProperties()[C :\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:517] at mx.managers::LayoutManager/mx.managers:LayoutManager::doPhasedInstantiation( )[C:\dev\GMC\sdk\frameworks\mx\managers\LayoutManager.as:628] at Function/http://adobe.com/AS3/2006/builtin::apply() at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher2()[C:\dev\GMC\ sdk\frameworks\mx\core\UIComponent.as:7789] at mx.core::UIComponent/mx.core:UIComponent::callLaterDispatcher()[C:\dev\GMC\s dk\frameworks\mx\core\UIComponent.as:7732] This happens when the addChildAt() method gets called. Without divulging context, is there any obvious reason why I'm getting this exception? I've been battling this for hours now and it won't yield. If I'm not doing something incredibly stupid that would cause this, please let me know. Intuitively, it seems like the addChild() is triggering something at the wrong moment in time, giving something similar to an Array out of bounds as it looks for stuff to render. I understand most of the trace atomically speaking, but on the whole I have no idea how to remedy it. Also, I have an annoying problem with Flexbuilder. Breakpoints dont seem to work for me at all. I can't find any setting that implies this might've been turned off, so I'm not sure what to do about it. Perhaps find the checkbox that says Don't work properly and untick it. Any clues would be much appreciated =) Kind Regards, Ciarán -- 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/ * Your email settings: Individual Email | Traditional * To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) * To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] * 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] addChild RemoveChild
Hello all , Is there any way by which i can decide if the any component contains a particular component or not. something like this : box:: VBox = new VBox(); box.width = 100;box.height = 100; if(Vboxid[box]== undefined){ Vboxid.addChild( box );} box.x = Vboxid.mouseX; box.y = Vboxid.mouseY; Igetrun timeerror at if condition ,The simplestwayI thought was to keep one Boolean and toggle it ..But I think there should be someother way Please tell me what is correct way todo it? Regards Ps __._,_.___ -- 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 Software development tool Software development Software development services Home design software Software development company Your email settings: Individual Email|Traditional Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___
Re: [flexcoders] addChild RemoveChild
Hi,use; box:VBox = new VBox(); box.width = 100; box.height = 100; if(!Vboxid.contains(box)){ Vboxid.addChild ( box );} box.x = Vboxid.mouseX ; box.y = Vboxid.mouseY;You could use the name property of the box and do a more complicated check.'The above will only work if 'box' is not a local variable. It needs to be an instance of a class. Peace, MikeOn 10/16/06, learner [EMAIL PROTECTED] wrote: Hello all , Is there any way by which i can decide if the any component contains a particular component or not. something like this : box:: VBox = new VBox(); box.width = 100; box.height = 100; if(Vboxid[box]== undefined){ Vboxid.addChild ( box );} box.x = Vboxid.mouseX; box.y = Vboxid.mouseY; Igetrun timeerror at if condition ,The simplestwayI thought was to keep one Boolean and toggle it ..But I think there should be someother way Please tell me what is correct way todo it? Regards Ps -- 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 Software development tool Software development Software development services Home design software Software development company Your email settings: Individual Email|Traditional Change settings via the Web (Yahoo! ID required) Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe __,_._,___
[flexcoders] addChild to Loader component
I tried to load a binary image data lo loader object, which worked great. but when I tried to add this loader object - addChild(loader) I got this message: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. the thing is that in all Adobe'shelp pageson Loader components, they use this method to display the image. am I doing something wrong? Best regards, gadi __._,_.___ -- 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] addChild to Loader component
If you want to show something in Flex, it must implement IUIComponent. Easiest way? var a:UIComponent = new UIComponent(); a.addChild(yourLoader); addChild(a); - Original Message - From: Gadi Srebnik To: flexcoders@yahoogroups.com Sent: Wednesday, July 26, 2006 4:57 AM Subject: [flexcoders] addChild to Loader component I tried to load a binary image data lo loader object, which worked great. but when I tried to add this loader object - addChild(loader) I got this message: TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent. the thing is that in all Adobe'shelp pageson Loader components, they use this method to display the image. am I doing something wrong? Best regards, gadi __._,_.___ -- 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] addChild() in constructor?
As far as I understand, now I can work with superclass view directly from constructor of inherited class after super() call? public class A extends Box { function A() { addChild(new TextInput()); // causes exception } } public class B extends A { function B() { super(); addChild(new TextInput()); // works correctly } } Is this behaviour is okay and could be used by developers? Sergey. Yahoo! Groups Sponsor ~-- See what's inside the new Yahoo! Groups email. http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/nhFolB/TM ~- -- 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] addChild() in constructor?
You're not supposed to create and add children in the constructor. Do it in createChildren, like this: protected override function createChildren():void { super.createChildren(); if ( my_txt == null) { my_txt = new TextInput(); addChild ( my_txt ); } } More info here: http://www.flex.org/ACDS/BuildingAFlexComponent.pdf - Original Message - From: Sergey Kovalyov [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Wednesday, July 19, 2006 10:01 AM Subject: [flexcoders] addChild() in constructor? As far as I understand, now I can work with superclass view directly from constructor of inherited class after super() call? public class A extends Box { function A() { addChild(new TextInput()); // causes exception } } public class B extends A { function B() { super(); addChild(new TextInput()); // works correctly } } Is this behaviour is okay and could be used by developers? Sergey. -- 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 Yahoo! Groups Sponsor ~-- See what's inside the new Yahoo! Groups email. http://us.click.yahoo.com/2pRQfA/bOaOAA/yQLSAA/nhFolB/TM ~- -- 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] addChild() in constructor?
Actually, I found this approach in IPE Controls by Ely Greenfield (http://demo.quietlyscheming.com/IPE/). There are classes like this there: package qs.ipeControls { import qs.ipeControls.classes.IPESlider; import mx.controls.HSlider; public class IPEHSlider extends IPESlider { public function IPEHSlider():void { super(); editableControl = new HSlider(); } } } In superclass IPESlider, editableControl setter is defined this way: protected function set editableControl(value:UIComponent):void { if(_editableControl != null) removeChild(_editableControl); _editableControl = value; _editableControl.styleName = this; addChild(_editableControl); _editableControl.visible = _editable; facadeEvents(_editableControl,dataChange); _editableControl.addEventListener(FocusEvent.FOCUS_OUT,commitOnBlurHandler); invalidateDisplayList(); } And it works... What's wrong? On 7/19/06, JesterXL [EMAIL PROTECTED] wrote: You're not supposed to create and add children in the constructor. Do it in createChildren, like this: protected override function createChildren():void { super.createChildren(); if ( my_txt == null) { my_txt = new TextInput(); addChild ( my_txt ); } } More info here: http://www.flex.org/ACDS/BuildingAFlexComponent.pdf Yahoo! Groups Sponsor ~-- Something is new at Yahoo! Groups. Check out the enhanced email design. http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/nhFolB/TM ~- -- 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] addChild() in constructor?
He wrote that code before the developer's summit is my guess. Ely told us specificlly not to add creation stuff in the constructors, only adding event listeners. The reason for this is the overhead that the constructor adds when instantiating a class. You can defer creation of children if need be if it's in a createChildren; but if it's in a constructor, you have no choice; doing var a:A = new A(); suddenly has a lot of overhead. Not sure why you're getting an exception, though, sorry. - Original Message - From: Sergey Kovalyov [EMAIL PROTECTED] To: flexcoders@yahoogroups.com Sent: Wednesday, July 19, 2006 10:31 AM Subject: Re: [flexcoders] addChild() in constructor? Actually, I found this approach in IPE Controls by Ely Greenfield (http://demo.quietlyscheming.com/IPE/). There are classes like this there: package qs.ipeControls { import qs.ipeControls.classes.IPESlider; import mx.controls.HSlider; public class IPEHSlider extends IPESlider { public function IPEHSlider():void { super(); editableControl = new HSlider(); } } } In superclass IPESlider, editableControl setter is defined this way: protected function set editableControl(value:UIComponent):void { if(_editableControl != null) removeChild(_editableControl); _editableControl = value; _editableControl.styleName = this; addChild(_editableControl); _editableControl.visible = _editable; facadeEvents(_editableControl,dataChange); _editableControl.addEventListener(FocusEvent.FOCUS_OUT,commitOnBlurHandler); invalidateDisplayList(); } And it works... What's wrong? On 7/19/06, JesterXL [EMAIL PROTECTED] wrote: You're not supposed to create and add children in the constructor. Do it in createChildren, like this: protected override function createChildren():void { super.createChildren(); if ( my_txt == null) { my_txt = new TextInput(); addChild ( my_txt ); } } More info here: http://www.flex.org/ACDS/BuildingAFlexComponent.pdf -- 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 Yahoo! Groups Sponsor ~-- Yahoo! Groups gets a make over. See the new email design. http://us.click.yahoo.com/XISQkA/lOaOAA/yQLSAA/nhFolB/TM ~- -- 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] addChild method in mx.core.Container
Hello, i have a problem. Please, help... if: ... var s:Sprite = new Sprite(); var b:Box = new Box(); // box - mx.core.Container.Box then: b.addChild(s);// - ERROR: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent i know (from debugger) that method 'addChild(val:DisplayObject)' in mx.core.Container is overriden and it checks the argument 'val' on IUIComponent'ness (sorry for my English:)). So, i can't add Sprite instance as a child to a Container instance. Is it true? It seems, it's not good... -- 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] addChild method in mx.core.Container
var s:Sprite = new Sprite(); var b:Box = new Box(); // box - mx.core.Container.Box then: b.addChild(s);// - ERROR: cannot convert flash.display::[EMAIL PROTECTED] to mx.core.IUIComponent i know (from debugger) that method 'addChild(val:DisplayObject)' in mx.core.Container is overriden and it checks the argument 'val' on IUIComponent'ness (sorry for my English:)). So, i can't add Sprite instance as a child to a Container instance. Is it true? It seems, it's not good... You can wrap your Sprite inside an UIComponent (code not tested): var s:Sprite = new Sprite(); var c:UIComponent = new UIComponent(); c.addChild(s); var b:Box = new Box(); b.addChild(b); I think the Flex Container can only accept UIComponents because it needs the properties and methods they add to layout the children. Jens -- 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] addChild method in mx.core.Container
You can wrap your Sprite inside an UIComponent (code not tested): var s:Sprite = new Sprite(); var c:UIComponent = new UIComponent(); c.addChild(s); var b:Box = new Box(); b.addChild(b); I meant b.addChild(c) of course... -- 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] addChild from String
Hi All, I'd like to provide a String value which represents the DisplayObject class I want to create dynamically with addChild. Has anyone accomplished this? This would be equivalent to createChild(findClass(Button)) in AS2... Thanks, Brendan -- 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] addChild from String
Hi All, I'd like to provide a String value which represents the DisplayObject class I want to create dynamically with addChild. Has anyone accomplished this? You mean like this? public function createInstance (className : String) : Object { var MyClass : Class = getClassByName(className); return new MyClass(); } Btw.: what I really miss is a method createInstance(args : Array) in the Class class, so I could easily provide an arbitrary number of constructor arguments not known until runtime, like this: public function createInstance (className:String, args:Array) : Object { var myClass : Class = getClassByName(className); return myClass.createInstance(args); } Class.createInstance(args:Array) would be the constructor equivalent of Function.apply(scope:Object, args:Array). If I use Function.apply after I created an instance the constructor would be called twice which would be quite dirty. Consider this as a feature request... ;) Jens www.oregano-server.org -- 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] addChild from String
You can use the player's getClassByName() function, which is in the flash.util package. Pass it a fully qualified class name like mx.controls.Button: createChild(getClassByName(mx.controls.Button)); - Gordon -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Brendan Meutzner Sent: Wednesday, January 18, 2006 9:13 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] addChild from String Hi All, I'd like to provide a String value which represents the DisplayObject class I want to create dynamically with addChild. Has anyone accomplished this? This would be equivalent to createChild(findClass(Button)) in AS2... Thanks, Brendan -- 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 -- 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] addChild from String
I asked internally and the equivalent createInstance functionality is not in the ECMA spec. So probably not going to come from us in Flex 2. Please file the enhancement request at http://www.macromedia.com/go/wish. You would need to simulate by creating the object with a no-arg constructor and then having a well-known function like initArgs which you could call via Function.apply. public function createInstance (className:String, args:Array) : Object { var myClass : Class = getClassByName(className); var inst : Object = new myClass(); inst.initArgs.apply(inst, args); return inst; } Matt -Original Message- From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Jens Halm Sent: Wednesday, January 18, 2006 10:32 AM To: Brendan Meutzner Subject: Re: [flexcoders] addChild from String Hi All, I'd like to provide a String value which represents the DisplayObject class I want to create dynamically with addChild. Has anyone accomplished this? You mean like this? public function createInstance (className : String) : Object { var MyClass : Class = getClassByName(className); return new MyClass(); } Btw.: what I really miss is a method createInstance(args : Array) in the Class class, so I could easily provide an arbitrary number of constructor arguments not known until runtime, like this: public function createInstance (className:String, args:Array) : Object { var myClass : Class = getClassByName(className); return myClass.createInstance(args); } Class.createInstance(args:Array) would be the constructor equivalent of Function.apply(scope:Object, args:Array). If I use Function.apply after I created an instance the constructor would be called twice which would be quite dirty. Consider this as a feature request... ;) Jens www.oregano-server.org -- 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 -- 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] addChild from String
public function createInstance (className:String, args:Array) : Object { var myClass : Class = getClassByName(className); var inst : Object = new myClass(); inst.initArgs.apply(inst, args); return inst; } Yes, that would be a workaround if I have complete control over the classes I work with, but that is not always the case. In AS 2 I work with a configuration framework inspired by Spring. I can do stuff in XML config files like this: object id=myObject class=myPackage.MyClass constructor-args stringarbitrary string/string booleanfalse/boolean /constructor-args property name=duration number5000/number /property /object Currently it would be impossible to port that to AS 3 which would really be a step back (which is sad because otherwise AS 3 is so much nicer than AS 2). In AS 2 I use a simple hack to implement how the constructor-args are applied: public static function createInstance (className:String, args:Array) : Object { var clazz:Function = eval(className); var obj:Object = new Object(); obj.__proto__ = clazz.prototype; clazz.apply(obj, args); return obj; } I really think something like Class.createInstance should be in the spec, it is quite important for generic frameworks. Couldn't you Adobe-guys push that? ;) Ok, I will file an enhancement request... Jens www.oregano-server.org -- 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/