0
votes

Hi i am trying to make preloader in flash builder. I wanna scale my load bar while all of items loading . But when i start my game its just waiting on white screen and skips load screen. Can anyone help me to fix this problem

public class OYLoadManager extends Sprite
{
    private var main:CagryInside;
    //////////////////Load Manager Items///////////////////////////// 
    [Embed(source="../Resources/loadImages/loadBackground.png")]
    private var loadBackgroundClass:Class;
    private var loadBackground:Bitmap = new loadBackgroundClass() ;

    [Embed(source="../Resources/loadImages/loadBar.png")]
    private var loadBarClass:Class ;
    private var loadBar : Bitmap = new loadBarClass() ;

    private static const loadBarWidth:Number = 612;

    private var loadManager:Loader = new Loader();

    public function OYLoadManager(getMain:CagryInside)
    {
        main = getMain;
        // Initializing Load Manager 
        loadBar.x = 226; 
        loadBar.y = 396; 
        loadBar.width = 0 ;

        //Load Screen images
        main.addChild(loadBackground);
        main.addChild(loadBar);
        //main.gameStateManager.selectGameStates(1);


        loadManager.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loadScreen);
        loadManager.contentLoaderInfo.addEventListener(Event.COMPLETE, finishProcess);
        loadManager.load(new URLRequest("playerProductInstall.swf"));


    }

    public function finishProcess(event:Event):void{
    //  removeLoadManagerMenu();
        main.gameStateManager.selectGameStates(1);
    }

    public function loadScreen(event:ProgressEvent):void{

        var ratio:Number = event.bytesLoaded / event.bytesTotal;
        //loadBar.width += loadBarWidth/loadedObjectNumber ;    
        loadBar.scaleX = ratio;
    }
1

1 Answers

0
votes

I can't see a stop() there anywhere.

Otherwise: Make sure when you export your classes for ActionScript that you deselect export in frame 1. Otherwise you'll have a bunch of your assets loading before flash events gets to loading your preloader.

A really useful tool for making sure your first frame is tiny is the bandwidth profiler. Use this. It's at View -> Bandwidth Profiler when you're testing your application/movie from flash. It displays the size of each frame - try keep frame 1 under say 30kb. Simple preloaders are better than big fancy images and such that take 10-20 seconds to load anyway. Or at least start with a simple preloader and then change the appearance of it as assets load.