well I instance my .fla with a class test.as so, when I try to declare a var like a XML it launch this error Type was not found or was not a compile-time constant: XML. I dont understand why, if I was loaded xml and its so reall easy but this time i dont know what happen, any idea??
////////////////////////////////////////////
// Project: Flex Builder PDVSA La Estancia
// Date: 11/4/12
// Author: Carlos Blanco
////////////////////////////////////////////
package {
////////////////////////////////////////////
// IMPORTS
////////////////////////////////////////////
//import flash.utils.*;
//import flash.media.*;
import fl.video.*;
import flash.xml.*;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Shape;
import flash.display.Sprite;
import flash.display.StageQuality;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.IOErrorEvent;
import flash.events.MouseEvent;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.system.fscommand;
import flash.text.TextField;
import flash.utils.ByteArray;
import flash.utils.setInterval;
import org.as3kinect.as3kinect;
import org.as3kinect.as3kinectUtils;
import org.as3kinect.as3kinectWrapper;
import org.as3kinect.events.as3kinectWrapperEvent;
import org.as3kinect.objects.motorData;
[SWF(width='1280', height='720', backgroundColor='#000000', frameRate='30')]
public class TestCam extends Sprite {
////////////////////////////////////////////
// VARIABLES
////////////////////////////////////////////
public var xmlParametros :XML;
private var coverflow :Coverflow;
public var btm:BitmapData;
public var bitmapStandar :BitmapData;
public var cargador :Cargador;
public var contte :MovieClip = new MovieClip();
public var currentCover:Sprite;
public var capa :MovieClip = new Background();
public var coverActivo :Boolean=false;
public var overback :MovieClip = new OverBackground();
public var caja :MovieClip = new MovieClip();
public var flvideo :FLVPlayback;
public var listener :Object = new Object();
private var _canvas_depth :BitmapData;
private var _canvas_video :BitmapData;
private var _bmp_depth :Bitmap;
private var _bmp_video :Bitmap;
private var _min_depth_dragging :Boolean = false;
private var _max_depth_dragging :Boolean = false;
private var _motor_dragging :Boolean = false;
private var _threshold_dragging :Boolean = false;
private var _blobs_on :Boolean = false;
private var _wb_filter_on :Boolean = false;
private var _threshold_value :int = 50;
private var _tone :Tone;
private var _as3w :as3kinectWrapper;
public var mc :MovieClip = new MovieClip();
public var bmd :BitmapData;
//VARIABLES PARA CALIBRAR EL DISPOSITIVO DEL KINECT
//punto para el movieclip que va a la izquierda, este de color Azul
public var izq_x:Number = 155;
public var izq_y:Number = 260;
//Punto para mover el movieclip que va a la derecha y es de color verde
public var der_x:Number = 416;
public var der_y:Number = 260;
//Punto para mover el movieclip que va en el centro, este es de color rojo
public var cen_x:Number = 291;
public var cen_y:Number = 260;
//Con esta Variable add_cam_depth se muestra o remueve del escenario la camara del kinect
//True : Se muestra en pantalla
//False : Es removida o nunca se muestra en la pantalla
public var add_cam_depth :Boolean = true;
public var container_mc_depth :MovieClip = new MovieClip();
////////////////////////////////////////////
// CONSTRUCTOR - INITIAL ACTIONS
////////////////////////////////////////////
public function TestCam() {
XML();
fscommand("fullscreen", "true");
setupStage();
//Resize Listener
stage.addEventListener(Event.RESIZE, resizeHandler);
resizeMe();
init();
}
public var myLoader:URLLoader
////////////////////////////////////////////
// FUNCTIONS
////////////////////////////////////////////
public function XML(){
myLoader = new URLLoader();
myLoader.load(new URLRequest("xml/parametros.xml"));
myLoader.addEventListener(Event.COMPLETE, loadXML);
}
public function loadXML(e :Event)
{
xmlParametros = new XML(e.target.data);
izq_x = Number( xmlParametros .@izq_x);
izq_y = Number( xmlParametros .@izq_x);
der_x = Number( xmlParametros .@der_x);
der_y = Number( xmlParametros .@der_x);
cen_x = Number( xmlParametros .@cen_x);
cen_y = Number( xmlParametros .@cen_x);
if( xmlParametros.@add_cam_depth == "Yes")
{
add_cam_depth = true;
}else
{
add_cam_depth = false;
}
}
public function errorXML(e:Event)
{
}
public function setupStage():void {
//stage.quality = StageQuality.HIGH;
//stage.scaleMode = StageScaleMode.NO_SCALE;
//stage.align = StageAlign.TOP_LEFT;
}
private function resizeHandler(event:Event):void {
resizeMe();
}
public function setbitmap():void
{
_as3w = new as3kinectWrapper();
_as3w.depth.mirrored = !_as3w.depth.mirrored;
//Add as3kinectWrapper events (depth, video and acceleration data)
_as3w.addEventListener(as3kinectWrapperEvent.ON_DEPTH, got_depth);
//Add depth BitmapData to depth_cam MovieClip
_canvas_depth = _as3w.depth.bitmap;
_bmp_depth = new Bitmap(_canvas_depth);
bmd = new BitmapData(640,480);
container_mc_depth.addChild(_bmp_depth);
if(this.add_cam_depth){
addChild(container_mc_depth);
}
container_mc_depth.scaleY = -1;
container_mc_depth.y = container_mc_depth.height + container_mc_depth.y;
this.addEventListener(Event.ENTER_FRAME, update);
}
public function showMC():void{
if(coverActivo == false){
addChild(capa);
flvideo = null;
flvideo = new FLVPlayback()
flvideo.source = coverflow._data[coverflow._currentCover].link;
addChild(flvideo);
flvideo.x = 450;
flvideo.y = 200;
flvideo.addEventListener(VideoEvent.COMPLETE, completePlay);
coverActivo = true;
}else{
//ns.close();
if(this.contains(capa)){
removeChild(capa);
removeChild(flvideo);
}
coverActivo = false;
}
}
public function completePlay(e:VideoEvent):void {
trace("VIdeo Complete"+e.toString());
if(this.contains(capa)){
removeChild(capa);
removeChild(flvideo);
}
coverActivo = false;
}
private function resizeMe():void {
//No Resizing for This
}
var maske :Shape = new Shape();
var i :Sprite = new Sprite();
var c :Sprite = new Sprite();
private function init():void {
coverflow = new Coverflow(stage.stageWidth, stage.stageHeight, stage);
addChild(coverflow);
maske.graphics.beginFill(0xffff00);
maske.graphics.drawRect(0,0,stage.width,stage.height);
overback.mouseEnabled = false;
addChild(overback);
addChild(maske);
this.mask = maske;
setbitmap();
d.graphics.beginFill(0x0000ff);
d.graphics.drawCircle(0,0,3);
container_mc_depth.addChild(d); d.x = der_x;d.y = der_y;
i.graphics.beginFill(0x00ff00);
i.graphics.drawCircle(0,0,3);
container_mc_depth.addChild(i); i.x=izq_x; i.y=izq_y;
//izq_x,izq_y
c.graphics.beginFill(0xff0000);
c.graphics.drawCircle(0,0,3);
container_mc_depth.addChild(c); c.x=cen_x;c.y=cen_y;
}
public var got_depth_on :Boolean =false;
public var d :MovieClip = new MovieClip();
public var _playing :Boolean = false;
public var forward :Boolean = false;
public var rewi :Boolean = false;
public var touch_event_izq :Boolean = false;
public var touch_event_der :Boolean = false;
public var cont_touchevent_i :int = 0;
public var cont_touchevent_d :int = 0;
//UPDATE METHOD (This is called each frame)
private function update(event:Event){
// trace(mouseX+" "+mouseY);
_as3w.depth.getBuffer();
if(got_depth_on){
bmd.draw(_bmp_depth);
//trace(cont_touchevent_i+", BOOL: "+touch_event_izq);
//BOTON EN LA IZQUIERDA, ITEM PREVIO
if(bmd.getPixel(izq_x,izq_y) != 0){
this.cont_touchevent_i++;
if(!this.contains(capa))
{
if(this.coverflow != null && got_depth_on == true)
{
if(!touch_event_izq)
{
this.coverflow.clickPre();
got_depth_on = true;
touch_event_izq = true;
}
if(cont_touchevent_i > 15)
{
cont_touchevent_i = 0;
touch_event_izq = false;
}else
{
touch_event_izq = true;
}
}
}else{
if(!rewi){
flvideo.seek(0);
rewi = true;
}else{
rewi = false;
}
}
}else{
this.cont_touchevent_i = 0;
touch_event_izq = false;
}
//CENTRO
if(bmd.getPixel(cen_x,cen_y) != 0){
if(this.coverflow != null && got_depth_on == true){
if(!_playing){
showMC();
got_depth_on = false;
_playing = true;
}
}
}else{
_playing = false;
}
//DERECHA
if(bmd.getPixel(der_x,der_y) != 0){
this.cont_touchevent_d++;
if(!this.contains(capa))
{
if(this.coverflow != null && got_depth_on == true)
{
if(!touch_event_der)
{
this.coverflow.clickNext();
got_depth_on = false;
touch_event_der = true;
}
if(cont_touchevent_d > 15)
{
this.cont_touchevent_d = 0;
touch_event_der = false;
}else
{
touch_event_der = true;
}
}
}else
{
if(!forward)
{
flvideo.seek(flvideo.playheadTime+0.05);
forward = true;
}else
{
forward = false;
}
}
}else{
this.cont_touchevent_d = 0;
touch_event_der = false;
}
}
//trace("Valor IZquierda:"+bmd.getPixel(izq_x,izq_y) +"Valor Centro:"+bmd.getPixel(cen_x,cen_y)+"Valor derecha:"+bmd.getPixel(der_x,izq_y));
}
//GOT DEPTH METHOD
private function got_depth(event:as3kinectWrapperEvent):void{
got_depth_on = true;
_as3w.depth.mirrored = true;
as3kinectUtils.byteArrayToBitmapData(event.data, _canvas_depth);
//as3kinectUtils.fireTouchEvent(1 , new Point(82,60), _touch_data, stage);
}
//GOT VIDEO METHOD
private function got_video(event:as3kinectWrapperEvent):void{
//Convert Received ByteArray into BitmapData
as3kinectUtils.byteArrayToBitmapData(event.data, _canvas_video);
}
//GOT MOTOR DATA (Accelerometer info)
function got_motor_data(event:as3kinectWrapperEvent):void
{
var object:motorData = event.data;
//info.text = "raw acceleration:\n\tax: " + object.ax + "\n\tay: " + object.ay + "\n\taz: " + object.az + "\n\n";
//info.appendText("mks acceleration:\n\tdx: " + object.dx + "\n\tdy: " + object.dy + "\n\tdz: " + object.dz + "\n");
}
}
}
You have a method named XML
:
public function XML(){
myLoader = new URLLoader();
myLoader.load(new URLRequest("xml/parametros.xml"));
myLoader.addEventListener(Event.COMPLETE, loadXML);
}
That is conflicting with the class top level class XML
.
When you say xmlParametros = new XML(e.target.data);
on line 157, the compiler thinks you are referencing your method not the class.
Change your function to an identifier that does not conflict with the class you are trying to instantiate. Perhaps public function requestXML() {