PDA

View Full Version : 1046: Type was not found or was not a compile-time constant


ogani
12-04-2008, 02:57 PM
this is the code in my swf file

import net.quip.sound.CuePointEvent;

function onCuePoint(event:CuePointEvent):void {
play();
}

and this in my actionscript file

package net.quip.sound
{
//import flash.external.*;
import flash.events.Event;

public class CuePointEvent extends Event
{
// PROPERTIES
public static const CUE_POINT:String = "cuePoint";
public var name:String;
public var time:uint;

// CONSTRUCTOR
public function CuePointEvent(type:String, cuePointName:String, cuePointTime:uint, bubbles:Boolean = false, cancelable:Boolean = false)
{
super(type, bubbles, cancelable);
this.name = cuePointName;
this.time = cuePointTime;
ExternalInterface.call("showit",cuePointName, cuePointTime );
}

}
}

I get this error
1046: Type was not found or was not a compile-time constant: CuePointEvent.

any ideas? i have scratched my head all day with it :eek:

Vjeko
12-05-2008, 09:26 AM
Check your paths, and folder structure, try playing with various ways to import your class.

ActionscriptDummie2009
02-17-2009, 08:54 PM
I am having this problem with my Actionscript file i am going mad trying to figure it out could anyone please help here is my as file?I am trying to do a dynamic photo galllery where everything is being pulled from code.package {
import flash.display.MovieClip;
import flash.events.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.display.*;
import app.ui.CreateRoundRectButton;
import flash.display.Bitmap;
import fl.motion.easing.*;




//class
public class gallery2 extends MovieClip {


private var galleryData:XML;
private var imgNum:int;
private var cols:int;
private var rows:int;
private var imgCount:int = 0;
private var spacing:int = 20;
private var menubarX:int = 50;
private var menubarY:int = 300;
private var gallery:MovieClip = new MovieClip();
addChild(gallery);
private var detailImage:Loader = new Loader();
setupDetail();



buildGalleryGrid();

//constructor
public function gallery2() {
trace("hello");
//this loads the XML
var galleryLoader:URLLoader = new URLLoader();
galleryLoader.load(new URLRequest("gallery.xml"));
galleryLoader.addEventListener(Event.COMPLETE, onComplete, false, 0, true);

function start() {

trace("hello");

var _menubar:Sprite = new Sprite();
//add a rectangle
var rect:Shape = new Shape();
rect.graphics.lineStyle(1);
rect.graphics.beginFill(0xCCCCCC, 3);
rect.graphics.drawRect(0, 0, 400, 50);
_menubar.addChild(rect);

var _playbtn:Sprite = new CreateRoundRectButton(80,20,15,3,0xCC66CC,"Play", 0x000000);
var _pausebtn:Sprite = new CreateRoundRectButton(80,20,15,3,0xCC66CC,"Pause", 0x000000);
var _stopbtn:Sprite = new CreateRoundRectButton(80,20,15,3,0xCC66CC,"Stop", 0x000000);

_playbtn.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_pausebtn.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
_stopbtn.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);

_playbtn.x = 10;
_pausebtn.x = _playbtn.width + spacing + 10;
_stopbtn.x = _playbtn.width + _pausebtn.width + spacing + spacing+10;

_playbtn.y = 10;
_pausebtn.y = 10;
_stopbtn.y = 10;


_menubar.addChild(_playbtn);
_menubar.addChild(_pausebtn);
_menubar.addChild(_stopbtn);

addChild(_menubar);
_menubar.x =menubarX;
_menubar.y =menubarY;


function onClick(evt:MouseEvent):void {
trace("button works");
}
}
}
}
//this method parses the XML
public function onComplete(evt:Event):void {
galleryData = new XML(evt.target.data);
imgNum = galleryData.image.length();
spacing = galleryData.@spacing;
cols = galleryData.@cols;
rows = Math.ceil(imgNum / cols);
trace(spacing);
trace(imgNum);
//start checking if the movie is loaded
addEventListener(Event.ENTER_FRAME, onCheckLoaded, false, 0, true);
galleryLoader.removeEventListener(Event.COMPLETE, onGalleryDataLoaded);
}


//function onCheckLoaded(evt:Event):void {
//if (root.loaderInfo.bytesTotal == root.loaderInfo.bytesLoaded) {
//gotoAndStop("main");
//removeEventListener(Event.ENTER_FRAME, onCheckLoaded);
//}
//}


addChild(gallery2);

buildGalleryGrid();



function setupDetail():void {
detail.visible = false;
detail.buttonMode = true;
detail.closeMessage.mouseEnabled = false;
detail.desc.mouseEnabled = false;

detail.addChild(detailImage);
// put border above loader;
detail.addChild(detail.border);
// make sure detail is above the gallery
addChild(detail);

detail.addEventListener(MouseEvent.CLICK, onCloseDetail,
false, 0, true);
}

function onCloseDetail(evt:MouseEvent):void {
detailImage.unload();
//detail.visible = false;private
}

function buildGalleryGrid():void {
for (var py:int = 0; py<rows; py++) {
for (var px:int = 0; px<cols; px++) {

var thumb:MovieClip = new Thumb();
thumb.scaleX = thumb.scaleY = .5;

// since the registration is centered we make sure to position
// thumbs so that the upper left corner is at the registration
// of the gallery movieClip

thumb.x = thumb.width / 2 + (thumb.width + spacing) * px;
thumb.y = thumb.height / 2 + (thumb.height + spacing) * py;

gallery.addChild(thumb);

// only add listeners and loader if thumb should be active
if (imgCount < imgNum) {

var imageData:XML = galleryData.image[imgCount];
var loader:Loader = new Loader();
var path:String = galleryData.@folder + imageData.@thumb;
loader.x = 0;
loader.y = 0;
loader.load(new URLRequest(path));
loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, onThumbComplete);

thumb.addChild(loader);
thumb.addChild(thumb.border);

thumb.buttonMode = true;

thumb.detail = galleryData.@folder + imageData.@detail;
thumb.desc = imageData;

thumb.addEventListener(MouseEvent.CLICK, onThumbClick,
false, 0, true);

thumb.addEventListener(MouseEvent.ROLL_OVER, onThumbOver,
false, 0, true);

thumb.addEventListener(MouseEvent.ROLL_OUT, onThumbOut,
false, 0, true);
} else {
// thumb is inactive
thumb.alpha = .5;
}
imgCount++;
maxWidth = gallery.width;
maxHeight = gallery.height;
}
}
}

// center the gallery clip
gallery.x = stage.stageWidth/2 - gallery.width/2;
gallery.y = stage.stageHeight/2 - gallery.height/2;

// position and setup gallery title
galleryTitle.autoSize = TextFieldAutoSize.LEFT;
galleryTitle.text = galleryData.@title;
galleryTitle.x = gallery.x-2;
galleryTitle.y = gallery.y-50;
}

function onThumbComplete(evt:Event):void {
var img:Bitmap = Bitmap(evt.target.content);
img.x = -img.width/2;
img.y = -img.height/2;
evt.target.removeEventListener(Event.COMPLETE, onThumbComplete);
}

function onThumbOver(evt:MouseEvent):void {
var thumb:MovieClip = MovieClip(evt.target);
gallery.addChild(thumb);
thumb.scaleX = thumb.scaleY = 1;
}

function onThumbOut(evt:MouseEvent):void {
evt.target.scaleX = evt.target.scaleY = .5;
}

function onThumbClick(evt:MouseEvent):void {
detail.visible = false;

detail.desc.condenseWhite = true;
detail.desc.htmlText = evt.currentTarget.desc;

try {
detailImage.close();
} catch (e:Error) {
// this is here incase someone tried to load another
// image before the detail has finished loading
// (not possible with current layout)
// trace(e);

detailImage.load(new URLRequest(evt.currentTarget.detail));
detail.visible = true;
detailImage.alpha = 0;
detailImage.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, onDetailComplete)

}
}