I'm trying to create something like Assets manager, where I would embed bunch of images in one class and then pass them to other classes for further use. The problem is, after doing all the work, the images simply wont appear, not all of them. From total 41 images I get about 23 to render/display properly. I triple checked all the code, tried in both Flashdevelop and Flash Professional, tried to add each image to it's own MovieClip or Sprite before adding them to stage, tried adding them one by one with addChild method (without using for loop) and still no success... Also there is no compile error (neither syntax).
Is there something like "max embedded image count" for flashdevelop or flash professional?
Here is the code:
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.Sprite;
public class AssetsLoader extends MovieClip
{
[Embed(source = "assets/map800x500.jpg")] private var _layer0Class:Class; public var layer0:Bitmap = new _layer0Class();
[Embed(source = "assets/al/AFR_01.png")] private var AFR_01_Class:Class; public var AFR_01:Bitmap = new AFR_01_Class() as Bitmap;
[Embed(source = "assets/al/AFR_02.png")] private var AFR_02_Class:Class; public var AFR_02:Bitmap = new AFR_02_Class() as Bitmap;
[Embed(source = "assets/al/AFR_03.png")] private var AFR_03_Class:Class; public var AFR_03:Bitmap = new AFR_03_Class() as Bitmap;
[Embed(source = "assets/al/AFR_04.png")] private var AFR_04_Class:Class; public var AFR_04:Bitmap = new AFR_04_Class() as Bitmap;
[Embed(source = "assets/al/AFR_05.png")] private var AFR_05_Class:Class; public var AFR_05:Bitmap = new AFR_05_Class() as Bitmap;
[Embed(source = "assets/al/AFR_06.png")] private var AFR_06_Class:Class; public var AFR_06:Bitmap = new AFR_06_Class() as Bitmap;
[Embed(source = "assets/al/ASI_01.png")] private var ASI_01_Class:Class; public var ASI_01:Bitmap = new ASI_01_Class() as Bitmap;
[Embed(source = "assets/al/ASI_02.png")] private var ASI_02_Class:Class; public var ASI_02:Bitmap = new ASI_02_Class() as Bitmap;
[Embed(source = "assets/al/ASI_03.png")] private var ASI_03_Class:Class; public var ASI_03:Bitmap = new ASI_03_Class() as Bitmap;
[Embed(source = "assets/al/ASI_04.png")] private var ASI_04_Class:Class; public var ASI_04:Bitmap = new ASI_04_Class() as Bitmap;
[Embed(source = "assets/al/ASI_05.png")] private var ASI_05_Class:Class; public var ASI_05:Bitmap = new ASI_05_Class() as Bitmap;
[Embed(source = "assets/al/ASI_06.png")] private var ASI_06_Class:Class; public var ASI_06:Bitmap = new ASI_06_Class() as Bitmap;
[Embed(source = "assets/al/ASI_07.png")] private var ASI_07_Class:Class; public var ASI_07:Bitmap = new ASI_07_Class() as Bitmap;
[Embed(source = "assets/al/ASI_08.png")] private var ASI_08_Class:Class; public var ASI_08:Bitmap = new ASI_08_Class() as Bitmap;
[Embed(source = "assets/al/ASI_09.png")] private var ASI_09_Class:Class; public var ASI_09:Bitmap = new ASI_09_Class() as Bitmap;
[Embed(source = "assets/al/ASI_10.png")] private var ASI_10_Class:Class; public var ASI_10:Bitmap = new ASI_10_Class() as Bitmap;
[Embed(source = "assets/al/ASI_11.png")] private var ASI_11_Class:Class; public var ASI_11:Bitmap = new ASI_11_Class() as Bitmap;
[Embed(source = "assets/al/AUS_01.png")] private var AUS_01_Class:Class; public var AUS_01:Bitmap = new AUS_01_Class() as Bitmap;
[Embed(source = "assets/al/AUS_02.png")] private var AUS_02_Class:Class; public var AUS_02:Bitmap = new AUS_02_Class() as Bitmap;
[Embed(source = "assets/al/AUS_03.png")] private var AUS_03_Class:Class; public var AUS_03:Bitmap = new AUS_03_Class() as Bitmap;
[Embed(source = "assets/al/AUS_04.png")] private var AUS_04_Class:Class; public var AUS_04:Bitmap = new AUS_04_Class() as Bitmap;
[Embed(source = "assets/al/EUR_01.png")] private var EUR_01_Class:Class; public var EUR_01:Bitmap = new EUR_01_Class() as Bitmap;
[Embed(source = "assets/al/EUR_02.png")] private var EUR_02_Class:Class; public var EUR_02:Bitmap = new EUR_02_Class() as Bitmap;
[Embed(source = "assets/al/EUR_03.png")] private var EUR_03_Class:Class; public var EUR_03:Bitmap = new EUR_03_Class() as Bitmap;
[Embed(source = "assets/al/EUR_04.png")] private var EUR_04_Class:Class; public var EUR_04:Bitmap = new EUR_04_Class() as Bitmap;
[Embed(source = "assets/al/EUR_05.png")] private var EUR_05_Class:Class; public var EUR_05:Bitmap = new EUR_05_Class() as Bitmap;
[Embed(source = "assets/al/EUR_06.png")] private var EUR_06_Class:Class; public var EUR_06:Bitmap = new EUR_06_Class() as Bitmap;
[Embed(source = "assets/al/EUR_07.png")] private var EUR_07_Class:Class; public var EUR_07:Bitmap = new EUR_07_Class() as Bitmap;
[Embed(source = "assets/al/NAM_01.png")] private var NAM_01_Class:Class; public var NAM_01:Bitmap = new NAM_01_Class() as Bitmap;
[Embed(source = "assets/al/NAM_02.png")] private var NAM_02_Class:Class; public var NAM_02:Bitmap = new NAM_02_Class() as Bitmap;
[Embed(source = "assets/al/NAM_03.png")] private var NAM_03_Class:Class; public var NAM_03:Bitmap = new NAM_03_Class() as Bitmap;
[Embed(source = "assets/al/NAM_04.png")] private var NAM_04_Class:Class; public var NAM_04:Bitmap = new NAM_04_Class() as Bitmap;
[Embed(source = "assets/al/NAM_05.png")] private var NAM_05_Class:Class; public var NAM_05:Bitmap = new NAM_05_Class() as Bitmap;
[Embed(source = "assets/al/NAM_06.png")] private var NAM_06_Class:Class; public var NAM_06:Bitmap = new NAM_06_Class() as Bitmap;
[Embed(source = "assets/al/NAM_07.png")] private var NAM_07_Class:Class; public var NAM_07:Bitmap = new NAM_07_Class() as Bitmap;
[Embed(source = "assets/al/NAM_08.png")] private var NAM_08_Class:Class; public var NAM_08:Bitmap = new NAM_08_Class() as Bitmap;
[Embed(source = "assets/al/NAM_09.png")] private var NAM_09_Class:Class; public var NAM_09:Bitmap = new NAM_09_Class() as Bitmap;
[Embed(source = "assets/al/SAM_01.png")] private var SAM_01_Class:Class; public var SAM_01:Bitmap = new SAM_01_Class() as Bitmap;
[Embed(source = "assets/al/SAM_02.png")] private var SAM_02_Class:Class; public var SAM_02:Bitmap = new SAM_02_Class() as Bitmap;
[Embed(source = "assets/al/SAM_03.png")] private var SAM_03_Class:Class; public var SAM_03:Bitmap = new SAM_03_Class() as Bitmap;
[Embed(source = "assets/al/SAM_04.png")] private var SAM_04_Class:Class; public var SAM_04:Bitmap = new SAM_04_Class() as Bitmap;
public var allTerritories:Array = [AFR_01, AFR_02, AFR_03, AFR_04, AFR_05, AFR_06,
ASI_01, ASI_02, ASI_03, ASI_04, ASI_05, ASI_06, ASI_07, ASI_08, ASI_09, ASI_10, ASI_11,
AUS_01, AUS_02, AUS_03, AUS_04,
EUR_01, EUR_02, EUR_03, EUR_04, EUR_05, EUR_06, EUR_07,
NAM_01, NAM_02, NAM_03, NAM_04, NAM_05, NAM_06, NAM_07, NAM_08, NAM_09,
SAM_01, SAM_02, SAM_03, SAM_04];
public var alphaContainer:MovieClip = new MovieClip();
public function AssetsLoader()
{
for (var i:int = 0; i < allTerritories.length; i++)
{
alphaContainer.addChild(allTerritories[i]);
alphaContainer.getChildAt(i).alpha = 1;
}
}
}
}
In another class I'm adding "alphaContainer" to stage:
package
{
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
[SWF(width = "800", height = "500", backgroundColor = "#222222", frameRate = "60")]
public class GameMap extends MovieClip
{
public var map:AssetsLoader = new AssetsLoader();
public function GameMap()
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init():void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
addChild(map.alphaContainer);
}
}
}
I once had a similar problem, and when I run my SWF in a debugger, it turned out that there's some runtime library missing which is required for loading embedded content. It was related to a compiler warning which appeared in my command line when compiling:
Warning: This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries. To compile without runtime shared libraries either set the -static-link-runtime-shared-libraries option to true or remove the -runtime-shared-libraries option.
When I added the -static-link-runtime-shared-libraries option, it started working.
Maybe the cause of your problem is the same?
Related
errore (private var isPlaying:Boolean;),i want paly more mp3 file for my project.help me.
Here's my code starts:
public class PlayerClass extends MovieClip
{
private var urlLoader:URLLoader;
private const xmlPath:String = "playlist.xml";//xml path
private var xml:XML;
private var songs:Array;// array for song paths
private var titles:Array;// array for song titles
private var currentSong:Number = 0;
private var sound:Sound;
private var context:SoundLoaderContext;
private var channel:SoundChannel;
private var isPlaying:Boolean;
private var isStopped:Boolean;
private var songPosition:int = 0;
}
I have a Problem with away 3d.I wanted to create an application and it was working fine till I had embedded 5 images in my program but as soon as I embed more than 5 images the flash develop stops responding [No debug Flash player connection request] showing me this message.Is it the problem with the number of images or should I do something else to include these images.
[Embed(source="assets1/b1 copy.png")]
private var EarthImage:Class;
private var earth:Bitmap = new EarthImage();
[Embed(source="assets1/balls.jpg")]
private var bac:Class;
private var bm:Bitmap = new bac();
[Embed(source="assets1/1.png")]
private var bac1:Class;
private var bm1:Bitmap = new bac1();
[Embed(source="assets1/2.png")]
private var bac2:Class;
private var bm2:Bitmap = new bac2();
[Embed(source="assets1/3.png")]
public var bac3:Class;
public var bm3:Bitmap = new bac3();
[Embed(source="assets1/4.png")]
public var bac4:Class;
public var bm4:Bitmap = new bac4();
[Embed(source="assets1/5.png")]
public var bac5:Class;
public var bm5:Bitmap = new bac5();
[Embed(source="assets1/6.png")]
public var bac6:Class;
public var bm6:Bitmap = new bac6();
[Embed(source="assets1/7.png")]
public var bac7:Class;
public var bm7:Bitmap = new bac7();
[Embed(source="assets1/8.png")]
public var bac8:Class;
public var bm8:Bitmap = new bac8();
[Embed(source="assets1/9.png")]
public var bac9:Class;
public var bm9:Bitmap = new bac9();
[Embed(source="assets1/10.png")]
public var bac10:Class;
public var bm10:Bitmap = new bac10();
[Embed(source="assets1/11.png")]
public var bac11:Class;
public var bm11:Bitmap = new bac11();
[Embed(source="assets1/12.png")]
public var bac12:Class;
public var bm12:Bitmap = new bac12();
[Embed(source="assets1/13.png")]
public var bac13:Class;
public var bm13:Bitmap = new bac13();
[Embed(source="assets1/14.png")]
public var bac14:Class;
public var bm14:Bitmap = new bac14();
[Embed(source="assets1/15.png")]
public var bac15:Class;
public var bm15:Bitmap = new bac15();
[Embed(source="assets1/16.png")]
public var bac16:Class;
public var bm16:Bitmap = new bac16();
[Embed(source="assets1/17.png")]
public var bac17:Class;
public var bm17:Bitmap = new bac17();
[Embed(source="assets1/18.png")]
public var bac18:Class;
public var bm18:Bitmap = new bac18();
[Embed(source="assets1/19.png")]
public var bac19:Class;
public var bm19:Bitmap = new bac19();
[Embed(source="assets1/20.png")]
public var bac20:Class;
public var bm20:Bitmap = new bac20()
This is the code I am using to embed the images into the application.
I've been trying to make quiz but i get bunch of errors that say:The public attribute can only be used inside a package.
package
{
import flash.display.Sprite;
import flash.events.Event;
/**
* ...
* #author Ilija
*/
public class Main extends Sprite
{
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
private var ButtonI:Loader = new Loader();
I get errors for all these vars
private var ButtonI2:Loader = new Loader();
private var ButtonI3:Loader = new Loader();
private var Button1:Sprite = new Sprite();
private var Button2:Sprite = new Sprite();
private var Button3:Sprite = new Sprite();
private var QuestionText:TextField = new TextField();
private var A1Text:TextField = new TextField();
private var A2Text:TextField = new TextField();
private var A3Text:TextField = new TextField();
private var pointText:TextField = new TextField();
private var point:int = 0;
private var _questions:Questions;
public function Main():void
I have seen this error when you have { without a matching }
make sure you have an opening with closing curly brackets all over...
I am having an Error on the loop function can anyone tell me what i am doing wrong?
I think my syntax is good?
Severity and Description Path Resource Location Creation Time Id
1046: Type was not found or was not a compile-time constant: Event. ar/src ar.as line 94 1318225764229 228
package {
import flash.display.Sprite;
import org.papervision3d.objects.primitives.Cube;
[SWF(width="640", height="480", framerate="30", backgroundColor="#ffffff")]
public class ar extends Sprite
{
// Embed the marker.pat file
[Embed(source="marker.pat", mimeType="application/octet-stream")]
private var marker:Class;
// Embed the camera.pat file
[Embed(source="camera_para.dat", mimeType="application/octet-stream")]
private var cam_params:Class;
// createFLAR Vars
private var ar_params:FLARParam;
private var ar_marker:FLARCode;
// createCAM Vars
private var ar_vid:Video;
private var ar_cam:Camera;
// createBMP Vars
private var ar_bmp:BitmapData;
private var ar_raster:FLARRgbRaster_BitmapData;
private var ar_detection:FLARSingleMarkerDetector;
// createPapervision Vars
private var ar_scene:Scene3D;
private var ar_3dcam:FLARCamera3D;
private var ar_basenode:FLARBaseNode;
private var ar_viewport:Viewport3D;
private var ar_renderengine:BasicRenderEngine;
private var ar_transmat:FLARTransMatResult;
private var ar_cube:Cube;
public function ARProj()
{
createFLAR();
createCAM();
createBMP();
createPapervision();
addEventListener(Event.ENTER_FRAME, loop);
}
public function createFLAR()
{
ar_params = new FLARParam();
ar_marker = new FLARCode();
ar_params.loadParam(new cam_params() as ByteArray);
ar_marker.loadARPatt(new marker());
}
public function createCAM()
{
ar_vid = new Video(640, 480);
ar_cam = Camera.getCamera();
ar_cam.setMode(640,480,30);
ar_vid.attachCamera(ar_cam);
addChild(ar_vid);
}
public function createBMP()
{
ar_bmp = new BitmapData(640,480);
ar_bmp.draw(ar_vid);
ar_raster = new FLARRgbRaster_BitmapData(ar_bmp);
ar_raster = new FLARSingleMarkerDetector(ar_params, ar_marker, 80);
}
public function createPapervision()
{
ar_scene = new Scene3D();
ar_3dcam = new FLARCamera3D(ar_params);
ar_basenode = new FLARBaseNode();
ar_renderengine = new BasicRenderEngine();
ar_transmat = new FLARTransMatResult();
ar_viewport = new Viewport3D();
var ar_light:PointLight3D = new PointLight3D();
ar_light.x = 1000;
ar_light.y = 1000;
ar_light.z = -1000;
var ar_bitmap:BitmapMaterial;
ar_bitmap = new BitmapFileMaterial("image.jpeg");
ar_bitmap.doubleSided = true;
ar_cube = new Cube(new MaterialsList({all:ar_bitmap}), 80, 80, 80);
ar_scene.addChild(ar_baseNnode);
ar_basenode.addChild(ar_cube);
addChild(ar_viewport);
}
public function loop(e:Event):void
{
ar_bmp.draw(ar_vid);
ar_cube.rotationX +=4;
ar_cube.rotationY +=6;
try
{
if (ar_detection.detectMarkerLite(ar_raster, 80) && ar_detection.getConfidence() > 0)
{
ar_detection.getTransformMatrix(ar_transmat);
ar_basenode.setTransformMatrix(ar_transmat);
ar_renderengine.renderScene(ar_scene, ar_3dcam, ar_viewport);
}
}
catch(e:Error){
}
}
}
}
import flash.events.Event;
You have not imported Event class. Add this import.
You're missing the import for the event Class (and probably more).
private static var tileDir:String;
public static var tileImage:BitmapData;
private static var loader:Loader;
public static var tileReady:EventDispatcher = new EventDispatcher();
public static var tileNum_perRow:Number = 3;
public static var select:selector;
public var tileNum:Number = 0;
public var setBack:Number = 0;
public var tileState:String;
public var tCol:Number;
public var tRow:Number;
private var tWidth:int = 30;
private var tHeight:int = 30;
private var tImage:BitmapData;
private var canvas:Bitmap;
private var p:Point;
private var r:Rectangle;
public function Tile():void
{
var tempImage:BitmapData = tileImage;
r = new Rectangle(0,0,30,30);
p = new Point(0,0);
tImage = new BitmapData(30,30);
tImage.copyPixels(tempImage,r,p);
}
And I get the following error:
ArgumentError: Error #2015: Invalid BitmapData.
It tends to happen when I copy the pixels. I dont know why.
tileImage;
tileImage is valid, I've used the variable in the code below and it works. But above doesnt. Don't know why. Anyone have any clues?
this.graphics.beginBitmapFill(tileImage);
this.graphics.drawRect(60, 0,tWidth ,tHeight );
Nevermind, I figure a better solution
theMatrix.translate(30,0);
this.graphics.beginBitmapFill(tileImage,theMatrix);
//this.graphics.drawRect(0, 0,tWidth ,tHeight );
this.graphics.endFill();
using the theMatrix.translates give you the ability to choose what part of the tile you want, without effecting the position of the sprite