0

This is driving me crazy right now!

var url gets defined longer up.

url = url + ".jpg";
var fileRequest:URLRequest = new URLRequest(url);

That's doesn't work for some reason... the ".jpg" doesnt get added. BUT, if I try to do this:

url = ".jpg" + url;
var fileRequest:URLRequest = new URLRequest(url);

It works, but I don't want the .jpg to be at the begining of the url ofcourse...

user1941346
  • 73
  • 1
  • 1
  • 5
  • 2
    Have you tried tracing `url` and seeing what comes up? It may do it properly but with an overlooked hitch. – puggsoy Jan 19 '13 at 13:20
  • Yes, the variable url is correct. In the first one with url + ".jpg" it just doesn't add .jpg to the end of it. – user1941346 Jan 19 '13 at 13:38
  • 1
    `trace(url,url+".jpg");` – inhan Jan 19 '13 at 14:52
  • The code: url = ".jpg" + url; var fileRequest:URLRequest = new URLRequest(url); completly no sense. As puggsoy say check the value of the url. Maybe you need to use URLVariables and/or UrlHeaders – Azzy Elvul Jan 19 '13 at 13:36
  • Why doesn't it make sense? – user1941346 Jan 19 '13 at 13:37
  • Becouse no matter what is the value of variable "url" the string ".jpg" is not a valud url addres. Check this: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html#URLRequest() – Azzy Elvul Jan 19 '13 at 13:39

2 Answers2

0

Try url += ".jpg"; Or url = String(url)+".jpg";

crooksy88
  • 3,849
  • 1
  • 24
  • 30
0

I've been looking all day for the same problem. Came across this thread on my way through. Found the solution. https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLVariables.html

So I will share to help speed you up.

This definitely works.

var currImage:int = 1;

var urlVariables:URLVariables = new URLVariables("folder=../images/&currImage=1&file=.png");

var url = urlVariables.folder + urlVariables.currImage + urlVariables.file;

 //changes image..
url = urlVariables.folder + 2 + urlVariables.file;

or

url = urlVariables.folder + currImage + urlVariables.file;

You can just remove the second urlVariable ( &currImage=1). I've just shown how it all works.

From here you can manipulate the number variable to load other images.