How do I draw an image regardless in AS3 code?

Mineat

  • Posts: 379
I was making my rpg in depth, until this question popped up. Is there a way to draw a loader in between the gameplay and on top of everything else? Here's what I got:

The use code:
Code: [Select]
import scripts.inLoader;

battleTMV = new inLoader;
battleTMV.inLoader(battleTMV, false);

The script:
Code: [Select]
package scripts
{
//Changing the package name in code requires you to change the package name in properties as well

import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.filters.*;

import Box2DAS.Collision.*;
import Box2DAS.Collision.Shapes.*;
import Box2DAS.Common.*;
import Box2DAS.Dynamics.*;
import Box2DAS.Dynamics.Contacts.*;
import Box2DAS.Dynamics.Joints.*;

import stencyl.api.data.*;
import stencyl.api.engine.*;
import stencyl.api.engine.actor.*;
import stencyl.api.engine.behavior.*;
import stencyl.api.engine.bg.*;
import stencyl.api.engine.font.*;
import stencyl.api.engine.scene.*;
import stencyl.api.engine.sound.*;
import stencyl.api.engine.tile.*;
import stencyl.api.engine.utils.*;

import org.flixel.*;
import mochi.as3.*;
import flash.ui.Mouse;

public dynamic class inLoader
 extends MovieClip
{

(attribute(id="1",name="loader",desc="The transition's name.",type="animation"));
public var str:MovieClip;

(attribute(id="2",name="isLooping",desc="Tells if looping is done or not."));
public var loop:Boolean;

public function inLoader(str:String,loop:Boolean)
{
loadMovieClip(str,-1);
str.x = 0;
str.y = 0;
str.h = stage.stageHeight;
str.w = stage.stageWidth;

str.play();
if(loop == false)
{
str.addEventListener(Event.ENTER_FRAME, str.everyFrame);

}

}

private function everyFrame(event:Event):void
{
if (str.currentFrame == 1)
    {
        str.gotoAndStop(str.totalFrames);
    }
    else
    {
          str.prevFrame();
    }
}
}
}

« Last Edit: October 29, 2012, 03:31:51 pm by Mineat »

Mineat

  • Posts: 379
Hello? I need help here!

rob1221

  • *
  • Posts: 9472
Doesn't a MovieClip need to be added to the stage?

Mineat

  • Posts: 379
Yeah, but aren't all of the entities MovieClips?

rob1221

  • *
  • Posts: 9472
I meant using FlxG.stage.addChild()

Mineat

  • Posts: 379
Okay, they left that piece of code alone in. 2.2. Now I'm getting compiler errors about the variables not being defined when they should be. Why is that happening?