The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 6 of 6

Thread: I am IN HUGE Trouble

  1. #1
    rimacy's Avatar
    309
    posts
    Registered Schmoozer

    Fla Script I am IN HUGE Trouble

    I publish my swf, everything works great. I make a preloader that seems to run well and here are the actions:
    Code:
    var l:Loader=new Loader();l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,loop);
    l.contentLoaderInfo.addEventListener(Event.COMPLETE,done);
    l.load(new URLRequest("MVCSpringBeauty12512.swf"));
    
    
    function loop(e:ProgressEvent):void
    {
        var perc=e.bytesLoaded/e.bytesTotal;
        ProgBar.scaleX=perc;
    }
    
    
    function done(e:Event):void
    {    removeChildAt(1);//tried this
           // removeChild(sunnyGulag);  tried this ,should be the same as removeChildAt(1)
        removeChildAt(0);//tried this
             removeChildAt(progBar);//tried this  ,should be the same as removeChildAt(0)
        //addChild(l);//tried this
        
    }
    Problem is that when the game starts to play I can still see my menu screen in the background and then my asBaseScreen is also in the background!!! My screenHandler is being screwed up by the damn preloader. I need a point in the right direction PLEASE

  2. #2
    Did you try to remove all childs that are in the display list, maybe something is gething wrong in the order
    Code:
    while(numChildren >0){
    removeChildAt(0);
    }

  3. #3
    rimacy's Avatar
    309
    posts
    Registered Schmoozer
    With this code:

    Code:
    function done(e:Event):void
    {    while(numChildren >0)
        {
            removeChildAt(0);
        }
        trace(numChildren)
        addChildAt(l,0);
        
    }
    The problem persists AND it traces 0!
    I added a trace to the function that removes the old screen in my formerly working view class
    Code:
    
    		private function removeOldScreen():void
    		{
    			trace("v368 numChildren from view= "+ numChildren);
    			
    			if(screenLayer.numChildren>0)
    			{
    				
    				var oldScreen:Sprite;
    				
    				oldScreen = screenLayer.getChildAt(0) as Sprite;
    					
    					screenLayer.removeChild(oldScreen);
    				
    			}
        		
    		}
    When I run it alone(it works) it traces
    v368 numChildren from view= 1
    v368 numChildren from view= 1(this is taking it through menu into play)
    When I run it with the preloader(old screen persists) it traces
    0
    v368 numChildren from view= 1
    v368 numChildren from view= 1
    v368 numChildren from view= 1(this is taking it through menu into play)
    Last edited by rimacy; April 15th, 2012 at 10:04 AM.

  4. #4
    rimacy's Avatar
    309
    posts
    Registered Schmoozer
    OK I got it but I still don't understand it. It turns out that ALL along I have been adding menuScreen to the screenLayer two times. When the swf is run alone this didn't cause any problems but with the preloader the other menuscreen persisted. It must have something to do with the preloader now supplying the background?

    Thanks for the help Thovas.
    Last edited by rimacy; April 15th, 2012 at 10:46 AM.

  5. #5
    21
    posts
    Registered User
    I am courious ..what is diference between while and if statement?

    Thanks for reply.

  6. #6
    rimacy's Avatar
    309
    posts
    Registered Schmoozer
    "While" will execute the command over and over again as long as the condition is met. If the condition never changes, then the while loop will execute forever.

    "If" executes the command once if the condition is met.
    If there is an "Else", that command is executed once if the condition is not met. So If/Else gives you a one or the other situation.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012