-
[RESOLVED] TypeError 1034. Possibly a URLRequest/ URLLoader problem.
Peek-a-boo, me again. I'm having some trouble with loading in a txt-file and I can't figure out why, as it works in a new .fla file as well. Here's the code in a nutshell:
PHP Code:
goldstar.addEventListener(MouseEvent.MOUSE_DOWN, showHS);
var weekrequest:URLRequest = new URLRequest("weekscores.txt");
var weekloader:URLLoader = new URLLoader();
//weekloader.dataFormat = URLLoaderDataFormat.VARIABLES;
//Not sure on this one, reading in data like this is completely new to me.
weekloader.addEventListener(Event.COMPLETE, checkWeek);
function showHS(MouseEvent):void{
weekloader.load(weekrequest); // --> checkWeek
trace("loaded"); //This works
}
function checkWeek(event:Event):void{
var loader2:URLLoader = URLLoader(event.target);
//This seems to be the problem.
var variables:URLVariables = new URLVariables(loader2.data);
}
This gives me the following error:
Code:
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Stage@2cdcf191 to flash.net.URLLoader.
at Game_fla::MainTimeline/checkWeek()
at Game_fla::MainTimeline/launchloop()
I've also tried several different traces, but they either returned null or nothing, but there's definitely an array of numbers in the .txt file.
As always, thanks in advance.
-Patrick
Last edited by senshi sentou; 01-08-2010 at 05:28 PM.
-
In checkweek, what comes back if you
trace(event.target)
trace(typeof event.target)
It sounds like the event.target is the stage by the error, but that doesn't sense.
I (Love | Hate) Flash.
----
Save a version back so others may help you!
-
It sounds like the event.target is the stage by the error, but that doesn't sense.
That's what I was thinking too, but I can't think of a why. o.o;
The traces give back
[object URLLoader] and object respectively.
Also, I forgot to mention the error actually fires before function showHS....Ok, I feel stupid now. While typing this, I realized the problem might lie somewhere completely different, and it did. In a loop, chechWeek was accidentally turned on, meaning it was also checking before the Event.COMPLETE event...
Argh, I'm sorry for taking your time, but thanks!
-Patrick
-
I do that all the time. Sometimes it takes you laying the problem out step for step for someone else to help solve when the problem reveals itself
I (Love | Hate) Flash.
----
Save a version back so others may help you!
-
Yup, you're absolutely right xD Thanks again =)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|