I have a small error in AS3 that I just can’t seem to fix. I’ve tried many things. Analyzing my code and I still can’t find anything that is taking me to this error.
Well, I’ve been working on an account creation program that I’m using to well…, create an account for my website. Here is my code that I think is problematic(I have cut out all irrelevant code):
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.net.*;
public class Main extends MovieClip{
var contact_url:String = "create.php";
var contactRequest:URLRequest = new URLRequest(contact_url);
var contactLoader:URLLoader = new URLLoader();
public function Main() {
contactRequest.method=URLRequestMethod.POST;
Frame2.create_account.addEventListener(MouseEvent.MOUSE_UP, createAccount);
Frame3.myResult.backButton.addEventListener(MouseEvent.MOUSE_UP, goBack);
}
private function goBack(mE:MouseEvent):void{
Frame2.visible=true;
Frame3.visible=false;
}
private function createAccount(mE:MouseEvent){
var accountData:String="username="+Frame2.user_id.text
+"&userpass="+Frame2.pass_word.text
+"&usercol="+Frame2.colorPicker.sColor.text;
var contactVariables:URLVariables = new URLVariables(accountData);
contactVariables.dataFormat=URLLoaderDataFormat.TEXT;
contactRequest.data=contactVariables;
contactLoader.load(contactRequest);
contactLoader.addEventListener(Event.COMPLETE, myResponse);
}
private function myResponse(e:Event):void{
var loader:URLLoader=new URLLoader(e.target);
var server_status:URLVariables=new URLVariables(loader.data).result;
if(server_status.data=="success"){
Frame3.visible=true;
Frame3.myResult.resultText.text = "You have successfully registered your account! Congrats!"
}else{
Frame3.visible=true;
Frame3.myResult.resultText.text = "Error! The username has already been registered."
}
}
}
}
I know that the variable accountData is working correctly, but I don’t know where my error is coming from. Here is my error:
C:\Users\Admin\Desktop\Main.as, Line 64 1118: Implicit coercion of a value with static type Object to a possibly unrelated type flash.net:URLRequest.
On my computer, it’s line 64. The rest of the code really is completely unrelated.
Does anybody know why it’s doing this?
Line 64:
var loader:URLLoader=new URLLoader(e.target);