首页 \ 问答 \ 由于AS3中的URLloader,嵌套函数调用的运行顺序延迟/改变了?(Running-order of nested function-calls delayed/altered due to URLloader in AS3?)

由于AS3中的URLloader,嵌套函数调用的运行顺序延迟/改变了?(Running-order of nested function-calls delayed/altered due to URLloader in AS3?)

首先:英语不是我的第一语言。 ;-)

我正在编译以下代码:

var sqldata:String;
function sql(saveorload,sqlstring) {
    var sqlloader = new URLLoader();
    var sqlrequest = new URLRequest("http://***/sql.php");
    sqlrequest.method = URLRequestMethod.POST;
    sqlloader.addEventListener(Event.COMPLETE, sqldonetrace);

    var variables:URLVariables = new URLVariables();
    variables.sqlm = saveorload;
    variables.sqlq = sqlstring;
    sqlrequest.data = variables;

    sqlloader.load(sqlrequest);
}
function sqldonetrace(e:Event) {
    sqldata = e.target.data;
}
sql("1","SELECT * FROM songs WHERE `flag2` LIKE '0'");
trace (sqldata);

所以,问题出现了:“sqldata”被追踪为“null”。 AS3似乎运行“sql”,然后“跟踪”然后“sqldone”,但我需要sql - > sqldone - > trace ...我不能把trace-command放在sqldone函数中因为它存储了as * .as并在我的.swf中的不同点加载,并不总是只跟踪一个trace-command。

脚本中的任何想法/提示/缺陷?


First of all: English is not my first language. ;-)

I am compiling the following code:

var sqldata:String;
function sql(saveorload,sqlstring) {
    var sqlloader = new URLLoader();
    var sqlrequest = new URLRequest("http://***/sql.php");
    sqlrequest.method = URLRequestMethod.POST;
    sqlloader.addEventListener(Event.COMPLETE, sqldonetrace);

    var variables:URLVariables = new URLVariables();
    variables.sqlm = saveorload;
    variables.sqlq = sqlstring;
    sqlrequest.data = variables;

    sqlloader.load(sqlrequest);
}
function sqldonetrace(e:Event) {
    sqldata = e.target.data;
}
sql("1","SELECT * FROM songs WHERE `flag2` LIKE '0'");
trace (sqldata);

So, here comes the problem: "sqldata" is traced as "null". AS3 seems to run "sql", then "trace" and then "sqldone", but i would need sql -> sqldone -> trace... I can't put the trace-command in the sqldone-function because it is stored as *.as and loaded at different points in my .swf and not always followed by only a trace-command.

Any Ideas/hints/flaws in script?


原文:https://stackoverflow.com/questions/16153739
更新时间:2023-07-20 19:07

最满意答案

教程在幻灯片3中说,“所有数组都是(双重)类型”,这意味着 - 通常用于不同类型 - 你不能在两种数组类型之间进行分配; 所以是的,你需要一个循环。

有一些“聪明”的方法,例如,未经检查的转换; 但是,真的,不要去那里!


The tutorial says, on slide 3, that "all arrays are (doubly) typed", which means that - as usual for different types - you can't assign between your two array types; so yes, you need a loop.

There are "clever" ways using, for example, unchecked conversion; but, really, don't go there!

相关问答

更多
  • 对于子类型, 'pos将返回与基类型相同的值(我相信分别为1..4和2..3)。 亚型并不是真正的新型和不同类型,尽管它们是相同的旧型,但对其可能的值有一些额外的限制。 但应该指出的是,这些值是在场景下分配的。 除非您使用'val 'pos和'pos属性,或者您正在与Ada(或硬件)之外编写的代码进行交互,否则它确实应该对您没有任何影响 。 另外,如果它最终成为问题,你应该知道情况实际上要复杂得多。 'pos和'val不会返回编译器在生成代码时使用这些枚举值的实际位值。 他们只是返回他们的“序位”; 他们偏 ...
  • 在第一个声明中,声明了一个与Integer不同的新类型,但是从它继承了一些属性(例如原始函数和运算符,不是那么重要)。 对于每一个实际问题,在这种情况下abc和def类型在语义上是等价的。 但是,如果您对基本类型进行了基本操作,则会有所不同。 在这种情况下,你不能真的认为范围的边界有类型,但是如果有基类型,它们必须满足在基类型范围内的限制。 现在xyz简直是不正确的,整数在这里没有任何意义。 它可能意味着两件事: 你真的想声明一个从整数派生的新类型。 在这种情况下,你错过了新的关键字。 你想声明一个整型的子 ...
  • 你不能拥有一系列不受约束的元素。 一些替代品: 使用不定矢量。 (好!) 创建一个对您的不定类型的访问数组。 (坏!) You can't have an array of unconstrained elements. Some alternatives: Use an indefinite vector. (Good!) Create an array of access to your indefinite type. (Bad!)
  • 查看Debian / Jessie中libplplot-ada1-dev软件包提供的源文件,可以在Ada 95版本或Ada 2005版本中提供软件包PLPlot_Auxilary 。 Ada 2005版本使用Ada数字包,而Ada 95版本则不使用。 Looking in the source files provided by the libplplot-ada1-dev package in Debian/Jessie, it looks like package PLPlot_Auxilary can ...
  • 教程在幻灯片3中说,“所有数组都是(双重)类型”,这意味着 - 通常用于不同类型 - 你不能在两种数组类型之间进行分配; 所以是的,你需要一个循环。 有一些“聪明”的方法,例如,未经检查的转换; 但是,真的,不要去那里! The tutorial says, on slide 3, that "all arrays are (doubly) typed", which means that - as usual for different types - you can't assign between y ...
  • 数组的问题在于,在所有表达式中(除了传递给sizeof和一元&运算符时),它们都转换为指向其第一个元素的指针。 所以,假设你有: int arr1[10]; int arr2[10]; ... 然后,如果你写了类似的东西 arr1 = arr2; 你实际上正在尝试这样做: arr1 = &arr2[0]; 或这个: &arr1[0] = &arr2[0]; 在这两种情况下,您都遇到阻止编译代码的问题。 在前一种情况下,您试图在两个不兼容的类型(数组vs指针)之间进行分配,而在后一种情况下,您试图修改 ...
  • 这是对原始答案的重写,现在我们知道有问题的任务类型是有区别的。 您通过“判别式”将值传递给每个任务而没有默认值,这使得任务类型不受约束; 如果没有为判别式提供值,则无法声明该类型的对象(并且提供默认值将无济于事,因为一旦创建了对象,则无法更改判别式)。 一种常见的方法是使用访问类型: with Ada.Integer_Text_IO; with Ada.Text_IO; procedure Maciek is task type T (Param : Integer); type T_P is ...
  • 这有点低级和重复性,但也许你可以创建一个小程序(甚至可以在Ada中!)来生成类似的东西 with Ada.Text_IO; use Ada.Text_IO; procedure Lambdabeta is F1 : aliased constant String := "res/0.file"; F2 : aliased constant String := "res/some_more/complicated/file.name"; type Strings is array (Posi ...
  • 您的AU定义为以1的下限开始(范围为1..10的匿名数组子类型)。 这永远不会改变。 对于无约束的结果(c和d),您应该分配一个新变量,如下所示: declare AU_c : TU := AU(6..10) & AU(1..5); AU_d : TU := AU(6) & AU(7..10)& AU(1..5); begin -- your Put/Put_Lines here end; Your AU is defined to start with lower bound of 1 ...
  • Ada可以使用动态固定字符串,而不使用Unbounded_String或Containers,或分配和指针,尽管这些是选项。 使这成为可能的见解是,字符串可以在声明时从其初始化表达式中获取其大小 - 但该声明可以在循环内部,因此每次循环时它都会重新执行。 你不能总是构建一个程序,所以这是有道理的,虽然它可能经常令人惊讶,只需要一点点思考。 另一个特点是,稍后,这些“声明”块可以很容易地重构到程序中。 with Ada.Text_IO; use Ada.Text_IO; procedure Calculat ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)