Results 1 to 5 of 5

Thread: Full Screen Fade In Issue

  1. #1
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Full Screen Fade In Issue

    I have some full screen code which works really well... I added a fade in to the code which does work to fade in the image but after 2 minutes the image just dissappears... Thought maybe you AS experts out there might be able to see what I am doing wrong! I've commented out the fade in code...

    Code:
    function loadBitmapSmoothed(url:String, target:MovieClip) {
    	var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
    	var listener:Object = new Object();
    	listener.tmc = target;
    	listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void  {
    		percent = Math.round((bytesLoaded/bytesTotal)*100);
    		pText.text = percent+"%";
    	};
    	listener.onLoadInit = function(mc:MovieClip) {
    		//fade in image
    		//mc._alpha=0; // Make mc 'mcl' _alpha 0
    		//mc.onEnterFrame=function(){ // Create new function
    		//mc._alpha +=15; // Speed 15
    		
    		mc._visible = false;
    		var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
    		this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
    		bitmap.draw(mc);
    		
    		// set size and position on load
    		if (Stage.height/Stage.width>target._height/target._width) {
    			img_prop = target._width/target._height;
    			target._height = Stage.height;
    			target._width = Stage.height*img_prop;
    			target._y = (Stage.height/2)-(target._height/2);
    			target._x = (Stage.width/2)-(target._width/2);
    		} else {
    			img_prop = target._height/target._width;
    			target._width = Stage.width;
    			target._height = Stage.width*img_prop;
    			target._y = (Stage.height/2)-(target._height/2);
    			target._x = (Stage.width/2)-(target._width/2);
    		}//}
    	};
    	var loader:MovieClipLoader = new MovieClipLoader();
    	loader.addListener(listener);
    	loader.loadClip(url, bmc);
    }

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Why don't you use a tween engine, it'll me a lot better IMO.

    Tween Class:
    Code:
    import mx.transitions.Tween; 
    import mx.transitions.easing.*;
    
    new Tween (mc, "_alpha", Regular.easeOut, 0, 100, 1, true);

    MC Tween:
    Code:
    #include "mc_tween2.as"
    
    mc._alpha = 0
    mc.alphaTo(100, 1, "easeOutQuad")

    btw, still can't get your other file to open

  3. #3
    Join Date
    Apr 2006
    Posts
    584
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi Medyman... Really? Maybe it's corrupt I'll take a look... So tween engine you think, where abouts would I add that to my code?

  4. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    You would add that to the same place where you're existing fade function is.

  5. #5
    Join Date
    Jul 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi,
    I agree with the other people about you using one of the tweening classes to do this, however it may be useful for you to know why your original code was producing the results that it did.

    There is no condition in your onEnterFrame to stop it ie
    PHP Code:
    if(mc._alpha >= 100)delete this.onEnterFrame
    so the onEnterFrame keeps executing - this is probably as you are using it to resize the image when the stage resizes.

    The result is that mc._alpha keeps getting incremented by 15 on each frame - when it reaches 12800 it will change to -12800 and then start adding 15 to that. This is one of those things in flash that you don't look out for unless you know that it is there - why would you want to set the alpha of an mc to more than 100.

    You should be using a tween for the fade in as others have stated.
    You should try to make sure that wherever possible you NEVER leave an onEnterFrame running.
    You should have a function to resize the mc when it first loads eg resizeMc() . Then handle any changes in Stage size by adding a listener to the Stage object and calling your resizeMc() function with the onResize event. There is an example in the help files.

    Hope this helps.

Bookmarks

Posting Permissions

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