Hello I have been trying to split my map off to a seperate .as file. I have several reasons for doing it, but the problem is I can not get the images to load.
this is my Map1.as (after the imports are done)
public class Map1 extends Object3D
{
//load skins for planets
[embed(source="sunmap.jpg")]
private var sunskin:BitmapFileMaterial;
[embed(source="mars_1k_color.jpg")]
private var marsskin:BitmapFileMaterial;
[embed(source="venusmap.jpg")]
private var venusskin:BitmapFileMaterial;
[embed(source="earthmap1k.jpg")]
private var earthskin:BitmapFileMaterial;
[embed(source="mercurymap.jpg")]
private var mercuryskin:BitmapFileMaterial;
[embed(source="jupitermap.jpg")]
private var jupiterskin:BitmapFileMaterial;
[embed(source="saturnmap.jpg")]
private var saturnskin:BitmapFileMaterial;
[embed(source="uranusmap.jpg")]
private var uranusskin:BitmapFileMaterial;
[embed(source="neptunemap.jpg")]
private var neptuneskin:BitmapFileMaterial;
[embed(source="plutomap1k.jpg")]
private var plutoskin:BitmapFileMaterial;
//load moon texture
[embed(source="moonmap1k.jpg")]
private var moonskin:BitmapFileMaterial;
private var sun:Sphere;
private var mercury:Sphere;
private var venus:Sphere;
private var earth:Sphere;
private var mars:Sphere;
private var jupiter:Sphere;
private var saturn:Sphere;
private var uranus:Sphere;
private var neptune:Sphere;
private var mapview:View3D;
public function Map1()
{
mapview = new View3D();
sunskin = new BitmapFileMaterial("sunmap.jpg");
sun = new Sphere({material:sunskin, radius:2000, segmentsH:16, segmentsW:16});
sun.bothsides = true;
mercuryskin = new BitmapFileMaterial("mercurymap.jpg");
mercury = new Sphere({material:mercuryskin, radius:240, segmentsH:16, segmentsW:16, z:5800});
venusskin = new BitmapFileMaterial("venusmap.jpg");
venus = new Sphere({material:venusskin, radius:600, segmentsH:16, segmentsW:16, z:18000});
//make star skybox
// create a temporary container-sprite to add stars into
var mc:Sprite = new Sprite();
mc.graphics.beginFill(0);
mc.graphics.drawRect(0,0,2048,2048);
mc.graphics.endFill();
// add 2000 star-sprites to the container
var s:Sprite, r:Number;
for( var i:uint=0; i<2000; i++ )
{
r = Math.random()*Math.random();
s = new Sprite();
s.graphics.beginFill(0xFFFFFF,0.9);
s.graphics.drawCircle(0,0,r);
s.graphics.endFill();
s.x = r + (mc.width - 2*r)*Math.random();
s.y = r + (mc.height - 2*r)*Math.random();
mc.addChild(s);
}
// render the container-sprite to a bitmap
var bmd:BitmapData = new BitmapData(mc.width, mc.height, false, 0);
bmd.draw(mc);
// create a 2x2 tiled material from the bitmap
var mat:TransformBitmapMaterial = new TransformBitmapMaterial(bmd, {
smooth: true, precision:0,
repeat: true, scaleX: 0.5, scaleY: 0.5 });
// create a skybox using that material on all 6 sides
var box:Skybox = new Skybox( mat,mat,mat,mat,mat,mat );
}
}
}
and this is the Game.as (the one that runs the game)
public class Game extends Sprite
{
private var map:Map1;
private var view:View3D;
private var cam:Camera3D;
public function Game()
{
view = new View3D();
cam = new Camera3D();
addChild(view);
view.camera = cam;
cam.z = 10000;
map = new Map1();
view.scene.addChild(map);
view.render();
}
}
}
what am I missing here?
I need to remove the embed lines, the format I am using now does not require them. I use away3d for my engine and BitmapFileMaterial imports directly from the url and requires no embed. So please do not tell me I am using embed wrong by not having a variable:Class. I know that part of the code is good I have tested it in a single file and it works.