- Home /
Flash WWW.texture problem
I need to apply texture files from an online location (same server as the swf) to objects in the scene, but I've had no luck at all with WWW class. Here is the code I'm testing:
#pragma strict
var url = "http://myserver.com/texture.jpg";
var plane : GameObject;
plane = GameObject.Find( "Plane" );
var www : WWW;
var isDone = "Texture Loading . . .";
function Start ()
{
www = new WWW (url);
}
function OnGUI ()
{
if (!www.isDone)
{
GUI.Label ( Rect (23, 23, 100, 30), isDone );
}
else
{
if (GUI.Button (Rect (10,10, 100, 50), "Apply Texture"))
{
plane.renderer.material.mainTexture = www.texture;
}
}
}
It works in the editor. When I place a test build online, the Apply Texture button has no effect.
Am I doing something wrong? If not, is there a workaround? Thanks.
Answer by Ghisallo · Oct 04, 2012 at 02:46 AM
Solved! Turns out it's my server. I have no idea why I can't load an image from my server, but at least I've narrowed it down. Anybody have any ideas what it might be?
Answer by RalphH · Oct 04, 2012 at 08:20 AM
A guess; your server needs a Flash crossdomain.xml for Flash to be able to access it.
I shall look into it. Interestingly, it had no trouble bringing up images from another server. It's only images on my server it doesn't like. Thanks.