Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




AS3 PHP URLLoader



Hi there,

I'm developing in AS3 in Flex compiled in CS3. I'm succesfully sending data from an AS3 form via PHP to MySQL, but my loader.addEventlistener(Event.COMPLETE, sendComplete) fires only in the CS3 enviroment, but not in the browser with FP10/9.


Code:
public function sendData():void{
variables = new URLVariables();
fData = new URLRequest("fSubmit.php");
fData.method = URLRequestMethod.POST;
fData.data = variables;

fLoader = new URLLoader();
fLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
fLoader.addEventListener(Event.COMPLETE, sendComplete);
variables.voorletters = form.vl.text;
variables.tussenvoegsel = form.tv.text;
variables.achternaam = form.an.text;
variables.geslacht = rbg.selection.value;
variables.gdag = cb1.value;
variables.gmaand = cb2.value;
variables.gjaar = cb3.value;
variables.straatnaam = form.sn.text;
variables.huisnummer = form.hn.text;
variables.toevoeging = form.htv.text;
variables.postcodecijfers = form.pc1.text;
variables.postcodeletters = form.pc2.text;
variables.plaats = form.pl.text;
variables.telefoon = form.tn.text;
variables.email = form.ea.text;
fLoader.load(fData);
}

private function sendComplete(e:Event):void{
if(e.target.data.writing == "Ok"){
alert("Bedankt uw!");
}else{
var s:String = e.target.data.writing;
alert(s);
}
}

PHP echo


Code:
echo "&writing=Ok&s=s";
for some reason the only way I got access to the "write" property was by adding an 'unnecessary' variable 's'. Any idea how I could get the sendComplete going?

thanks,

Tomi



ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 12-28-2008, 07:31 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

URLLoader And SSL
Hi,

On my server I'm running some SWFs which in turn call the server to fetch some XML.
Movies and scripts are located on the same domain, server and directory so the path is set to a relative relative path (ie. name of php file in same dir).
Crossdomain file is copied to root and even several other directories (if that now should be needed).

The Flash is developed with AS3 and for player version 9 > and uses an instance of the URLLoader like this:

var urq = new URLRequest("getxml.php");
var loader = new URLLoader(urq);
loader.addEventListener(Event.COMPLETE, xmlLoaded);

Now all works well with HTTP but not HTTPS.

Anyone - any clue ?

Thanks for any reply,
Bjorn

URLLoader... Which Url?
When a URLLoader (that was passed a URLRequest object) fires an event like the 'complete' event, the 'target' attribute of the event parameter is the URLLoader... however, because of certain program logic, I need to be able to tell from the URLLoader what the URLRequest (or more specifically, what the url) is for that particular event response. For instance, if I have 10 different urls that I fire off 10 different loaders with, I need a single event handler to be able to tell which url the response came from is for certain processing.

I have been unable to figure out how to take the URLLoader reference and get it to tell me the URLRequest or the url it comes from. Why?

What could possibly be the reason for the URLLoader not keeping a (public) reference to the URLRequest used by the last load call? This seems like an incredibly dull and limiting decision by the designers of this class.

Anyone have any thoughts?

Loader Or URLLoader
Hi There,

Just wondering, in which instances you would use the loader class and in which instance you would use URLLoader instead. Basically, whats the difference?

Thanks

URLLoader And BytesTotal
Hi guys,

I'm registering for the ProgressEvent.PROGRESS event on a URLLoader object. The URLLoader object is loading a fairly large xml file (50KB).

It appears that the bytesTotal (and perhaps bytesLoaded) value is incorrect. It seems fine locally but as soon as I put the swf on a web server it's wrong.

I've attached my source .as file and some trace output. I'd really appreciate it if somebody took a quick look. Thanks!

Adding Img From XML Using URLLoader
I am loading my XML in fine and I can get the path of the image. I am having a problem adding the image to the Display list once its done. Can someone help me figure this out. I have a movieclip in my library with linkage CourseClip. Once my XML loads and create a new CourseClip, add the text to the text field inside and then create a loader. I want the image to load into

cc.thumb

Thats my instance name. So essentially it would be __holder["thumb"].addChild(__loader);

but that isnt working. Any ideas?
code:
package com.dop
{
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.*;
import flash.events.*;
public class VTODGrid extends MovieClip
{

private var __holder:MovieClip;
private var __loader:URLLoader;
private var __xml:XML;
private var __xmlList:XMLList;
private var __xmlData:Array;
private var cc:CourseClip;

public function VTODGrid(holder:MovieClip,xml:String)
{
__holder = holder;
__loader = new URLLoader();
__loader.load(new URLRequest(xml));
__loader.addEventListener(Event.COMPLETE, loadXML);
}
private function loadXML(e:Event):void
{
__xml = new XML(__loader.data);
__xmlList = new XMLList(__xml.item);
var nbrColumns = 4;
var leftMargin = 0;
var topMargin = 0;
var cellWidth = 150;
var cellHeight = 100;
for (var i:int = 0; i < __xmlList.length(); i++)
{
var cellX = i % nbrColumns;
var cellY = Math.floor(i / nbrColumns);
cc = new CourseClip();
cc.x = leftMargin + cellX * cellWidth;
cc.y = topMargin + cellY * cellHeight;
cc["txt"].text = __xmlList[i].@title;
__loader = new URLLoader();
__loader.load(new URLRequest(__xmlList[i].@thumb));
__loader.addEventListener(Event.COMPLETE, loadImage);
__holder.addChild(cc);
}
}
private function loadImage(e:Event):void
{
trace(e.currentTarget);
}
}
}

[as3] Text URLLoader
let me start off by saying, to further my as3 learning exsperiance I removed all library items, and recreating every library item with actionscript. And now I can't seem to load external text into my text field. or associate the mask or scroll bar to the text field. below is my output errors and below that is my complete code. any help will be greatly appreciated,
ps sorry code is so long but figured it was nessasary
thanks sincerely sybershot

output errors

Code:
TypeError: Error #1010: A term is undefined and has no properties.
at changescrolltextwithbar3_fla::MainTimeline/frame1()
TypeError: Error #1010: A term is undefined and has no properties.
at changescrolltextwithbar3_fla::MainTimeline/onLoaded()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()


as3 code

Code:
var a = "myText.txt";
var b = "myText2.txt";
var c = "myText3.txt";
var d = "myText4.txt";
var e = "myText5.txt";
var defaultText = a;

var contents:MovieClip = new MovieClip
var content:TextField = new TextField();
content.wordWrap=true;
content.border = true
content.width = 379;
content.height =300;
this.contents.addChild(content);
this.contents.y = 26;
addChild (contents);

import gs.TweenMax;
import fl.motion.easing.*;
TweenMax.from(content, 5, {y:"-100", ease:Elastic.easeOut});

stage.scaleMode = StageScaleMode.NO_SCALE;

var masker:MovieClip = new MovieClip();
masker.graphics.beginFill(0x2C02D2,.1);
masker.graphics.lineStyle(0, 0x111111, 0);
masker.graphics.moveTo(0,0);
masker.graphics.lineTo(379, 0);
masker.graphics.lineTo(379, 300);
masker.graphics.lineTo(0, 300);
masker.graphics.lineTo(0,0);
masker.graphics.endFill();
this.contents.addChild(masker);

var track:MovieClip = new MovieClip();
var fillType:String = GradientType.LINEAR;
var colors:Array = [0x333333, 0x777777];
var alphas:Array = [100, 100];
var ratios:Array = [0, 255];
var matr:Matrix = new Matrix();
matr.createGradientBox(175,250,250,50,50);
var spreadMethod:String = SpreadMethod.PAD;
track.graphics.beginGradientFill(fillType, colors, alphas, ratios, matr, spreadMethod);
track.graphics.lineStyle(1, 0x111111, 1);
track.graphics.moveTo(0,0);
track.graphics.lineTo(10, 0);
track.graphics.lineStyle(1, 0x777777, 1);
track.graphics.lineTo(10, 300);
track.graphics.lineStyle(2, 0x666666, 1);
track.graphics.lineTo(0, 300);
track.graphics.lineStyle(2, 0x111111, 1);
track.graphics.lineTo(0, 0);
track.graphics.endFill();

var thumb:MovieClip = new MovieClip();
var fillType2:String = GradientType.LINEAR;
var colors2:Array = [0x777777, 0x333333];
var alphas2:Array = [999, 999];
var ratios2:Array = [0, 255];
var matr2:Matrix = new Matrix();
matr2.createGradientBox(5,5,0,5,5);
var spreadMethod2:String = SpreadMethod.PAD;
thumb.graphics.beginGradientFill(fillType2, colors2, alphas2, ratios2, matr2, spreadMethod2);
thumb.graphics.lineStyle(0, 0x111111, 0);
thumb.graphics.moveTo(-1,-1);
thumb.graphics.lineTo(12, -1);
thumb.graphics.lineTo(12, 40);
thumb.graphics.lineTo(-1, 40);
thumb.graphics.lineTo(-1, -1);
thumb.graphics.endFill();
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.color = 0x000000;
dropShadow.blurX = 10;
dropShadow.blurY = 10;
dropShadow.angle = 0;
dropShadow.alpha = 0.5;
dropShadow.distance = 3;
var filtersArray:Array = new Array(dropShadow);
thumb.filters = filtersArray;

var sb:MovieClip = new MovieClip();
this.sb.addChild(track);
this.sb.addChild(thumb);
this.contents.addChild(sb);
this.sb.x = 380;
this.sb.y =0;

var fillType3:String = GradientType.LINEAR;
var colors3:Array = [0x777777, 0x333333,];
var alphas3:Array = [1, 1];
var ratios3:Array = [0, 255];
var matr3:Matrix = new Matrix();
matr3.createGradientBox(200,100,0,-50,100);
var spreadMethod3:String = SpreadMethod.PAD;

var btn1:MovieClip = new MovieClip();
btn1.graphics.beginGradientFill(fillType3, colors3, alphas3, ratios3, matr3, spreadMethod3);
btn1.graphics.lineStyle(1, 0x111111, .5);
btn1.graphics.moveTo(0,0);
btn1.graphics.lineTo(75, 0);
btn1.graphics.lineTo(75, 25);
btn1.graphics.lineTo(0, 25);
btn1.graphics.lineTo(0, 0);
btn1.graphics.endFill();
addChild(btn1);

var btn2:MovieClip = new MovieClip();
btn2.graphics.beginGradientFill(fillType3, colors3, alphas3, ratios3, matr3, spreadMethod3);
btn2.graphics.lineStyle(1, 0x111111, .5);
btn2.graphics.moveTo(0,0);
btn2.graphics.lineTo(75, 0);
btn2.graphics.lineTo(75, 25);
btn2.graphics.lineTo(0, 25);
btn2.graphics.lineTo(0, 0);
btn2.graphics.endFill();
addChild(btn2);
this.btn2.x = 76;

var btn3:MovieClip = new MovieClip();
btn3.graphics.beginGradientFill(fillType3, colors3, alphas3, ratios3, matr3, spreadMethod3);
btn3.graphics.lineStyle(1, 0x111111, .5);
btn3.graphics.moveTo(0,0);
btn3.graphics.lineTo(75, 0);
btn3.graphics.lineTo(75, 25);
btn3.graphics.lineTo(0, 25);
btn3.graphics.lineTo(0, 0);
btn3.graphics.endFill();
addChild(btn3);
this.btn3.x = 152;

var btn4:MovieClip = new MovieClip();
btn4.graphics.beginGradientFill(fillType3, colors3, alphas3, ratios3, matr3, spreadMethod3);
btn4.graphics.lineStyle(1, 0x111111, .5);
btn4.graphics.moveTo(0,0);
btn4.graphics.lineTo(75, 0);
btn4.graphics.lineTo(75, 25);
btn4.graphics.lineTo(0, 25);
btn4.graphics.lineTo(0, 0);
btn4.graphics.endFill();
addChild(btn4);
this.btn4.x = 228;

var btn5:MovieClip = new MovieClip();
btn5.graphics.beginGradientFill(fillType3, colors3, alphas3, ratios3, matr3, spreadMethod3);
btn5.graphics.lineStyle(1, 0x111111, .5);
btn5.graphics.moveTo(0,0);
btn5.graphics.lineTo(75, 0);
btn5.graphics.lineTo(75, 25);
btn5.graphics.lineTo(0, 25);
btn5.graphics.lineTo(0, 0);
btn5.graphics.endFill();
addChild(btn5);
this.btn5.x = 304;

var txtLoader:URLLoader;
loadText();

function loadText():void {
txtLoader = new URLLoader()
txtLoader.addEventListener(Event.COMPLETE, onLoaded);
txtLoader.load(new URLRequest(defaultText));

btn1.addEventListener(MouseEvent.CLICK, btn_click);
btn2.addEventListener(MouseEvent.CLICK, btn_click);
btn3.addEventListener(MouseEvent.CLICK, btn_click);
btn4.addEventListener(MouseEvent.CLICK, btn_click);
btn5.addEventListener(MouseEvent.CLICK, btn_click);
}

function onLoaded(e:Event):void
{
if (content.height < sb.track.height) {
sb.alpha = 0;
} else if (content.height > sb.track.height) {
sb.alpha = 1;
sb.thumb.y = yMin;
content.y = masker.y;
}
content.autoSize = TextFieldAutoSize.LEFT;
content.text = String(txtLoader.data);
}

function btn_click(event:MouseEvent){
var selected_text:String
if(event.target.name == "btn1") {
selected_text = a;
} else if(event.target.name == "btn2") {
selected_text = b;
} else if(event.target.name == "btn3") {
selected_text = c;
} else if(event.target.name == "btn4") {
selected_text = d;
} else if(event.target.name == "btn5") {
selected_text = e;
}
txtLoader.load (new URLRequest(selected_text));
}

var yOffset:Number;
var yMin:Number = 0;
var yMax:Number = sb.track.height - sb.thumb.height;

sb.thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);

function thumbDown(e:MouseEvent):void {
stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
yOffset = mouseY - sb.thumb.y;
}

function thumbUp(e:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}

function thumbMove(e:MouseEvent):void {
sb.thumb.y = mouseY - yOffset;
if (sb.thumb.y <= yMin) {
sb.thumb.y = yMin;
}
if (sb.thumb.y >= yMax) {
sb.thumb.y = yMax;
}
var sp:Number = sb.thumb.y / yMax;
TweenMax.to(content, 1, {y:(-sp*(content.height - masker.height)), ease:Back.easeOut});
e.updateAfterEvent();
}

Nasty Urlloader
Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()



heres my code, compiles fine:

function sendData(url:String, _vars:URLVariables):void {
var request:URLRequest = new URLRequest(url);
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.data = _vars;
request.method = URLRequestMethod.POST;
loader.addEventListener(Event.COMPLETE, handleComplete);
loader.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
loader.load(request);
}

function handleComplete(event:Event):void {
trace("complete");
play();
}

function onIOError(event:IOErrorEvent):void {
trace("Error loading URL.");
}

iSubmit.addEventListener(MouseEvent.CLICK, submitFunction);

stop();

function submitFunction(evt:MouseEvent):void {
var url:String = "request.php";
var variables:URLVariables = new URLVariables();

variables.c_FullName = iName.text;
variables.c_Company = iCompany.text;
variables.c_EMail = iEMail.text;
variables.c_Nature = iNature.text;

sendData(url, variables);
}

URLLoader Repeating Itself
Hi there,

I'm pretty new to Flash and AS3 but I've managed to figure most of my problems out with the help of books and the net...I'm having a problem with a URLLoader and I just cannot work it out.

The problem is that when I click on my buttons that start the function containing the URLLoader, the Loader loads the data repeatedly, as many times as I have clicked on a button. So, for example, if I click a button it will load the data twice. Click again and it loads it three times, again and it loads it four times etc...I know this because I traced the function that runs when the URLLoader is completed (xmlLoader.addEventListener (Event.COMPLETE, xmlLoaded); )

This poses serious problems for me because each time this happens, the loader adds more and more children to the sprite I am loading the data (a simple XML List) and I cannot manipulate the objects correctly. On top of that I'm sure there is a memory problem.

Anyway, I'm sorry this is such a loaded question, but have you run into a problem like this before and do you have any suggestions? Thank you!

Getting URLLoader To Ignore
Is there a way to get the URLLoader object to ignor
in a text file? I want to use a text file as a configuration file...something like this...

gamename=gameone&gamelevel=2

this works but I have lots of variables and want to format my text file with a variable on its own line like this...

gamename=gameone&
gamelevel=2

The problem is URLloader doesn't know how to handle the new line.
is there a way around this???
Thanks
T

URLLoader Timeout
Is there anyway to set the timeout of a request with URLLoader?

I want to test a connection to a server but if it takes longer than 10seconds I want it to timeout the request. Is this possible?

Urlloader Database Help
I'm trying to have my swf connect to a database and check to see if the username and password is correct. If so then let them see the rest of the swf. I am using AMFPHP to connect to the database. I cannot figure out how to get my u.text and p.text from my textfields into the php and back again to verify.


ActionScript Code:
var gw:NetConnection = new NetConnection();
gw.connect("http://localhost/amfphp/gateway.php");

var res:Responder = new Responder(onResult, onFault);

function onResult(responds:Object):void
{
    // parse the ArrayCollection
    var t:Array = responds.serverInfo.initialData;
    for(var i:uint=0; i<t.length; i++)
    {
        trace(t[i][0]);
    }
}

function onFault(responds:Object):void
{
    for(var i in responds)
    {
        trace(responds[i]);
    }
}

gw.call("password.getTutorials", res);

lb.addEventListener(MouseEvent.CLICK, doButton);

var vars:URLVariables = new URLVariables();
     
      function doButton(anEvent:MouseEvent):void
      {
         var myData:URLRequest = new URLRequest("amfphp/services/password.php");
         myData.method = URLRequestMethod.POST;
         
         
         
         vars.username = u.text;
         myData.data = vars;
         var loader:URLLoader = new URLLoader();
         loader.dataFormat = URLLoaderDataFormat.TEXT;
         //loader.dataFormat = URLLoaderDataFormat.VARIABLES;
         loader.addEventListener(Event.COMPLETE, doComplete);
         loader.load(myData);
      }
     
      function doComplete(anEvent:Event):void
      {
        trace( "POST Complete");
        //trace( "POST Complete" + anEvent.target.data.username);
      }

My php:

PHP Code:



<?php

class password
{    
    public function __construct()
    {
        mysql_connect("localhost", "root", "root");
        mysql_select_db("news");
    }

    /**
     * Retrieves tutorial data
     * @returns title, description, and url
     */
    function getTutorials()
    {
$username = $_POST['username'];

        return mysql_query("SELECT username,password FROM login WHERE username = '$username' LIMIT 1");


    }
}

?>




If I replace '$username' in the query statement with a hardcoded value that is in my database then I can see the result in the AMFPHP browser so I know the database is working fine.

Seems like every forum has my code and it works. I cannot get it to work. Why?

URLLoader And 201,404 And 409 Errors
Hi all,

I'm using AS3 to talk with a server. I have to use a specific player which is running exactly as the one in Flash CS3 I use :
- when HTTP status == 200 : URLLoader.data is filled
- when HTTP status != 200 : nothing in URLLoader.data (this is working in a web browser)

How can i get the datas if the status equals 201 (which is a correct status), or with a 404 ?

Please give me some clues, even weird ones

keyz

Adding Img From XML Using URLLoader
I am loading my XML in fine and I can get the path of the image. I am having a problem adding the image to the Display list once its done. Can someone help me figure this out. I have a movieclip in my library with linkage CourseClip. Once my XML loads and create a new CourseClip, add the text to the text field inside and then create a loader. I want the image to load into

cc.thumb

Thats my instance name. So essentially it would be __holder["thumb"].addChild(__loader);

but that isnt working. Any ideas?

ActionScript Code:
package com.dop
{
    import flash.display.MovieClip;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.xml.*;
    import flash.events.*;
    public class VTODGrid extends MovieClip
    {

        private var __holder:MovieClip;
        private var __loader:URLLoader;
        private var __xml:XML;
        private var __xmlList:XMLList;
        private var __xmlData:Array;
        private var cc:CourseClip;

        public function VTODGrid(holder:MovieClip,xml:String)
        {
            __holder = holder;
            __loader = new URLLoader();
            __loader.load(new URLRequest(xml));
            __loader.addEventListener(Event.COMPLETE, loadXML);
        }
        private function loadXML(e:Event):void
        {
            __xml = new XML(__loader.data);
            __xmlList = new XMLList(__xml.item);
            var nbrColumns = 4;
            var leftMargin = 0;
            var topMargin = 0;
            var cellWidth = 150;
            var cellHeight = 100;
            for (var i:int = 0; i < __xmlList.length(); i++)
            {
                var cellX = i % nbrColumns;
                var cellY = Math.floor(i / nbrColumns);
                cc = new CourseClip();
                cc.x = leftMargin + cellX * cellWidth;
                cc.y = topMargin + cellY * cellHeight;
                cc["txt"].text = __xmlList[i].@title;
                __loader = new URLLoader();
                __loader.load(new URLRequest(__xmlList[i].@thumb));
                __loader.addEventListener(Event.COMPLETE, loadImage);
                __holder.addChild(cc);
            }
        }
        private function loadImage(e:Event):void
        {
            trace(e.currentTarget);
        }
    }
}

URLLoader And UTF-8 Encoded PHP
This is really frustrating. I have a URLLoader that gets some data (in valid XML format) from a PHP file. Then i do something like:

ActionScript Code:
var xmlData:XML = new XML(e.target.data);
on the Event.Complete of the URLLoader.

Now the problem:
When the PHP file is in ANSI encoding (saved as "ANSI" with notepad for example), the above code works fine!
When the PHP file is saved in UTF-8 encoding (the code inside remains the same of course!) the above line of code throws an error. Not well-formed root element or something...

I had to go with saving it as ANSI since time is pressing me, but i'd like to know why that happens or if there is a way to fix it.

Thanks!

URLLoader Progress?
I know you can track the progress of URLLoader receiving variables, but has anyone found a way to track the progress of it sending variables?

URLLoader Synchronously?
When I call URLloader in my code, it keeps running through the code without waiting for a response back.(asynchronously)

How can I do this so it waits until it completes to continue on through the code? (synchronously)

Thanks!

Facebook AS3 URLLoader
hi
I'm trying to create just another facebook drawing application for witch I use fb:swf on canvas. When the user is done drawing, it is supossed to send the art as a biteArray via http_raw_post_data to a PHP file witch safe it as a JPG file on my server.

When tested on my server everything works great. But when tested inside facebook it is like my URLLoader never gets done. ¿Do you know what is going on?

Here is my AS:

public function done() {
variables.sendresponse = "Saving draw";
this.msgBox.text = variables.sendresponse;

var myBitmapData:BitmapData = new BitmapData(canvas.width, canvas.height);
myBitmapData.draw(canvas);

var jpgEncoder:JPGEncoder = new JPGEncoder(30);
var jpgStream:ByteArray = jpgEncoder.encode(myBitmapData);
var header:URLRequestHeader = new URLRequestHeader("Content-type", "application/octet-stream");

var jpgURLRequest:URLRequest = new URLRequest("jpg_encoder_download.php?name=" + (new Date()).getTime() + ".jpg");
jpgURLRequest.requestHeaders.push(header);
jpgURLRequest.method = URLRequestMethod.POST;
jpgURLRequest.data = jpgStream;

var jpgURLLoader:URLLoader = new URLLoader();
jpgURLLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
jpgURLLoader.addEventListener( Event.COMPLETE, sendComplete );
jpgURLLoader.addEventListener( IOErrorEvent.IO_ERROR, sendIOError );
jpgURLLoader.load( jpgURLRequest );

}


And here is my PHP

<?php
if ( isset ( $GLOBALS["HTTP_RAW_POST_DATA"] )) {
$im = $GLOBALS["HTTP_RAW_POST_DATA"];
$filename = "drawings/".$_GET['name'];
touch($filename); // Create blank file
chmod($filename,0777);
$fp = fopen($filename,"wb");
fwrite($fp,$im);
fclose($fp);
} else echo 'Error.';
?>


Here is my app on facebook (a work in progress)
http://apps.facebook.com/eatbookyouface/


And here is my app on my server
http://chiste.hostsnake.com/chisteSimpleDrawApp.html

I Think A Problem With The URLLoader
I'm making a site and on that site you should be able to see some coördinates on a map.
but you won't be looking to the whole time to the same coördinates.

this is what I have:

var loader1991:URLLoader ;

function laadCoordinaten (evt:Event):void{
loader1991 = new URLLoader ();
var request1991:URLRequest = new URLRequest ("coordinaten/"+ "1991 " + fotoNaam.text + ".txt");
loader1991.load(request1991);
loader1991.addEventListener(Event.COMPLETE, klaar1991);

function klaar1991 (evt:Event):void{
var data1991:Array = loader1991.data.split("&");
for(var i:int = 0; i < data1991.length-1;i++){
var coordinaten1991:Array = data1991.split(",");
aLengte1991.push(Number(coordinaten1991[0]));
aBreedte1991.push(Number(coordinaten1991[1]));

--- another function that is triggered ----

grid1991.graphics.drawRect(0,0,600,1000);
kaart.addChild(grid1991);

for(var i:int; i < aLengte1991.length; i++){
var newX1991:Number = (aLengte1991 - lengteStart)* lengteSchaal;
var newY1991:Number = (aBreedte1991 - breedteStart) * breedteSchaal;
var newPoint1991:Sprite = new Sprite ();
newPoint1991.graphics.lineStyle(2,0xFF0000)
newPoint1991.graphics.drawCircle(newX1991,newY1991,4);
grid1991.addChild(newPoint1991);

I only put some lines because the whole thing is 1486 lines. I think the problem is in this lines.
some variables are missing, but if the name starts whit an "a" it's an array and if it doesn't start whit a "a" it's a number.

the problem is that when I go to the first map everything works, but when I change the map I want to see he will give the same coördinates.

URLLoader And Variables HELP
Hey i am trying to get this working and i know i can use string parsers to get what i need but that will become too messy for what i want. This is my following AS3 code:


var request:URLRequest = new URLRequest("http://mywebsite.yadayada/flash_getproducts.aspx?Id=11");
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener (Event.COMPLETE, completeHandler);
try {
loader.load (request);
} catch (error:Error) {
trace("Unable to load requested document.");
}

function completeHandler(event:Event):void
{
var loader:URLLoader = URLLoader(event.target);

trace (loader.data);
}

Now as soon as i run my movie i get the following error message and it never even makes it to completeHandler event:

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

I need help for this urgently

[Q] URLLoader Not Working ?
Hi all
I am trying to load an image from the web.


Code:

var vUrl:String = "http://www.abc.com/images1.JPG";
var req:URLRequest = new URLRequest(vUrl);
var loader:URLLoader = new URLLoader();
loader.load(req);
addChild(loader);
However, it returns the following error ...
1067: Implicit coercion of a value of type flash.net:URLLoader to an unrelated type flash.displayisplayObject.

could any body help ??
Thanks

URLloader Problem {please Help}
:::::::RESOLVED::::::::::::::::::::::

First off heres the fla.
http://gfxcomplex.com/labs/kulerheader.zip

I just posted an update look at next comment:

here's the error:

Code:
TypeError: Error #1010: A term is undefined and has no properties.
at header_fla::MainTimeline/xmlLoaded()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()
-thanks

URLLoader Cache
I use URLLoader to sends posts to a php script, and then I display the result. Problem is, the php reply is cached, and everytime I run the program again, I always get the same result as the first time. The only way to make flash actually make new request is to restart the IDE. Is this an IDE bug? A setting I've overlooked? A programming error?

URLLoader Question.
I built a sequential loader which works fine and now I am trying to add in a loadBar so you can see the progress for each image. Everything runs fine except the loadBar only shows the progress for the first image then is removed but it won't show again. When I put a trace statement in the onImageOpen method it will trace out something for each image. So I know it is being called correctly I just can't figure out how to add the loadBar when the loading begins, remove the loadBar when the loading is done and continue that process for each image.

Here is a quick glimpse of my class

Code:
_thumbLoader = new Loader();
_thumbLoader.contentLoaderInfo.addEventListener( Event.OPEN, onImageOpen );
_thumbLoader.contentLoaderInfo.addEventListener( ProgressEvent.PROGRESS, onImageProgress );

// Here is the open method which is where I create my shape and add to the display list
private function onImageOpen( event:Event ):void
{
loadBar = new Shape();
loadBar.graphics.beginFill( Math.random() * 0x910303 );
loadBar.graphics.drawRect( 0.0, 0.0, 100.0, 100.0 );
loadBar.graphics.endFill();
loadBar.width = 0.0;

addChild( loadBar );
}

// Here is my ProgressEvent method which shows the progress and removes the loaderBar once it hits 1.0
private function onImageProgress( event:ProgressEvent ):void
{
var target:LoaderInfo = LoaderInfo( event.currentTarget );

var percent:Number = ( 1.0 / event.bytesTotal ) * event.bytesLoaded;

if( percent == 1.0 )
{
target.removeEventListener( ProgressEvent.PROGRESS, onImageProgress );

removeChild( loadBar );
}
else
{
loadBar.width = stage.stageWidth * percent;
//loadBar.height = stage.stageHeight;
}
}

URLLoader Problems
Hopefully this is a relatively easy one! I'm using the following code to obtain some variables from a remote page:

Code:
public function URLLoaderDataFormatExample(event:MouseEvent)
{
var request:URLRequest = new URLRequest("http://www.<mydomain>/sample.txt");
var variables:URLLoader = new URLLoader();
variables.dataFormat = URLLoaderDataFormat.VARIABLES;
variables.addEventListener(Event.COMPLETE, completeHandler);
try
{
variables.load(request);
}
catch (error:Error)
{
trace("Unable to load URL: " + error);
}
}
private function completeHandler(ev:Event){
var loader = URLLoader(ev.target);
trace(loader.data.st);
}
This works fine, until I change sample.txt to sample.php and use echo to print out my name variable pair. I get the following error with the PHP file:

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
at Error$/throwError()
at flash.net::URLVariables/decode()
at flash.net::URLVariables$iinit()
at flash.net::URLLoader/flash.net:URLLoader::onComplete()

My PHP code is simply: echo "?st=OK";

What's going wrong?

Cheers
Kevin

URLLoader Repeating Itself
Hi there,

I'm pretty new to Flash and AS3 but I've managed to figure most of my problems out with the help of books and the net...I'm having a problem with a URLLoader and I just cannot work it out.

The problem is that when I click on my buttons that start the function containing the URLLoader, the Loader loads the data repeatedly, as many times as I have clicked on a button. So, for example, if I click a button it will load the data twice. Click again and it loads it three times, again and it loads it four times etc...I know this because I traced the function that runs when the URLLoader is completed (xmlLoader.addEventListener (Event.COMPLETE, xmlLoaded); )

This poses serious problems for me because each time this happens, the loader adds more and more children to the sprite I am loading the data (a simple XML List) and I cannot manipulate the objects correctly. On top of that I'm sure there is a memory problem.

Anyway, I'm sorry this is such a loaded question, but have you run into a problem like this before and do you have any suggestions? Thank you!

Regarding URLLoader And The & As A String
So you separate variables using the &, however if I want this as part of the string how would I do it?

Say I am sending


Code:
ice_cream=Tom & Jerry&size=large
If I were to encode all the special characters, what would the flash function to decode it be? Or should I just replace the & with a special key and then recode it when it gets passed into the flash file?

Thanks.

[Q] URLLoader Not Working ?
Hi all,
I am trying to update the database via a SWF file in every 10 second

I am using the URLLoader to load the file http://127.0.0.1/plus_one.php
This PHP file can do the increment in database
(http://127.0.0.1/plus_one.php works well and fine if open in a browser)


If put it into the AS3 ... It works fine for the frist 10 seconds...
but after the next 20 seconds, there is no more increment to the database ...

How ever ... if i change the 127.0.0.1 to localhost..
It works again for the first 10 seconds, but not working after the next 20 seconds ...


Is there any people can help ?



Code:


var vPath:String = "http://127.0.0.1/plus_one.php";
var ldr:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest(vPath);
var t:Timer = new Timer(10000);
ldr.addEventListener(Event.OPEN, onOpen);
ldr.addEventListener(HTTPStatusEvent.HTTP_STATUS, onHttpStatus);
ldr.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onSecurityError);
ldr.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
ldr.addEventListener(Event.COMPLETE, onComplete);
t.addEventListener(TimerEvent.TIMER, addOne);
t.start();

function addOne(e:TimerEvent):void {
ldr.load(req);
}
function onOpen(e:Event):void {
trace("OK");
}
function onHttpStatus(e:HTTPStatusEvent):void {
trace("HTTP Status: " + e.status);
}
function onSecurityError(e:SecurityErrorEvent):void {
trace("Security Error: " + e.text);
}
function onIOError(e:IOErrorEvent):void {
trace("IO Error: " +e.text);
}
function onComplete(e:Event):void {
trace("Complete: ");
}

URLLoader And BytesTotal
Hi guys,

I'm registering for the ProgressEvent.PROGRESS event on a URLLoader object. The URLLoader object is loading a fairly large xml file (50KB).

It appears that the bytesTotal (and perhaps bytesLoaded) value is incorrect. It seems fine locally but as soon as I put the swf on a web server it's wrong.

I've attached my source .as file and some trace output. I'd really appreciate it if somebody took a quick look. Thanks!

URLLoader Class
Hi,

I'm not new to Flash, but am new to AS 3. Help is appreciated.

I've got two buttons (button_one and button_two) both through which I am attempting to load external swfs into main fla. My issue is that when say button_one has already loaded its swf in then when I select button_two I want button_one's content to unload (and vice versa).

Here is the code that I tried but I am getting a compiler error message.

button_one.addEventListener(MouseEvent.CLICK, justin);
function justin (e:MouseEvent):void {
var my_loaderJustin:Loader = new Loader();
my_loaderJustin.load(new URLRequest("justin.swf"));
addChild(my_loaderJustin);
}

button_two.addEventListener(MouseEvent.CLICK, ed);
function ed (e:MouseEvent):void {
var my_loaderEd:Loader = new Loader();
my_loaderEd.load(new URLRequest("ed.swf"));
addChild(my_loaderEd);
}

I thought that unload would work. And maybe I am just not using unload correctly. For example in the button_two code I tried adding this line to the button_two code (to unload the Justin content of button_one):

my_loaderJustin.unload();

and the error message I get is: Access of undefined property'

Hoping that it might (sort of) be like AS 2 where loading in a second content into the loader (as loadMovie had done in AS 2) would automatically unload the first content. But this does not work as both contents are on the stage at the same time (just changing the stacking order of the two).

So how to unload the swfs is the question. Thank you.

[AS3] URLLoader Data?
I built a DataLoader class which handles URLLoader and all its events. I did this so that I can reuse everything in case I wanted to load a .txt file or another XML file. When using URLLoader what type of object is data?

I am asking because I am passing an event and I would like to strong type "data" instead of using "*". I still need to add in the rest of the functionality but you can get the idea


ActionScript Code:
public function DataLoader( url:String ):void
        {
            _loader = new URLLoader();
            _loader.load( new URLRequest( url ) );
            _loader.addEventListener( Event.COMPLETE, completeHandler );
        }
       
        private function completeHandler( event:Event ):void
        {
            _loader.removeEventListener( Event.COMPLETE, completeHandler );
           
            dispatchCustomEvent( _loader.data );
        }
       
       
        private function dispatchCustomEvent( data:* ):void
        {
            var t:String = DataLoaderEvent.ON_LOAD_COMPLETE;
            var e:dataLoaderEvent = new DataLoaderEvent( t, data );
 
            dispatchEvent( e );
        }

Problem Using URLLoader
Hi Guys

I am trying to load an external text file but keep receiving the following error message:

Code:

TypeError: Error #2007: Parameter url must be non-null.
   at flash.net::URLStream/load()
   at flash.net::URLLoader/load()
   at lee.dataload::TextLoader()

this is the code i'm using, i'm very new to actionscript so it's probably loaded with errors:

Code:

package lee.dataload
{
   import flash.display.*;
   import fl.transitions.*;
   import fl.transitions.easing.*;
   import flash.text.*;
   import flash.net.*;
   import flash.events.*;

   public class TextLoader extends MovieClip {
      var txtField:TextField = new TextField();
      var externalReq:URLRequest=new URLRequest(textData);
      var externalLoad:URLLoader = new URLLoader();
      var textData:String;

      public function TextLoader(txt:String) {
         textData = txt;
         txtField.x=10;
         txtField.y=50;
         txtField.textColor=0x000099;
         addChild(txtField);
         externalLoad.load(externalReq);
         externalLoad.addEventListener(Event.COMPLETE, textReady);
      }

      function textReady(event:Event):void {
         txtField.htmlText = event.target.data;
      }
   }
}

Thanks for your help

Odd URLLoader Problem
I have the worst kind of error, one that only shows up on two machines right now. We're testing an application that's supposed to go live tomorrow and found an oddity on two machines.

We have a flash application that makes a url request, gets back xml then makes links with the data it gets back. This works fine on almost all machines except for two. On these two, the first request works just fine. However, if you try clicking any link after the first, it appears that the url request is never made. We put diagnostics in the php file that's called. When the urls are created in the flash, sure enough the php file writes to the log. When the urls don't get created, the php file which spits out the xml doesn't write to the log, which shows that the call isn't reaching the php file.

The computers that don't work are running Windows XP and IE 6 and others are running that and have no problem. And again, even the ones that don't work work the first time, then die (the flash request doesn't happen) when trying to click another link.

Here's the code:


Code:


var menuLoader:URLLoader = new URLLoader();
var menuRequest:URLRequest = new URLRequest(url);
menuLoader.dataFormat = URLLoaderDataFormat.TEXT;
menuLoader.addEventListener(Event.COMPLETE, getNavItemsList);
menuLoader.load(menuRequest);

private function getNavItemsList(e:Event):void {
//build the links



Has anyone even heard of a problem like this?

URLLoader Response Timeout
I was asked to give longer waiting time (30sec) for URLLoader response. Is that possible to change in some way (not Socket).

Thanks,
George

Error 1046 URLLoader
i have this code in my main program at the begining
and it produces the errors below but it works in isolation what can the problem be?

code

var myTextLoader:URLLoader = new URLLoader ();
myTextLoader.addEventListener(Event.COMPLETE, onLoaded);

function onLoaded(e:Event):void {
trace(e.target.data);
}

myTextLoader.load(new URLRequest("mytxt.txt"));

Errors

1046: Type was not found or was not a compile-time constant: URLLoader.
1180: Call to a possibly undefined method URLLoader.
1180: Call to a possibly undefined method URLRequest.
thnaks andrew

Cs4 URLLoader Reset? Xml Question
I am very new to flash and trying to learn to read and parse XML files.

it seems to work really elegantly except I have an issue with what seems to be caching that makes it hard to check my work.


Code:
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);

xmlLoader.load(new URLRequest("http://www.somedomain.com/flashtest/list.xml"));

function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
trace(xmlData);
}


this works fine to load and trace the list.xml file on my server, however, if i edit list.xml, and then hit ctrl-enter to rerun the swf, the changes are not reflected in the program. in fact, i can delete list.xml off the server and it keeps tracing the the file that was originally loaded.

i have to actually close out my .fla file and reopen it to get it to update.

i am sure there is something silly i am missing but i have been messing with it for hours.

thanks for any help

URLLoader Send Progress
Im using a URLLoader to send a large request that returns a true or false string.

Is there any way I can display the progress of the send rather than the load?

URLLoader Returns Same Data?
I have a Flex2 app that loads JSON data every 2s from a web service. On my laptop it works every time... On my colleages machines it retrieves the first set of data then continues to return the same data unless refresh is hit on the browser. (even if they build the code in flexbuilder it does this). No errors are thrown by the loader, it just returns the same data ?
My code is the same as in the examples... note it is calling a MS aspx service to get the data with one paramater, this call is the same every time, the server generates new data each time however.
I notice that I can get the responses stay constant (even if I hit refresh) I use change the case for the service URI or paramater.. which is wierd, It should not make a differerence...
I also tried uninstalling all my flash players and reloaded just the release no difference.
Any ideas on what may be causing this anomoly much appreciated.

Urlloader Complete Data
I am just wonder about data property in urlloader. Since data property returns * datatype is there any advantage in converting data to String before asigning it to variable?


ActionScript Code:
...
var data:String;
private function onComplete(evt:Event):void
    {
        _data = evt.target.data as String;
    }

URLLoader Only Working Flash IDE
Hi there,

I have a script that is working fine in the IDE. A simple URLLoader and URLRequest that is POSTing some data to and ASP page and getting the data that it returns.

I don't have the script on me, its just your standard get up using these two classes and the thing is that it works fine the Flash IDE, however when I run it on my webserver it doesn't work. The ASP page is on another domain and I have my IP address in the crossdomain.xml file on the root of that server.

Anyone ever have a similar experience to this?

Cheers,

Nathan

Get URLLoader Url In LoadComplete Handler
Hi guys.
Im having some problems getting the requested url of an URLLoader object.
I am loading several xml files, each with different parameter and in the loadComplete handler I want to get those parameters again.
Example:


Code:
private function doLoad(event:Event):void {
for (var i:int = 0; i<someobject.length(); i++) {
var request:URLRequest = new URLRequest('http://www.bla.com/getSomething?id='+i);
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, loadComplete);
loader.load(request);
}
}

private function loadComplete(event:Event):void {
var someXML:XML = XML(event.target.data);
// --------------------- how to get the requested url from here?
}
Anyone got an idea?

URLLoader RSS Encoding Greek
Hello,
I am trying to get a RSS feed using the URLLoader class. The page has Greek charachters and when I just trace the URLLoader data I see things like:

<?xml version="1.0" encoding="iso-8859-7"?>
<rss version="2.0">
<channel>
<title>H KAÈHMEPINH : ÐOËITIKH</title>
<item>
<title>×éëéÜäåò åêêñåìåßò õðïèÝóåéò óôï ÓôÅ</title>
<link>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</link>
<pubDate>2008-1-9T09:05:06Z</pubDate>
<category>POLITICS</category>
<guid>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</guid>
<description><![CDATA[Óå ìåãÜëç ðëçãÞ ôïõ óõóôÞìáôïò áðïíïìÞò äéêáéïóýíçò óôç ÷þñá áíáäåéêíýïíôáé ïé ôñáãéêÝò êáèõóôåñÞóåéò êáôÜ ôçí Ýêäïóç ôùí äéêáóôéêþí áðïöÜóåùí, ðïõ ðëÝïí áããßæïõí êáé ôï Óõìâïýëéï ôçò Åðéêñáôåßáò. Óýìöùíá ìå ôïí ðñüåäñï ôïõ áíþôáôïõ áêõñùôéêïý äéêáóôçñßïõ... ...]]></description>
</item>

While the actual code from the source of the page I am trying to get is :

<?xml version="1.0" encoding="iso-8859-7"?>
<rss version="2.0">
<channel>
<title>H KAΘHMEPINH : ΠOΛITIKH</title>

<item>
<title>Χιλιάδες εκκρεμείς υποθέσεις στο ΣτΕ</title>
<link>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</link>
<pubDate>2008-1-9T09:05:06Z</pubDate>

<category>POLITICS</category>
<guid>http://news.kathimerini.gr/4dcgi/_w_articles_politics_0_09/01/2008_254817</guid>
<description><![CDATA[Σε μεγάλη πληγή του συστήματος απονομής δικαιοσύνης στη χώρα αναδεικνύονται οι τραγικές καθυστερήσεις κατά την έκδοση των δικαστικών αποφάσεων, που πλέον αγγίζουν και το Συμβούλιο της Επικρατείας. Σύμφωνα με τον πρόεδρο του ανώτατου ακυρωτικού δικαστηρίου... ...]]></description>
</item>


How can I encode the data so to look proper?

My code is:

import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;

var url:String = "http://wk.kathimerini.gr/xml_files/politics.xml" ;
var rssXMLURL:URLRequest = new URLRequest(url);
var myLoader = new URLLoader();
myLoader.dataFormat = URLLoaderDataFormat.TEXT;
myLoader.addEventListener(Event.COMPLETE, xmlLoaded);
myLoader.load(rssXMLURL);

function xmlLoaded(event:Event):void
{
trace(myLoader.data);

}


thanks,
Panos

Putting The URLLoader On Stage?
Say for example that i have code as following. Now obviously in flash you need to drag the component into the library to be able to see the specified image using URLLoader however there is no URL loader component in flash (not that i know of!). Hence i am abit confused as to how to display an image on STAGE once its been retrieved using URLLoader; knowing that you cant just addChild(URLLoader).


Code:
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.display.*;
import flash.display.Loader;

var myLoader:URLLoader = new URLLoader();
var myRequest:URLRequest = new URLRequest("http://www.dureforsog.com/images/wallpaper/knee2_large.jpg" );
myLoader.addEventListener(Event.CHANGE,test);
myLoader.load(myRequest);


function test(ev:Event):void
{
trace(ev);
}

Evaling XML From URLLoader Or String
Is there anyway to eval curly-braced variables in XML that has been loaded from a URL (or from a string for that matter)? For example:

var msg:String="Hello world";
var xml:XML = <root>{msg}</root>;
trace( xml.toXMLString() );

prints out: <root>Hello world</root>;

but if I do:
var msg:String="Hello world";
var xmlStr:String = "<root>{msg}</root>";
var xml:XML = new XML( xmlStr );
trace( xml.toXMLString() );

prints out: <root>{msg}</root>

I'd like the two print outs to be identical. Is this possible?

URLLoader Localhost Data
I am working on an intranet web-based application.

All of the computers in our network have a file data.txt in the root - http://localhost/data.txt. I want to read the contents of the file with URLLoader, but the problem is the client computers are on one domain and the server hosting this application is on other and I am running into cross-domain policy issues.

I cannot ask all the client computers to create the crossdomain.xml file in their root. Is there any other way to read the data in the file?

And I was wondering, how the security check occurs in the swf file. The swf is being executed on the client's local computer and my understanding is that any call to the localhost should be handled without re-routing outside the box and my call should execute successfully.

Any help over this will be greatly appreciated. Thanks.

UrlLoader: IOError For Correct Url
Hello.
I am using URLLoader to load data from external domain(with open crossdomain.xml). I am using it's REST api. All is going fine if there is no server error in response. But if there is server error - i just receive :
Error #2032: Stream Error. URL:
I don't need this. I want to parse error response(it is in xml). Anybody know why this can happen?

Thanks.Aleksey

A Really Simple Question About URLLoader
In the document class, I used the following statements in an attempt to read data from mydata.txt saved in the same folder. But the trace shows "undefined". Anyone has a quick solution to this? Thanks!

var request:URLRequest = new URLRequest("mydata.txt");
var loader:URLLoader = new URLLoader();
loader.load(request);
trace(loader.data)

URLLoader In Class > Access
hello!

i have a class where i fetch some XML data from an external file.
on the main stage, i instantiate the class and call a function to do the external file loading.

my problem now is, that the main stage doesnt know when the loading process is finished. inside the class i do it with the COMPLETE event but i dint know how to wait for that on the main stage so i thought i might return the data in th COMPLETE handler. however, i dont really find the right sntax for that.

can somebody help me with this problem?

here is my code
-------------------------------------------------
package
{
import flash.events.*;
import flash.net.*;


public class Lang
{

private varlangFile = this.loaderInfo.parameters.lang;

public function getVars(folderRoot:String):void {
var xmlURLLoader:URLLoader = new URLLoader();
var xmlURLRequest:URLRequest = new URLRequest(folderRoot + "lang/" + langFile);
xmlURLLoader.load(xmlURLRequest);
xmlURLLoader.addEventListener(Event.COMPLETE , dataLoaded );

function dataLoaded(event:Event):void {
var langVars:XML = new XML (xmlURLLoader.data);
return langVars;
}
}

}
}

Can't Send URLVariables With URLLoader...
I have seen this problem all over, but I cannot seem to find a solution to it. Funny thing is that it was working earlier, but I must have changed some code and now it doesn't work any more. Drat! Here the code:


ActionScript Code:
var loader:URLLoader = new URLLoader();
var variables:URLVariables = new URLVariables();
var request:URLRequest = new URLRequest();

loader.dataFormat = URLLoaderDataFormat.VARIABLES;
request.url = "http://www.mysite.com/process.php";
request.method = URLRequestMethod.POST;
variables.title = "a title 1";
variables.post = "a post 1";
variables.switcher = "0";
request.data = variables;

loader.load(request);

I know for a fact my PHP code works properly, so there's no need to go into that. I get the error: #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs. I have checked numerous websites and the documentation and examples for the request, variables, and loader objects and from all that am pretty sure my code is correct. The one thing different in the documentation that I saw was how they declared the variables for the URLVariables object. In the "working with external data" page (the last example code they have) they do it like this: var variables:URLVariables = new URLVariables("name=Franklin"); but I don't know how you'd do more than one variable if you did it like that and I'd like to know how to do it the way I'm doing it above anyway. I know it works the way I have it because like I said, it worked before... somehow. The difficult part is that decode() is called automatically, so I don't know which line of code is wrong.

I have also tried messing around with decode() to try to manually convert strings into URL crap, but that doesn't seem to solve the problem.

URLLoader Constructor Problem?
ok, this seems to work if I paste it into a frame as an action, but doesnt work if use it in an AS3 file:

var myLoader:URLLoader = new URLLoader();

any attempt to use myLoader (from inside an AS3 file) gives me error 1120: Access of undefined property myLoader


I know there's a logical explanation, but no sign of it yet. thanks in advance for clues for the clueless!

Copyright © 2005-08 www.BigResource.com, All rights reserved