A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: actionscript 2.0 to 3.0

  1. #1
    Member
    Join Date
    Jun 2007
    Posts
    47

    Angry actionscript 2.0 to 3.0

    I need a little help converting this to Actionscript 3.0.I have done some of it so for but I need help on the rest.
    Thanks in advance.
    Code:
    stop();
    
    // Function for fading out objects
    addEventListener(Event.
    function fadeOut(){
    	// Reduce opacity
    	this._alpha-=5;
    	// Check to see if the clip has been faded out all the way, if so remove the script
    	if(this._alpha<=0){
    		// Set opacity all the way down
    		this._alpha=0;
    		// Set the visible to false
    		this._visible=false;
    		// Play next frame
    		play();
    		// Kill the enterframe script
    		this.onEnterFrame=null;
    	}
    }
    
    
    
    // Start the preloading
    
    addEventListener(Event.ENTER_FRAME, currentProgress);
    function currentProgress(e:Event):void{
    	// Variable for how much is downloaded
    	//var dataLoaded=this.getBytesLoaded();
    	// Variable for the total file size
    	//var totalData=this.getBytesTotal();	
    	var bytestotal = stage.loaderInfo.bytesTotal;    
    	var bytesloaded = stage.loaderInfo.bytesLoaded;		
    	// Variable that calculates the percentage downloaded	
    	var percentData = Math.round(bytesloaded/bytestotal)*100;
    	// Animate the preloader. The preloader clip itself it 100px wide
    	preloader_mc.gotoAndPlay(percentData);
    	// Update the text field with the percentage downloaded
    	preloader_mc.percent1_mc.percent_txt.text = percentData+"%";
    	preloader_mc.percent2_mc.percent_txt.text = percentData+"%";
    	// Check to see if the movie is downloaded
    	if(percentData>=100){
    		// Play to the next frame
    		preloader_mc.gotoAndStop(100);
    		// Fade out the preloader and the text field
    		preloader_mc.onEnterFrame=fadeOut;
    		// Get rid of this enterframe script
    		this.onEnterFrame=null;
    	}
    }

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Location
    UK
    Posts
    269
    Looks like you're almost there.

    _alpha and _visible become just apha and visible. And alpha values in AS3 are between 0 and 1, not 0 and 100.

    Instead of 'this.onEnterFrame=null;', you would remove the event listener using 'removeEventListener(Event.ENTER_FRAME, currentProgress);'

  3. #3
    Member
    Join Date
    Jun 2007
    Posts
    47
    Thanks for the help but what about the fadeout function?How should I change that?
    also need to know what to change this too:
    Code:
    preloader_mc.onEnterFrame=fadeOut;
    Last edited by askurat1; 02-13-2008 at 06:32 PM.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center