Re: [flexcoders] Re: apply style in newly created component
Worked liked charm!!! I guess valdhor also suggested something like this in one of his initial mails. Thanks to all On Fri, Jan 15, 2010 at 12:45 PM, Amy wrote: > > > > > --- In flexcoders@yahoogroups.com , > "valdhor" wrote: > > > > Hm I don't use charts. > > > > Maybe you could try... > > > > myComp.myChart.styleName = "noGutterChart"; > > > > Actaully, the myChart component may not have been instantiated at that > point. I would add a creationComplete event handler to the myChart component > that dispatches a custom event that will bubble up to the component that you > are in. When that event comes in, apply the style. > > My guess is that the setStyle functionality bypasses some of the controls > in the life cycle logic of the chart, whereas styleName will just set a flag > somewhere and the logic will just wait until the appropriate moment to apply > the styles to the objects, which will have been instantiated at that point. > > MPO is that if you use styleName you should not need to add an event > listener for initialized or creationcomplete. Be aware that neither of these > events will fire until the component has already been added to the Canvas > and the Canvas has been added to the display list. > > HTH; > > Amy > > >
[flexcoders] Re: apply style in newly created component
--- In flexcoders@yahoogroups.com, "valdhor" wrote: > > Hm I don't use charts. > > Maybe you could try... > > myComp.myChart.styleName = "noGutterChart"; > > Actaully, the myChart component may not have been instantiated at that point. > I would add a creationComplete event handler to the myChart component that > dispatches a custom event that will bubble up to the component that you are > in. When that event comes in, apply the style. My guess is that the setStyle functionality bypasses some of the controls in the life cycle logic of the chart, whereas styleName will just set a flag somewhere and the logic will just wait until the appropriate moment to apply the styles to the objects, which will have been instantiated at that point. MPO is that if you use styleName you should not need to add an event listener for initialized or creationcomplete. Be aware that neither of these events will fire until the component has already been added to the Canvas and the Canvas has been added to the display list. HTH; Amy
[flexcoders] Re: apply style in newly created component
Try this... http://www.adobe.com/2006/mxml"; xmlns:local="*" creationComplete="onCreationComplete()"> .noGutterChart { gutterLeft:0; gutterBottom:0; gutterTop:0; gutterRight:0; } ChartComp.mxml: http://www.adobe.com/2006/mxml"; creationComplete="dispatchEvent(new Event('myChartCompleted', true, true))"> --- In flexcoders@yahoogroups.com, Vivian Richard wrote: > > I just tried as suggested and still the same. May be it does not get > instantiated > until it is added in its parent. May be!!! > > > > On Fri, Jan 15, 2010 at 10:50 AM, valdhor valdhorli...@...wrote: > > > > > > > Hm I don't use charts. > > > > Maybe you could try... > > > > myComp.myChart.styleName = "noGutterChart"; > > > > Actaully, the myChart component may not have been instantiated at that > > point. I would add a creationComplete event handler to the myChart component > > that dispatches a custom event that will bubble up to the component that you > > are in. When that event comes in, apply the style. > > > > > > --- In flexcoders@yahoogroups.com , Vivian > > Richard kanpsack@ wrote: > > > > > > Actually I am trying to apply a very simple style to a chart. My chart is > > > inside a > > > canvas component and in a separate file. I want to add this chart > > containing > > > canvas in dynamically. This component is like this: > > > > > > > > > > > > > > > > > > > > > > > > Now I have this simple styles for the the chart which are: > > > > > > .noGutterChart { > > > gutterLeft:0; > > > gutterBottom:0; > > > gutterTop:0; > > > gutterRight:0; > > > } > > > > > > Now as I am trying to create the component dunamically and want to apply > > > the > > > style to the chart I get the error message. > > > > > > var myComp:ChartComp = new ChartComp; > > > myComp.myChart.setStyle("styleName","noGutterChart"); > > > > > > This gives me the error message that I cannot access a function of a > > > null object. > > > > > > > > > > > > > > > > > > > > > > > > > > > On Fri, Jan 15, 2010 at 9:49 AM, valdhor valdhorli...@wrote: > > > > > > > > > > > > > > > > > In that case he should use the styleName property... > > > > > > > > .myStyle > > > > { > > > > cornerRadius: 9; > > > > fillAlphas: 1, 1, 1, 1; > > > > fillColors: #6699ff, #6699ff, #6699ff, #6699ff; > > > > themeColor: #00ff00; > > > > fontSize: 24; > > > > } > > > > > > > > > > > > var button:Button = new Button; > > > > button.label = "My Fancy New Button"; > > > > button.styleName = "myStyle"; > > > > this.addChild(button); > > > > > > > > > > > > --- In flexcoders@yahoogroups.com , Erik > > de Bruin wrote: > > > > > > > > > > Hi, > > > > > > > > > > I think he's trying to set a named CSS style ("myStyle") on the > > Button > > > > using > > > > > setStyle(). I don't think that's possible? > > > > > > > > > > EdB > > > > > > > > > > On Fri, Jan 15, 2010 at 3:02 PM, valdhor valdhorlists@: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > I don't understand. Once you use the "new" operator, the button is > > > > > > instantiated. You can apply all sorts of styles to it before adding > > it > > > > to > > > > > > the displayList. For example, this works for me... > > > > > > > > > > > > var button:Button = new Button; > > > > > > button.label = "My Fancy New Button"; > > > > > > button.setStyle("cornerRadius", 9); > > > > > > button.setStyle("fontSize", 24); > > > > > > button.setStyle("themeColor", '#00FF00'); > > > > > > button.setStyle("fillColors", ['#6699ff', '#6699ff', > > > > > > '#6699ff', '#6699ff']); > > > > > > button.setStyle("fillAlphas", [1, 1, 1, 1]); > > > > > > this.addChild(button); > > > > > > > > > > > > > > > > > > > > > > > > --- In flexcoders@yahoogroups.com , > > "hworke" kanpsack@ wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi I am trying to apply style in a newly created component > > > > > > > but since it is not instantiated it gives me error message. > > > > > > > > > > > > > > My code is like this: > > > > > > > > > > > > > > var button:Button = new Button; > > > > > > > button.setStyle("styleName", "myStyle"); > > > > > > > canvas.addChild(button); > > > > > > > I need to create the component dynamically and also need > > > > > > > to apply the style dynamically. How can I do that? > > > > > > > > > > > > > > Regards, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > Ix Multimedia Software > > > > > > > > > > Jan Luykenstraat 27 > > > > > 3521 VB Utrecht > > > > > > > > > > T. 06-51952295 > > > > > I. www.ixsoftware.nl > > > > > > > > > > > > > > > > > > > > > > >
Re: [flexcoders] Re: apply style in newly created component
I just tried as suggested and still the same. May be it does not get instantiated until it is added in its parent. May be!!! On Fri, Jan 15, 2010 at 10:50 AM, valdhor wrote: > > > Hm I don't use charts. > > Maybe you could try... > > myComp.myChart.styleName = "noGutterChart"; > > Actaully, the myChart component may not have been instantiated at that > point. I would add a creationComplete event handler to the myChart component > that dispatches a custom event that will bubble up to the component that you > are in. When that event comes in, apply the style. > > > --- In flexcoders@yahoogroups.com , Vivian > Richard wrote: > > > > Actually I am trying to apply a very simple style to a chart. My chart is > > inside a > > canvas component and in a separate file. I want to add this chart > containing > > canvas in dynamically. This component is like this: > > > > > > > > > > > > > > > > Now I have this simple styles for the the chart which are: > > > > .noGutterChart { > > gutterLeft:0; > > gutterBottom:0; > > gutterTop:0; > > gutterRight:0; > > } > > > > Now as I am trying to create the component dunamically and want to apply > > the > > style to the chart I get the error message. > > > > var myComp:ChartComp = new ChartComp; > > myComp.myChart.setStyle("styleName","noGutterChart"); > > > > This gives me the error message that I cannot access a function of a > > null object. > > > > > > > > > > > > > > > > > > On Fri, Jan 15, 2010 at 9:49 AM, valdhor wrote: > > > > > > > > > > > > In that case he should use the styleName property... > > > > > > .myStyle > > > { > > > cornerRadius: 9; > > > fillAlphas: 1, 1, 1, 1; > > > fillColors: #6699ff, #6699ff, #6699ff, #6699ff; > > > themeColor: #00ff00; > > > fontSize: 24; > > > } > > > > > > > > > var button:Button = new Button; > > > button.label = "My Fancy New Button"; > > > button.styleName = "myStyle"; > > > this.addChild(button); > > > > > > > > > --- In flexcoders@yahoogroups.com , Erik > de Bruin wrote: > > > > > > > > Hi, > > > > > > > > I think he's trying to set a named CSS style ("myStyle") on the > Button > > > using > > > > setStyle(). I don't think that's possible? > > > > > > > > EdB > > > > > > > > On Fri, Jan 15, 2010 at 3:02 PM, valdhor valdhorli...@...: > > > > > > > > > > > > > > > > > > > > > > > I don't understand. Once you use the "new" operator, the button is > > > > > instantiated. You can apply all sorts of styles to it before adding > it > > > to > > > > > the displayList. For example, this works for me... > > > > > > > > > > var button:Button = new Button; > > > > > button.label = "My Fancy New Button"; > > > > > button.setStyle("cornerRadius", 9); > > > > > button.setStyle("fontSize", 24); > > > > > button.setStyle("themeColor", '#00FF00'); > > > > > button.setStyle("fillColors", ['#6699ff', '#6699ff', > > > > > '#6699ff', '#6699ff']); > > > > > button.setStyle("fillAlphas", [1, 1, 1, 1]); > > > > > this.addChild(button); > > > > > > > > > > > > > > > > > > > > --- In flexcoders@yahoogroups.com , > "hworke" kanpsack@ wrote: > > > > > > > > > > > > > > > > > > > > > > > > Hi I am trying to apply style in a newly created component > > > > > > but since it is not instantiated it gives me error message. > > > > > > > > > > > > My code is like this: > > > > > > > > > > > > var button:Button = new Button; > > > > > > button.setStyle("styleName", "myStyle"); > > > > > > canvas.addChild(button); > > > > > > I need to create the component dynamically and also need > > > > > > to apply the style dynamically. How can I do that? > > > > > > > > > > > > Regards, > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > Ix Multimedia Software > > > > > > > > Jan Luykenstraat 27 > > > > 3521 VB Utrecht > > > > > > > > T. 06-51952295 > > > > I. www.ixsoftware.nl > > > > > > > > > > > > > > >
[flexcoders] Re: apply style in newly created component
Hm I don't use charts. Maybe you could try... myComp.myChart.styleName = "noGutterChart"; Actaully, the myChart component may not have been instantiated at that point. I would add a creationComplete event handler to the myChart component that dispatches a custom event that will bubble up to the component that you are in. When that event comes in, apply the style. --- In flexcoders@yahoogroups.com, Vivian Richard wrote: > > Actually I am trying to apply a very simple style to a chart. My chart is > inside a > canvas component and in a separate file. I want to add this chart containing > canvas in dynamically. This component is like this: > > > > > > > > Now I have this simple styles for the the chart which are: > > .noGutterChart { >gutterLeft:0; >gutterBottom:0; >gutterTop:0; >gutterRight:0; > } > > Now as I am trying to create the component dunamically and want to apply > the > style to the chart I get the error message. > > var myComp:ChartComp = new ChartComp; > myComp.myChart.setStyle("styleName","noGutterChart"); > > This gives me the error message that I cannot access a function of a > null object. > > > > > > > > > On Fri, Jan 15, 2010 at 9:49 AM, valdhor wrote: > > > > > > > In that case he should use the styleName property... > > > > .myStyle > > { > >cornerRadius: 9; > >fillAlphas: 1, 1, 1, 1; > >fillColors: #6699ff, #6699ff, #6699ff, #6699ff; > >themeColor: #00ff00; > >fontSize: 24; > > } > > > > > > var button:Button = new Button; > > button.label = "My Fancy New Button"; > > button.styleName = "myStyle"; > > this.addChild(button); > > > > > > --- In flexcoders@yahoogroups.com, Erik de Bruin wrote: > > > > > > Hi, > > > > > > I think he's trying to set a named CSS style ("myStyle") on the Button > > using > > > setStyle(). I don't think that's possible? > > > > > > EdB > > > > > > On Fri, Jan 15, 2010 at 3:02 PM, valdhor valdhorli...@...: > > > > > > > > > > > > > > > > > I don't understand. Once you use the "new" operator, the button is > > > > instantiated. You can apply all sorts of styles to it before adding it > > to > > > > the displayList. For example, this works for me... > > > > > > > > var button:Button = new Button; > > > > button.label = "My Fancy New Button"; > > > > button.setStyle("cornerRadius", 9); > > > > button.setStyle("fontSize", 24); > > > > button.setStyle("themeColor", '#00FF00'); > > > > button.setStyle("fillColors", ['#6699ff', '#6699ff', > > > > '#6699ff', '#6699ff']); > > > > button.setStyle("fillAlphas", [1, 1, 1, 1]); > > > > this.addChild(button); > > > > > > > > > > > > > > > > --- In flexcoders@yahoogroups.com, "hworke" kanpsack@ wrote: > > > > > > > > > > > > > > > > > > > > Hi I am trying to apply style in a newly created component > > > > > but since it is not instantiated it gives me error message. > > > > > > > > > > My code is like this: > > > > > > > > > > var button:Button = new Button; > > > > > button.setStyle("styleName", "myStyle"); > > > > > canvas.addChild(button); > > > > > I need to create the component dynamically and also need > > > > > to apply the style dynamically. How can I do that? > > > > > > > > > > Regards, > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > Ix Multimedia Software > > > > > > Jan Luykenstraat 27 > > > 3521 VB Utrecht > > > > > > T. 06-51952295 > > > I. www.ixsoftware.nl > > > > > > > >
[flexcoders] Re: apply style in newly created component
use the styleName option if your applying a CSS to it: mychart.styleName = "noGutterChart"; --- In flexcoders@yahoogroups.com, Vivian Richard wrote: > > Actually I am trying to apply a very simple style to a chart. My chart is > inside a > canvas component and in a separate file. I want to add this chart containing > canvas in dynamically. This component is like this: > > > > > > > > Now I have this simple styles for the the chart which are: > > .noGutterChart { >gutterLeft:0; >gutterBottom:0; >gutterTop:0; >gutterRight:0; > } > > Now as I am trying to create the component dunamically and want to apply > the > style to the chart I get the error message. > > var myComp:ChartComp = new ChartComp; > myComp.myChart.setStyle("styleName","noGutterChart"); > > This gives me the error message that I cannot access a function of a > null object.
Re: [flexcoders] Re: apply style in newly created component
Actually I am trying to apply a very simple style to a chart. My chart is inside a canvas component and in a separate file. I want to add this chart containing canvas in dynamically. This component is like this: Now I have this simple styles for the the chart which are: .noGutterChart { gutterLeft:0; gutterBottom:0; gutterTop:0; gutterRight:0; } Now as I am trying to create the component dunamically and want to apply the style to the chart I get the error message. var myComp:ChartComp = new ChartComp; myComp.myChart.setStyle("styleName","noGutterChart"); This gives me the error message that I cannot access a function of a null object. On Fri, Jan 15, 2010 at 9:49 AM, valdhor wrote: > > > In that case he should use the styleName property... > > .myStyle > { >cornerRadius: 9; >fillAlphas: 1, 1, 1, 1; >fillColors: #6699ff, #6699ff, #6699ff, #6699ff; >themeColor: #00ff00; >fontSize: 24; > } > > > var button:Button = new Button; > button.label = "My Fancy New Button"; > button.styleName = "myStyle"; > this.addChild(button); > > > --- In flexcoders@yahoogroups.com, Erik de Bruin wrote: > > > > Hi, > > > > I think he's trying to set a named CSS style ("myStyle") on the Button > using > > setStyle(). I don't think that's possible? > > > > EdB > > > > On Fri, Jan 15, 2010 at 3:02 PM, valdhor valdhorli...@...wrote: > > > > > > > > > > > > I don't understand. Once you use the "new" operator, the button is > > > instantiated. You can apply all sorts of styles to it before adding it > to > > > the displayList. For example, this works for me... > > > > > > var button:Button = new Button; > > > button.label = "My Fancy New Button"; > > > button.setStyle("cornerRadius", 9); > > > button.setStyle("fontSize", 24); > > > button.setStyle("themeColor", '#00FF00'); > > > button.setStyle("fillColors", ['#6699ff', '#6699ff', > > > '#6699ff', '#6699ff']); > > > button.setStyle("fillAlphas", [1, 1, 1, 1]); > > > this.addChild(button); > > > > > > > > > > > > --- In flexcoders@yahoogroups.com, "hworke" kanpsack@ wrote: > > > > > > > > > > > > > > > > Hi I am trying to apply style in a newly created component > > > > but since it is not instantiated it gives me error message. > > > > > > > > My code is like this: > > > > > > > > var button:Button = new Button; > > > > button.setStyle("styleName", "myStyle"); > > > > canvas.addChild(button); > > > > I need to create the component dynamically and also need > > > > to apply the style dynamically. How can I do that? > > > > > > > > Regards, > > > > > > > > > > > > > > > > > > -- > > Ix Multimedia Software > > > > Jan Luykenstraat 27 > > 3521 VB Utrecht > > > > T. 06-51952295 > > I. www.ixsoftware.nl > > > >
[flexcoders] Re: apply style in newly created component
In that case he should use the styleName property... .myStyle { cornerRadius: 9; fillAlphas: 1, 1, 1, 1; fillColors: #6699ff, #6699ff, #6699ff, #6699ff; themeColor: #00ff00; fontSize: 24; } var button:Button = new Button; button.label = "My Fancy New Button"; button.styleName = "myStyle"; this.addChild(button); --- In flexcoders@yahoogroups.com, Erik de Bruin wrote: > > Hi, > > I think he's trying to set a named CSS style ("myStyle") on the Button using > setStyle(). I don't think that's possible? > > EdB > > On Fri, Jan 15, 2010 at 3:02 PM, valdhor valdhorli...@...wrote: > > > > > > > I don't understand. Once you use the "new" operator, the button is > > instantiated. You can apply all sorts of styles to it before adding it to > > the displayList. For example, this works for me... > > > > var button:Button = new Button; > > button.label = "My Fancy New Button"; > > button.setStyle("cornerRadius", 9); > > button.setStyle("fontSize", 24); > > button.setStyle("themeColor", '#00FF00'); > > button.setStyle("fillColors", ['#6699ff', '#6699ff', > > '#6699ff', '#6699ff']); > > button.setStyle("fillAlphas", [1, 1, 1, 1]); > > this.addChild(button); > > > > > > > > --- In flexcoders@yahoogroups.com, "hworke" kanpsack@ wrote: > > > > > > > > > > > > Hi I am trying to apply style in a newly created component > > > but since it is not instantiated it gives me error message. > > > > > > My code is like this: > > > > > > var button:Button = new Button; > > > button.setStyle("styleName", "myStyle"); > > > canvas.addChild(button); > > > I need to create the component dynamically and also need > > > to apply the style dynamically. How can I do that? > > > > > > Regards, > > > > > > > > > > > -- > Ix Multimedia Software > > Jan Luykenstraat 27 > 3521 VB Utrecht > > T. 06-51952295 > I. www.ixsoftware.nl >
Re: [flexcoders] Re: apply style in newly created component
Hi, I think he's trying to set a named CSS style ("myStyle") on the Button using setStyle(). I don't think that's possible? EdB On Fri, Jan 15, 2010 at 3:02 PM, valdhor wrote: > > > I don't understand. Once you use the "new" operator, the button is > instantiated. You can apply all sorts of styles to it before adding it to > the displayList. For example, this works for me... > > var button:Button = new Button; > button.label = "My Fancy New Button"; > button.setStyle("cornerRadius", 9); > button.setStyle("fontSize", 24); > button.setStyle("themeColor", '#00FF00'); > button.setStyle("fillColors", ['#6699ff', '#6699ff', > '#6699ff', '#6699ff']); > button.setStyle("fillAlphas", [1, 1, 1, 1]); > this.addChild(button); > > > > --- In flexcoders@yahoogroups.com, "hworke" wrote: > > > > > > > > Hi I am trying to apply style in a newly created component > > but since it is not instantiated it gives me error message. > > > > My code is like this: > > > > var button:Button = new Button; > > button.setStyle("styleName", "myStyle"); > > canvas.addChild(button); > > I need to create the component dynamically and also need > > to apply the style dynamically. How can I do that? > > > > Regards, > > > > -- Ix Multimedia Software Jan Luykenstraat 27 3521 VB Utrecht T. 06-51952295 I. www.ixsoftware.nl
[flexcoders] Re: apply style in newly created component
I don't understand. Once you use the "new" operator, the button is instantiated. You can apply all sorts of styles to it before adding it to the displayList. For example, this works for me... var button:Button = new Button; button.label = "My Fancy New Button"; button.setStyle("cornerRadius", 9); button.setStyle("fontSize", 24); button.setStyle("themeColor", '#00FF00'); button.setStyle("fillColors", ['#6699ff', '#6699ff', '#6699ff', '#6699ff']); button.setStyle("fillAlphas", [1, 1, 1, 1]); this.addChild(button); --- In flexcoders@yahoogroups.com, "hworke" wrote: > > > > Hi I am trying to apply style in a newly created component > but since it is not instantiated it gives me error message. > > My code is like this: > > var button:Button = new Button; > button.setStyle("styleName", "myStyle"); > canvas.addChild(button); > I need to create the component dynamically and also need > to apply the style dynamically. How can I do that? > > Regards, >