-
8 Apr 2011 3:11 AM #1
[B2] Gradients not working when I extend Ext.draw.Component
[B2] Gradients not working when I extend Ext.draw.Component
When I to add gradients to my extended class from Ext.draw.Sprite it always crashes in internet explorer.
Here is my extended class:
But when I just create an instance of the Ext.draw.Component is does not crash and shows the gradient:Code:Ext.define('Editor.Layout.Surface', { extend: 'Ext.draw.Component', viewBox: false, gradients: [{ id: 'blackblue', viewBox: true, angle: 90, stops: { 0: { color: 'rgb(33, 33, 33)' }, 100: { color: 'rgb(156, 178, 248)' } } }] }); lSurface = Ext.create('Editor.Layout.Surface', {});
The error message:Code:lSurface = Ext.create('Ext.draw.Component', { viewBox: false, gradients: [{ id: 'blackblue', viewBox: true, angle: 90, stops: { 0: { color: 'rgb(33, 33, 33)' }, 100: { color: 'rgb(156, 178, 248)' } } }] });
on this line:'gradientsCall' is empty or no object
If you like a testcase:Code:if (fillUrl.charAt(0) == "#") { gradient = me.gradientsColl.getByKey(fillUrl.substring(1)); }
The 2 different methods are in there, you can see that the content of the defined class is the exact same as the instance of the component.Code:Ext.onReady(function () { // Test with the extended class: Ext.define('Canvas', { extend: 'Ext.draw.Component', viewBox: false, gradients: [{ id: 'blackblue', angle: 45, stops: { 0: { color: 'rgb(33, 33, 33)' }, 100: { color: 'rgb(156, 178, 248)' } } }] }); var canvas = Ext.create('Canvas'); //Test with the instance of Ext.draw.Component: // var canvas = Ext.create('Ext.draw.Component', { // viewBox: false, // gradients: [{ // id: 'blackblue', // angle: 45, // stops: { // 0: { // color: 'rgb(33, 33, 33)' // }, // 100: { // color: 'rgb(156, 178, 248)' // } // } // }] // }); Ext.define('Test.Control.Event', { extend: 'Ext.draw.Sprite', constructor: function () { this.callParent([{ type: 'circle', x: 150, y: 150, radius: 100, fill: 'url(#blackblue)', stroke: '#000', surface: canvas.surface }]); } }); //create a window to place the draw component in Ext.create('Ext.Window', { width: 1000, height: 500, layout: 'fit', items: [canvas] }).show(); s = canvas.surface.add(new Test.Control.Event()); s.show(true); });
Is this a bug or am I extending whrong?
-
8 Apr 2011 9:17 AM #2
Hi,
it seems that gradients are only added while creation. If you change your code this way it works:
Code:Ext.define('Canvas', { extend: 'Ext.draw.Component', viewBox: false }); var canvas = Ext.create('Canvas', { gradients: [{ id: 'blackblue', angle: 45, stops: { 0: { color: 'rgb(33, 33, 33)' }, 100: { color: 'rgb(156, 178, 248)' } } }] });vg Steffen
--------------------------------------
Release Manager of TYPO3 4.5
energlobe.de - german online magazine
-
9 Apr 2011 5:14 PM #3
Hi, thank you for your report.
I don't believe this is an issue. I think that you are confusing configuration properties (passed in the creation of an instance) with class methods/properties defined when extending a Class from another Class. This is different. The right way to extend a class and setting these gradients as configuration by default would be to override the `constructor` method appending the gradients property to the config object and then calling the parent constructor.
Let me know if this works for you.
-
10 Apr 2011 11:03 PM #4
Hey
It worked for me thanks
Code:Ext.define('Editor.Layout.Surface', { extend: 'Ext.draw.Component', viewBox: false, constructor: function (config) { this.gradients = [{ id: 'gradTask', viewBox: true, angle: 25, stops: { 0: { color: 'rgb(255, 255, 0)' }, 100: { color: 'rgb(255, 255, 255)' } } }]; if (this.gradients) { Ext.apply(config, { gradients: this.gradients }); } this.callParent([config]); } });
-
10 Apr 2011 11:05 PM #5
This should be documented as it's not selfexplained.
vg Steffen
--------------------------------------
Release Manager of TYPO3 4.5
energlobe.de - german online magazine
-
28 Jan 2012 12:41 AM #6
Just ran into this myself. Any way to update how this works or if not update the documentation?
-
27 Jun 2012 7:43 AM #7Sencha - Senior Forum Manager
- Join Date
- Mar 2007
- Location
- St. Louis, MO
- Posts
- 33,714
- Vote Rating
- 436
There shouldn't be any reason why gradients defined on the prototype using Ext.define should not work. I'm going to reopen this report.
EXTJSIV-831Mitchell Simoens @SenchaMitch
Sencha Inc, Senior Forum Manager
________________
http://www.JSONPLint.com - Source to lint your JSONP!
Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
https://github.com/mitchellsimoens
Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/
Need more help with your app? Hire Sencha Services services@sencha.com
Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is almost in print!
When posting code, please use BBCode's CODE tags.
You found a bug! We've classified it as
EXTJSIV-831
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
Similar Threads
-
[CLOSED-EXTJSIV-800] Ext.draw.Component is not rotating in IE
By vega109 in forum Ext:BugsReplies: 4Last Post: 10 Apr 2011, 7:33 AM -
[OPEN-EXTJSIV-572][B1] Draw Component misses filters
By steffenk in forum Ext:BugsReplies: 3Last Post: 1 Apr 2011, 12:22 AM -
[FIXED-EXTJSIV-445] Ext.draw.Component: Render Items Config not rendered right
By Nickname in forum Ext:BugsReplies: 5Last Post: 29 Mar 2011, 8:45 AM -
[PR4] [VML][FIXED-EXTJSIV-163] Crash when I draw more than 27 draw.Components
By johanhaest in forum Ext:BugsReplies: 1Last Post: 18 Mar 2011, 9:35 AM -
[OPEN-EXTJSIV-157] Ext.draw.Component viewbox issue
By 4CastRisk in forum Ext:BugsReplies: 1Last Post: 17 Mar 2011, 4:16 PM


Reply With Quote