首页 \ 问答 \ 在AS3中,URLLoader.close();(In AS3, does URLLoader.close(); cause problems if nothing is being loaded?)

在AS3中,URLLoader.close();(In AS3, does URLLoader.close(); cause problems if nothing is being loaded?)

我不确定到底发生了什么,但确实找出了URLLoader.close(); 是原因。

我有一个简单的应用程序,用户将信息输入文本框,然后我将该信息发送到PHP脚本并返回输出。 收到输出后,您可以单击重置应用程序的新按钮。 错误在于单击该按钮后执行的功能。

如果单击该按钮重置应用程序,它将重置所有变量等,但似乎我的addEventListener方法不会执行。

这是重置功能:

//Reset function if the Reset button is pressed
function clearApplication(e:MouseEvent):void {
    receivedData="";
    data1TextBox.text="";
    data2TextBox.text="";
    resetButton.visible=false;
    resetButton.removeEventListener(MouseEvent.CLICK, clearApplication, false);
    goButton.visible=true;
    goButton.addEventListener(MouseEvent.CLICK, getData, false, 0, true);
    myLoader.close();
}

执行此操作后,我的goButton不再有效。

如果单击goButton ,它应执行以下操作:

function getData(e:MouseEvent):void {
    if (data1TextBox.text!=""&&data2TextBox.text!="") {
        goButton.removeEventListener(MouseEvent.CLICK, getData, false);
        goButton.visible=false;

        postVars = new URLVariables();
        postVars.data1=data1TextBox.text;
        postVars.data2=data2TextBox.text;

        myRequest=new URLRequest("URL");
        myRequest.method=URLRequestMethod.POST;
        myRequest.data=postVars;

        myLoader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
        myLoader.load(myRequest);
    }
}

最后,onComplete函数:

function onComplete(e:Event):void {
    receivedData=e.target.data;

    outputTextBox.text=receivedData;

    resetButton.visible=true;
    resetButton.addEventListener(MouseEvent.CLICK, clearApplication, false, 0, true);
}

请注意,未在函数内声明的任何变量都是全局声明的。

所以,我偶然发现了如果我删除myLoader.close();clearApplication函数,然后一切顺利。 如果填写了所有文本字段,我的goButton没有问题并按预期执行。

我知道如果当前没有任何东西被加载是没有必要的,但它是存在的,因为我从来不知道它是否会挂起并需要被取消。 为什么myLoader.close(); 导致这样的事情发生?

编辑:对不起,尝试简化我的代码示例时犯了一些错误。


I am not sure exactly is happening here but did figure out that URLLoader.close(); is the cause.

I have a simple application whereby a user enters info into a textbox, then I send that info to a PHP script and return output. After output is received, you can click a new button that resets the application. The error lies with the function that executes after that button is clicked.

If you click that button to reset the application, it resets all variables, etc, but then it seems my addEventListener method does not execute.

Here is the reset function:

//Reset function if the Reset button is pressed
function clearApplication(e:MouseEvent):void {
    receivedData="";
    data1TextBox.text="";
    data2TextBox.text="";
    resetButton.visible=false;
    resetButton.removeEventListener(MouseEvent.CLICK, clearApplication, false);
    goButton.visible=true;
    goButton.addEventListener(MouseEvent.CLICK, getData, false, 0, true);
    myLoader.close();
}

After this executes, my goButton no longer works.

If the goButton is clicked, it should execute the following:

function getData(e:MouseEvent):void {
    if (data1TextBox.text!=""&&data2TextBox.text!="") {
        goButton.removeEventListener(MouseEvent.CLICK, getData, false);
        goButton.visible=false;

        postVars = new URLVariables();
        postVars.data1=data1TextBox.text;
        postVars.data2=data2TextBox.text;

        myRequest=new URLRequest("URL");
        myRequest.method=URLRequestMethod.POST;
        myRequest.data=postVars;

        myLoader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);
        myLoader.load(myRequest);
    }
}

And finally, the onComplete function:

function onComplete(e:Event):void {
    receivedData=e.target.data;

    outputTextBox.text=receivedData;

    resetButton.visible=true;
    resetButton.addEventListener(MouseEvent.CLICK, clearApplication, false, 0, true);
}

Note that any variables not declared within the functions are declared globally.

So, I stumbled upon the fact that if I delete myLoader.close(); from the clearApplication function then everything works smoothly. My goButton has no issues and executes as expected if all text fields are filled in.

I know it is not necessary if nothing is currently being loaded, but it is there since I never know if it is going to hang and needs to be canceled. Why would myLoader.close(); cause something like this to happen?

Edit: Sorry, made a few mistakes trying to simplify my code for the example.


原文:https://stackoverflow.com/questions/3253293
更新时间:2023-11-03 08:11

最满意答案

首先,方法,字段和类名称以明文形式存储在.class文件中。

其次,除了反射之外,还有java反编译器可以从字节代​​码中恢复几乎可读的代码。

第三,如果你想保护你的代码使用混淆。 有几种流行的java obfuscatotors可用。


First, Method, fields and class names are stored as clear text in .class file.

Second, additionally to reflection there are java decompilers that can restore the almost-readable code from byte code.

Third if you want to protect your code use obfuscation. There are several popular java obfuscatotors available.

相关问答

更多
  • 文字常量的存储本身没有字节码。 .class文件只有一个这些常量的表,当加载类时,它们被放入内存,就像初始化静态变量一样。 There are no bytecodes, per se, involved in the storage of literal constants. The .class file just has a table of these constants, and when the class is loaded they're placed into memory, much l ...
  • RetentionPolicy是关于类的类文件,您在其中添加了注释,而不是注释本身的类文件,例如 @MyAnno public class TestClass {} RetentionPolicy.SOURCE意味着,如果将注释添加到类中,然后尝试使用TestClass.class.getAnnotations()获取该类的所有注释,则它不会成为结果的一部分。 RetentionPolicy is about the class files of classes, where you added the ...
  • 可能有更优雅的方式,但这应该让你开始: a= "\\x00\\x00\\xff\n" a.scan(/\\x([0-9a-f][0-9a-f])/).flatten.collect{|x| x.to_i(16)} # => [ 0, 0, 255 ] to.i(16)将从十六进制字符串转换为十进制。 看起来你正在寻找插值转义序列。 我知道这可以使用eval完成,但不能 。 我认为也可以通过YAML完成。 eval("\"#{a}\"").strip.bytes.to_a # => [ 0, 0, 25 ...
  • 字符串文字是源代码中未命名的字符串常量。 例如, "abc"是一个字符串文字。 如果你做了类似char str[] = "abc";事情char str[] = "abc"; ,那么你可以说str是用文字初始化的 。 str本身不是文字,因为它不是未命名的 。 字符串(或C字符串,而不是)是一个连续的字节序列,以空字节结尾。 char数组不一定是C字符串,因为它可能缺少终止空字节。 A string literal is an unnamed string constant in the source co ...
  • 下面是一些应该有效的快速代码。 您可以做的另一件事是通过查看#US元数据流来读取程序集中的所有字符串文字。 我不久前写了一些代码,如果你有兴趣,我可以把它挖出来。 class Program { static void Main() { foreach (string literal in FindLiterals(typeof(Program).GetMethod("TestMethod1", BindingFlags.NonPublic ...
  • 您可以使用矢量化的str.decode将字节字符串解码为普通字符串: df['COLUMN1'].str.decode("utf-8") 要为多列执行此操作,只需选择str列: str_df = df.select_dtypes([np.object]) 转换全部: str_df = str_df.stack().str.decode('utf-8').unstack() 然后,您可以将原始df cols换算成cols: for col in str_df: df[col] = str_df[ ...
  • 这就是“资源”和“设置”的用途。 您可以通过在Visual Studio中右键单击项目并单击“属性”,然后转到“资源”或“设置”选项卡来找到它。 对于不会经常更改的预构建资源,请使用资源。 对于您希望配置的内容,请使用“设置”,因为它会自动生成App.config的配置块。 如果您不想使用默认值,则仍需要手动复制和粘贴这些值。 两者的好处是VS将构建一个很好的静态类,其中包含可在整个代码中使用的属性。 只要您继续使用向导,VS将动态维护类和资源。 Realized that I could do this ...
  • 首先,方法,字段和类名称以明文形式存储在.class文件中。 其次,除了反射之外,还有java反编译器可以从字节代码中恢复几乎可读的代码。 第三,如果你想保护你的代码使用混淆。 有几种流行的java obfuscatotors可用。 First, Method, fields and class names are stored as clear text in .class file. Second, additionally to reflection there are java decompiler ...
  • 如果你想用“二进制”写它,并且你想节省空间,为什么不用jdk压缩它呢? 满足您的所有要求。 If you want to write it in "binary", and you want to save space, why not just zip it using the jdk? Meets all your requirements.
  • 我不清楚你在问什么,但看起来你的意思是宣布它们? 在这种情况下,请参阅UNICODE_STRING_SIMPLE宏: const UnicodeString someString = UNICODE_STRING_SIMPLE("Some String"); 如果您要声明C样式的Unicode字符串文字,请查看U_STRING_DECL和U_STRING_INIT宏。 另请参见: C ++ Unicode字符串文字 I'm unclear what you're asking about, but it ...

相关文章

更多

最新问答

更多
  • 您如何使用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)