PDA

View Full Version : Having compile time errors with URL Request


adaykin
07-21-2008, 04:01 PM
Hey, I am trying to upgrade my code to as 3, I have a few compiler errors, I can't figure out how to solve them. Here is my code:


package {
// required for flash file and output display
import flash.display.*;
import flash.events.*;
// required to send/recieve data over AMF
import flash.net.NetConnection;
import flash.net.Responder;

// Flash CS3 Document Class.
public class Main extends MovieClip {
private var gateway:String = "http://spanglerdesign.com/test/360/amfphp/gateway.php";
private var connection:NetConnection;
private var responder:Responder;
private var picLoader = new Loader();
picLoader.load(new URLRequest("art/gal360one.jpg", mainPIC.TEMPlgTARGET));

public function Main() {
// Event listener for mouse over
tmbONE.addEventListener(MouseEvent.MOUSE_OVER, loadOne);

// Event listener for mouse out
tmbONE.addEventListener(MouseEvent.MOUSE_OUT, hideMain);

// Responder to handle data returned from AMFPHP.
responder = new Responder(onResult);
connection = new NetConnection;
dispatchEvent(new Event("NetStatusEvent.NET_STATUS"));

// Gateway.php url for NetConnection
connection.connect(gateway);
}

public function loadOne(e:MouseEvent):void
{
picLoader.load(new URLRequest("art/gal360one.jpg", "mainPIC.lgTARGET"));
with (mainPIC) {
gotoAndPlay("fadeup");
}
var params = 1;
connection.call("DisplayInfo.info", responder, params);
}

public function hideMain(e:MouseEvent):void
{
with (mainPIC) {
gotoAndPlay("fadedown");
}
}

private function onResult(result:Object):void {
textResponse.text = String(result);
}
}
}


The errors the compiler gives are:

Line15: 1120: Access of undefined property picLoader. picLoader.load(new URLRequest("art/gal360one.jpg", mainPIC.TEMPlgTARGET));

Line15: 1180: Call to a possibly undefined method URLRequest. picLoader.load(new URLRequest("art/gal360one.jpg", mainPIC.TEMPlgTARGET));

Line15: 1120: Access of undefined property mainPIC. picLoader.load(new URLRequest("art/gal360one.jpg", mainPIC.TEMPlgTARGET));

Line35: 1180: Call to a possibly undefined method URLRequest. picLoader.load(new URLRequest("art/gal360one.jpg", "mainPIC.lgTARGET"));

senocular
07-21-2008, 04:04 PM
you need to call picLoader.load() inside of Main

adaykin
07-21-2008, 04:27 PM
that fixed my problem with the loader, I still get the errors about the url request, here is the code:

package {
// required for flash file and output display
import flash.display.*;
import flash.events.*;
// required to send/recieve data over AMF
import flash.net.NetConnection;
import flash.net.Responder;

// Flash CS3 Document Class.
public class Main extends MovieClip {
private var gateway:String = "http://spanglerdesign.com/test/360/amfphp/gateway.php";
private var connection:NetConnection;
private var responder:Responder;
private var picLoader = new Loader();


public function Main() {
// Event listener for mouse over
tmbONE.addEventListener(MouseEvent.MOUSE_OVER, loadOne);

// Event listener for mouse out
tmbONE.addEventListener(MouseEvent.MOUSE_OUT, hideMain);

// Responder to handle data returned from AMFPHP.
responder = new Responder(onResult);
connection = new NetConnection;
dispatchEvent(new Event("NetStatusEvent.NET_STATUS"));

// Gateway.php url for NetConnection
connection.connect(gateway);
picLoader.load(new URLRequest("art/gal360one.jpg", mainPIC.TEMPlgTARGET));
}

public function loadOne(e:MouseEvent):void
{
picLoader.load(new URLRequest("art/gal360one.jpg", "mainPIC.lgTARGET"));
with (mainPIC) {
gotoAndPlay("fadeup");
}
var params = 1;
connection.call("DisplayInfo.info", responder, params);
}

public function hideMain(e:MouseEvent):void
{
with (mainPIC) {
gotoAndPlay("fadedown");
}
}

private function onResult(result:Object):void {
textResponse.text = String(result);
}
}
}

lines 31, and 36 are where the errors are at, with the urlrequest

box86rowh
07-21-2008, 04:35 PM
you have to import the urlrequest class at the top

adaykin
07-21-2008, 04:49 PM
Thanks a lot guys for the support. One more question. Is there a way in 3.0 that I can load the picture into a movie clip circle? I know there is in 1.0, but how would I do this with the url request in 3.0?

box86rowh
07-21-2008, 04:54 PM
a circle? like a round mask? not sure what you mean

adaykin
07-21-2008, 04:58 PM
yeah like a round mask.

box86rowh
07-21-2008, 05:19 PM
once you have the image loaded simply apply what you would like to use as a mask using the mask property of the loader

adaykin
07-21-2008, 05:54 PM
Sorry, I'm just learning flash and actionscript, how would I use the mask property of a loader? On my fla document, I already have a circle movie clip where I want the image to go, and the part of the image that will show up, will be what is in the circle, I am trying to load that part. Hope that clears it up.

I also get a warning when I publish saying: WARNING: Actions on button or MovieClip instances are not supported in ActionScript 3.0. All scripts on object instances will be ignored.

I'm not sure what part of the code that's talking about

matbury
07-22-2008, 06:49 PM
I think it means that you've put code directly on a button or MovieClip object. AS 3.0 doesn't allow you to do that.

goysar
09-22-2009, 10:44 AM
I am also getting the same error with URLRequest, i have already import the package.
here is my code:
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
import flash.net.URLRequest;
private var request:URLRequest=new
URLRequest("hhtp://www.google.com");
navigateToURL(request);
]]>
</mx:Script>

I get the error shown at the last line(navigateToURL). Must i import servicemonitor.swc to my project's build path. If so please guide me how to do that.

Thanks in advance!!!