错误#1006:值不是函数
//创建URLLOader实例 var myLoader:URLLoader = new URLLoader();
//the data will come as URL-encoded variables
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES
//Load using an URLRequest, even beeing local
myLoader.load(new URLRequest("flash/index.php"))
//onLoad handler listener
myLoader.addEventListener(Event.COMPLETE, onDataLoad)
//add a listener for the complete event
function onDataLoad(evt:Event){
for(var i:uint=0; i<evt.target.data.cant; i++){
var mc_holder:MovieClip = new MovieClip();
mc_holder.name = "mc_holder"+i;
mc_holder.x = 30;
mc_holder.y = mc_holder.height+10;
//trace(mc_holder.y = mc_holder.height*i)
addChild(mc_holder);
var loader:Loader = new Loader()
loader.load(new URLRequest(evt.target.data["Image"+i]))
mc_holder.addChild(loader)
mc_holder.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(e:MouseEvent):void {
var my_thumb = e.target.name;
trace(my_thumb);
my_thumb.startDrag();
}
这给了我错误 Error #1006: value is not a function。当我点击拖动时
//Create the URLLOader instance
var myLoader:URLLoader = new URLLoader();
//the data will come as URL-encoded variables myLoader.dataFormat = URLLoaderDataFormat.VARIABLES //Load using an URLRequest, even beeing local myLoader.load(new URLRequest("flash/index.php")) //onLoad handler listener myLoader.addEventListener(Event.COMPLETE, onDataLoad) //add a listener for the complete event function onDataLoad(evt:Event){ for(var i:uint=0; i<evt.target.data.cant; i++){ var mc_holder:MovieClip = new MovieClip(); mc_holder.name = "mc_holder"+i; mc_holder.x = 30; mc_holder.y = mc_holder.height+10; //trace(mc_holder.y = mc_holder.height*i) addChild(mc_holder); var loader:Loader = new Loader() loader.load(new URLRequest(evt.target.data["Image"+i])) mc_holder.addChild(loader) mc_holder.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler); function mouseDownHandler(e:MouseEvent):void { var my_thumb = e.target.name; trace(my_thumb); my_thumb.startDrag(); }
This gives me error Error #1006: value is not a function. when i click on drag
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您的代码中有很多错误。您还试图用一种方法做太多事情。您解析数据,创建影片剪辑,添加加载器,加载图像,然后调用加载器上的函数...我试图消除明显的错误,但毫无疑问,您的代码可以通过分离来改进的担忧。
如果您将代码拆分为单独的方法,您的代码将更加灵活&调试起来也容易得多...你可以加载&解析变量,在另一个函数中为设计准备 XML 数据,然后将显示逻辑留给另一个方法。
与此同时,这是错误较少的代码
There are a lot of errors in your code. You're also trying to do too much with one single method. You parse your data, create a movie clip , add a loader , load an image then call a function on the loader... I've tried to get rid of the obvious mistakes , but there's no doubt your code could be improved by separating concerns.
If you split your code into separate methods, your code will be more flexible & much easier to debug too... You could load & parse your variables , in another function prepare your XML data for your designs , then leave the display logic to another method.
In the meantime, here's your code with less mistakes
您发布的代码似乎有语法错误,但我认为您的问题的解决方案应该是调用
e.target.startDrag();
。通过调用my_thumb.startDrag();
,您尝试在e.target.name
上调用不存在的函数startDrag
。或者你可以替换
为
You posted code seems to have syntactical errors, but I think the solution for your problem should be the call of
e.target.startDrag();
. With your call ofmy_thumb.startDrag();
you are trying to call a functionstartDrag
one.target.name
which doesn't exists.Alternativly you can replace
with