ExtJS表面和精灵创建功能
ExtJS surface and sprite creation functions
我正在尝试创建一个ExtJS应用程序,以基于XML文件创建曲面,然后可以通过鼠标在这些曲面上添加精灵。我在实际函数方面遇到了一些麻烦,这些函数是通过可以从前面列举的源中获得的参数来创建曲面和精灵的。当我在JS控制台中检查tham的值时,我创建的对象返回时未定义。我在它报告的JS中没有任何错误或警告。这是代码:
Ext.ns('myNameSpace');//create namespace to hold all variables
myNameSpace = {
init: function(){//initialize namespace
function surfaceCreator(name){//create surface based on parameter
var name = Ext.create('Ext.draw.Component', {
viewBox: false
});
return name;
}
function spriteCreator(surfaceName,sprite,posX,posY){//draw sprite based on parameters
var sprite = Ext.create('Ext.draw.Sprite', {
type: 'circle',
x: posX,
y: posY,
radius: 25,
surface: surfaceName.surface,
fill: '#cc5'
});sprite.show(true);
}
var mySurface = 'mySurface';//this could be an xml value
var myCircle = 'myCircle';//this could be determined by numbering each one that is created.
var myActualSurface = surfaceCreator(mySurface);//call function to create surface and return surface name as an object
spriteCreator(myActualSurface,myCircle,20,20);//call function to create sprite on specified surface. Also, I could use the mouse coordinates to determine where the sprite should be drawn and make this trigger on 'click'.
var myWin = Ext.create('Ext.Window', {// Create a window to house the surfaces
width: 800,
resizeable: false,
height: 600,
layout: 'fit',
items: myActualSurface//This seems to be undefined somehow and I'm not sure why, as it is defined up above.
}).show();
}
}
Ext.onReady(myNameSpace.init,myNameSpace);//render namespace when webpage is ready.
如果我能对这里可能发生的事情有第二种看法,我会非常高兴。如果有人有一个解决方案(很可能我只是用错了什么),我会欣喜若狂。感谢您的时间和考虑。
我认为这里的主要问题是"surface"属性,请参阅:http://docs.sencha.com/extjs/4.1.3/#/api/Ext.draw.Sprite
您可以使用以下符号将精灵添加到曲面:
surfaceName.add(sprite);
或
var sprite = Ext.create('Ext.draw.Sprite', {
type: 'circle',
x: posX,
y: posY,
radius: 25,
// surface: surfaceName.surface, >> omit this line
fill: '#cc5'
});
{
xtype:'drawcomponent',
items:[sprite]
}
相关文章:
- 如何使用Java脚本创建提交按钮's的拖放功能
- 使用Jquery创建一个具有单击和悬停功能的菜单
- 创建缩放功能当我们点击签署整个页面获得缩放,当我们点击-签署它获得缩小
- .on(“单击”,..)不处理使用相同的单击功能创建的对象
- 我使用什么语言来创建像Webly这样的拖放功能
- 在Google AdWords中创建可重用功能
- 有没有一种方法可以修改在使用javascript的媒体功能的媒体查询下创建的样式
- 创建具有点击幻灯片功能的 jQuery 滑块
- 如何创建一个脚本,该脚本给定网站列表,它使用其搜索功能来获取信息
- 创建具有蓝鸟承诺的节流功能
- Javascript在不同的功能中创建Cookie
- 具有动态幻灯片创建功能的JavaScript滑块
- 按钮创建无法定位功能代码错误
- 从文件目录结构创建JSON数据的有效功能
- 如何创建具有合并和调整大小功能的表
- 在PhpStorm中创建自定义语言,扩展所有html语言功能
- ExtJS表面和精灵创建功能
- 创建功能,允许有不同数量的弹出窗口和可以隐藏它的按钮
- 在d3.js制图中创建功能时出错
- 在设定的时间内创建功能阻滞剂