A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: Need help with a preloader in a fluid layout Flash website

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    1

    Question Need help with a preloader in a fluid layout Flash website

    Hi. I'm new to the forum and actionscript 3. I'm basically a designer with no real programming background. I do understand some basic of AS2, but with AS3 I kinda have no clue. Anyway I got a problem that I have been trying to solve alone for quite some time and can't seem to. So any help on this will be highly appreciated.

    I want to make a full flash website in Fluid Layout using AS3. Here are the tutorials I'm following:

    http://stairwellblog.com/2009/03/cre...ts-the-basics/
    http://www.dlocc.com/articles/flash-...-and-download/

    I'm trying to write my own code based on the thing I have seen in both tutorials. I wrote the fluid layout part based on the first tutorial link, and the preloader part based on the code found in preloader.fla in the second tutorial link.

    So now I have 2 seperated swf file, which is website.swf and preloader.swf

    The thing is that once the preloader is done and the website.swf is shown, the fluid layout code inside website.swf doesn't seem to work. Both files has the fluid layout code, and the code works when u open the file seperately, but when it's linked together the code just fails.

    here's the code on the preloader.fla:
    Code:
    import flash.events.Event;
    import flash.display.MovieClip;
    
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    
    Mouse.hide();
    stage.addEventListener(MouseEvent.MOUSE_MOVE,follow);
    function follow(evt:MouseEvent){
    	cursor_mc.x = mouseX;
    	cursor_mc.y = mouseY;
    }
    
    preloader_mc.x = ((stage.stageWidth / 2) - (preloader_mc.width / 2)) ;
    preloader_mc.y = ((stage.stageHeight / 2) - (preloader_mc.height / 2)) ;
    bg_mc.x = ((stage.stageWidth / 2) - (bg_mc.width / 2)) ;
    bg_mc.y = ((stage.stageHeight / 2) - (bg_mc.height / 2)) ;
    
    var loader:Loader = new Loader();
    var req:URLRequest = new URLRequest("website2.swf");
    var preLoadRemove:MovieClip;
    preLoadRemove = preloader_mc;
    
    
    stage.addEventListener(Event.RESIZE, onStageResize);
    
    function onStageResize(evt:Event):void
    	{
    		//trace("Stage Height =" + stage.stageHeight + "px", "Stage Width =" + stage.stageWidth + "px") ;
    		preloader_mc.x = ((stage.stageWidth / 2) - (preloader_mc.width / 2)) ;
    		preloader_mc.y = ((stage.stageHeight / 2) - (preloader_mc.height / 2)) ;
    		bg_mc.x = ((stage.stageWidth / 2) - (bg_mc.width / 2)) ;
    		bg_mc.y = ((stage.stageHeight / 2) - (bg_mc.height / 2)) ;
    	}
    
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadPage);
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
    
    function loadPage(e:ProgressEvent):void
    {
    	var pct:Number = e.bytesLoaded / e.bytesTotal;
    	preloader_mc.bar_mc.scaleX = pct;
    }
    
    function done(e:Event):void
    {
    	removeChild(preLoadRemove); 
    	canvas_mc.addChild(loader); 
    	cursor_mc.gotoAndPlay("passive");
    	
    }
    
    loader.load(req);
    and here's the code on website.fla :
    Code:
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    
    stage.addEventListener(Event.RESIZE, onStageResize);
    
    bg_mc.x = ((stage.stageWidth / 2) - (bg_mc.width / 2)) ;
    bg_mc.y = ((stage.stageHeight / 2) - (bg_mc.height / 2)) ;
    
    mainmenu_mc.x = ((stage.stageWidth / 2) - (mainmenu_mc.width / 2)) ;
    mainmenu_mc.y = (stage.stageHeight - mainmenu_mc.height) ;
    
    function onStageResize(evt:Event):void
    	{
    		preloader_mc.x = ((stage.stageWidth / 2) - (preloader_mc.width / 2)) ;
    		preloader_mc.y = ((stage.stageHeight / 2) - (preloader_mc.height / 2)) ;
    		
    		bg_mc.x = ((stage.stageWidth / 2) - (bg_mc.width / 2)) ;
    		bg_mc.y = ((stage.stageHeight / 2) - (bg_mc.height / 2)) ;
    		
    		mainmenu_mc.x = ((stage.stageWidth / 2) - (mainmenu_mc.width / 2)) ;
    		mainmenu_mc.y = ((stage.stageHeight) - (mainmenu_mc.height)) ;
    		
    	}
    here are the source file : http://www.mediafire.com/?lqeh7pyn0c7tawi

    I apologize if anyone has already made a thread about this, but I'm really in the dark now. Thanks in advance for anyone kind enough to reply to this. Thank you guys.

    All the best
    Last edited by Remelius; 07-21-2011 at 06:35 AM.

Tags for this Thread

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