Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 not recognising MovieClips - 1046: Type was not found or was not a compile-time constant: MP_00
    primarykey
    data
    text
    <p>So Im new to AS3, trying to make a simple videogame for smartphones. And it was all going smooth until I hit this problem. I was using and manipulating objects from timeline without a problem and than all the sudden whatever I try I get the 1046.</p> <p>Here is some code that gets an error:</p> <pre><code>mp = new MP_00(); </code></pre> <p>And at the top I have this:</p> <pre><code>import flash.display.MovieClip; var mp:Movieclip; </code></pre> <p>And at the end this:</p> <pre><code>function mapMove(){ mp.y = mp.y - playerSpeed; } </code></pre> <p>Im searching for a solution all the time, but nobody seems to have the same problem. I do have AS linkage set to MP_00 and witch ever object I try to put in, it dosent work. While objects put in on the same way before, they work.</p> <p>For example I have this </p> <pre><code>var player:MovieClip; player = new Player(); </code></pre> <p>with AS Linkage set to Player, and that works.</p> <p>This is all done in Flash Professional cs6</p> <p>EDIT 1 full code Keep in mind that a lot of stuff is placeholder or just not finished code.</p> <p>On this code Im getting the error twice for the same object</p> <pre><code>Scene 1 1046: Type was not found or was not a compile-time constant: MP_00. Scene 1, Layer 'Actions', Frame 1, Line 165 1046: Type was not found or was not a compile-time constant: MP_00. </code></pre> <p>Thats the errors.</p> <pre><code>import flash.display.MovieClip; import flash.events.MouseEvent; import flash.text.engine.SpaceJustifier; import flashx.textLayout.operations.MoveChildrenOperation; /*----------------------------Main VARs-----------------------------*/ var STATE_START:String="STATE_START"; var STATE_START_PLAYER:String="STATE_START_PLAYER"; var STATE_PLAY:String="STATE_PLAY"; var STATE_END:String="STATE_END"; var gameState:String; var player:MovieClip; var playerSpeed:Number; var map:Array; var bullets:Array; //holds civil vehicles var civil:Array; //holds enemy vehicles var enemy:Array; var explosions:Array; var BBullet:MovieClip; //maps var mp:MovieClip; /* var MP_01:MovieClip; var MP_02:MovieClip; var MP_03:MovieClip; */ //sets the bullet type and properties var BType = "BBasic"; var BProp:Array; //bullet preperties by type var BBasic:Array = new Array(1, 1, 100, 50, 0, new BBasicA()); /** ARRAY SETTING 0 = bullet position (middle , back, sides etc...) 1-middle front 2-left side front 3-right side front 4-left and right side middle 5-back 7-left and right side wheels 1 = bullet direction 1-forward 2-back 3-sides 2 = fire speed (in millisecounds so 1000 = 1sec) 3 = speed of movement 4 = damage 10-100 5 = name of the firing animation in library 6 = name of launch animation in library 7 = name of impact animation in library **/ var level:Number; //BCivil speed and randomness var BCSpeed:Number = 3; var BCRand:Number = 120; /*------------------------------Setup-------------------------------*/ introScreen.visible = false; loadingScreen.visible = false; gameScreen.visible = false; endScreen.visible = false; //map visibility //MpRSimple.visible = false; /*---------------------------Intro screen--------------------------*/ /*-----------------------------mainScreen---------------------------*/ mainScreen.play_btn.addEventListener(MouseEvent.CLICK, clickAway); function clickAway(event:MouseEvent):void { gameStart(); } function gameStart():void { //Move main screen from stage mainScreen.visible = false; //Begin loading the game loadingScreen.visible = true; gameState = STATE_START; trace (gameState); addEventListener(Event.ENTER_FRAME, gameLoop); } /*----------------------------gameLoop-----------------------------*/ function gameLoop(e:Event):void { switch(gameState) { case STATE_START: startGame(); break; case STATE_START_PLAYER: startPlayer(); break; case STATE_PLAY: playGame(); break; case STATE_END: endGame(); break; } } /*-_________________________-Game STATES-_________________________-*/ /*---------------------------STATE_START---------------------------*/ function startGame():void { level = 1; //setting level for enemies //Graphics //player icon player = new Player(); //add bullet holder bullets = new Array(); //basicCivil icon civil = new Array(); //basicEnemy icon enemy = new Array(); //holds explosions explosions = new Array(); //map //mp = new MP_00(); //var mp:MP_00 = new MP_00(); //Load map parts //End startGame gameState = STATE_START_PLAYER; trace(gameState); } /*------------------------STATE_START_PLAYER-----------------------*/ function startPlayer():void { //start the player //set possition of player player.y = stage.stageHeight - player.height; addChild(player); addEventListener(Event.ENTER_FRAME, movePlayer); //changing screens gameScreen.visible = true; //start game gameState = STATE_PLAY; trace(gameState); } //player controll function movePlayer(e:Event):void { //gameScreen.visible = true; //mouse\touch recognition player.x = stage.mouseX; player.y = stage.mouseY; //player does not move out of the stage if (player.x &lt; 0) { player.x = 0; } else if (player.x &gt; (stage.stageWidth - player.width)) { player.x = stage.stageWidth + player.width; } } //setting bullet type if (BType == "BBasic") { BProp = BBasic; /*case BMissile; BProp = BMissile; break; */ } //creating bullets //gameScreen.fire_btn.addEventListener(MouseEvent.CLICK, fireHandler()); /* function fireHandler():void { var bulletTimer:Timer = new Timer (500); bulletTimer.addEventListener(TimerEvent.TIMER, timerListener); bulletTimer.start(); trace("nja"); } function timerListener(e:TimerEvent):void { //need and if statement to determine the bullet speed and travel depended on type of bullet var tempBullet:MovieClip = /*BProp[5] new BBasicA(); //shoots bullets in the middle tempBullet.x = player.x +(player.width/2); tempBullet.y = player.y; //shooting speed tempBullet.speed = 10; bullets.push(tempBullet); addChild(tempBullet); //bullets movement forward for(var i=bullets.length-1; i&gt;=0; i--) { tempBullet = bullets[i]; tempBullet.y -= tempBullet.speed; } } */ /*----------------------------STATE_PLAY---------------------------*/ function playGame():void { //gameplay //speedUp(); mapMove(); //fire(); makeBCivil(); makeBEnemy(); moveBCivil(); moveBEnemy(); vhDrops(); testCollision(); testForEnd(); removeExEplosions(); } function mapMove(){ mp.y = mp.y - playerSpeed; } /* function speedUp():void { var f:Number; for (f&lt;10; f++;) { var playerSpeed = playerSpeed + 1; f = 0; //mapMove(); MpRSimple = new MP_RS(); MpRSimple.y = MpRSimple.y - playerSpeed; trace ("speed reset"); } trace (f); } */ function makeBCivil():void { //random chance var chance:Number = Math.floor(Math.random()*BCRand); if (chance &lt;= 1 + level) { var tempBCivil:MovieClip; //generate enemies tempBCivil = new BCivil(); tempBCivil.speed = BCSpeed; tempBCivil.x = Math.round(Math.random()*800); addChild(tempBCivil); civil.push(tempBCivil); } } function moveBCivil():void { //move enemies var tempBCivil:MovieClip; for(var i:int = civil.length-1; i&gt;=0; i--) { tempBCivil = civil[i]; tempBCivil.y += tempBCivil.speed } //testion colision with the player and screen out if (tempBCivil.y &gt; stage.stageHeight /* || tempBCivil.hitTestObject(player) */) { trace("ds hit"); //makeExplosion (player.x, player.y); removeCivil(i); //gameState = STATE_END; } } //Test bullet colision function testCollision():void { var tempBCivil:MovieClip; var tempBEnemy:MovieClip; var tempBullet:MovieClip; //civil/bullet colision civils:for(var i:int=civil.length-1; i&gt;=0; i--) { tempBCivil = civil[i]; for (var j:int=bullets.length-1; j&gt;=0; j--) { tempBullet = bullets[j]; if (tempBCivil.hitTestObject(tempBullet)) { trace("laser hit the civil"); makeExplosion (tempBCivil.x, tempBCivil.y); removeCivil(i); removeBullet(j); break civils; } } } //enemy/bullet colision enemy:for(var k:int=enemy.length-1; k&gt;=0; k--) { tempBEnemy = enemy[k]; for (var l:int=bullets.length-1; l&gt;=0; l--) { tempBullet = bullets[l]; if (tempBEnemy.hitTestObject(tempBullet)) { trace("bullet hit the Enemy"); makeExplosion (tempBEnemy.x, tempBEnemy.y); removeEnemy(k); removeBullet(l); break enemy; } } } } function makeExplosion(ex:Number, ey:Number):void { var tempExplosion:MovieClip; tempExplosion = new boom(); tempExplosion.x = ex; tempExplosion.y = ey; addChild(tempExplosion) explosions.push(tempExplosion); } function makeBEnemy():void { //random chance var chance:Number = Math.floor(Math.random()*BCRand); if (chance &lt;= 1 + level) { var tempBEnemy:MovieClip; //generate enemies tempBEnemy = new BEnemy(); tempBEnemy.speed = BCSpeed; tempBEnemy.x = Math.round(Math.random()*800); addChild(tempBEnemy); enemy.push(tempBEnemy); } } function moveBEnemy():void { //move enemies var tempBEnemy:MovieClip; for(var i:int = enemy.length-1; i&gt;=0; i--) { tempBEnemy = enemy[i]; tempBEnemy.y += tempBEnemy.speed } //testion colision with the player and screen out if (tempBEnemy.y &gt; stage.stageHeight /* || tempBCivil.hitTestObject(player) */) { trace("enemy"); //makeExplosion (player.x, player.y); removeEnemy(i); //gameState = STATE_END; } } function vhDrops():void {} function testForEnd():void { //check damage //end game //gameState = STATE_END; trace(gameState); } /*--------------------REMOVING BS FROM STAGE-----------------------*/ //removing civils function removeCivil(idx:int):void { if(idx &gt;= 0) { removeChild(civil[idx]); civil.splice(idx, 1); } } //removing enemies function removeEnemy(idx:int):void { if(idx &gt;= 0) { removeChild(enemy[idx]); enemy.splice(idx, 1); } } //removing civils function removeBullet(idx:int):void { if(idx &gt;= 0) { removeChild(bullets[idx]); bullets.splice(idx, 1); } } //removing expired explosions function removeExEplosions():void { var tempExplosion:MovieClip; for(var i=explosions.length-1; i&gt;=0; i--) { tempExplosion = explosions[i]; if (tempExplosion.currentFrame &gt;= tempExplosion.totalFrames) { removeExplosion(i); } } } //removing civils function removeExplosion(idx:int):void { if(idx &gt;= 0) { removeChild(explosions[idx]); explosions.splice(idx, 1); } } /*--------------------------STATE_END------------------------------*/ function endGame():void { } /*gameScreen*/ /*endScreen*/ </code></pre> <p>And Im sure theres some other bad code here but that doesent matter now.</p> <p>Export for AS and AS Linkage is set: <a href="http://i.stack.imgur.com/UvMAt.png" rel="nofollow">http://i.stack.imgur.com/UvMAt.png</a></p> <p>EDIT: removed the 2nd var declaration, still get the same error.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload