help with script

Discussion in 'Web Design and Development' started by phadam, Jun 1, 2009.

  1. phadam macrumors regular

    Joined:
    Jan 21, 2009
    #1
    im having some issues with my script. im completely new to this so I expected mistakes. now im just trying to learn from them.

    could someone take a look at my script and layout for me and tell me what I am doing wrong or help me fix it???? i couldn't att a fla file here :(
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    You can either zip the file and attach that, or change the extension on the file to .txt and just not in the post to change it back to .fla before opening.
     
  3. phadam thread starter macrumors regular

    Joined:
    Jan 21, 2009
    #3
    here is a zip

    thanks!!
     

    Attached Files:

  4. phadam thread starter macrumors regular

    Joined:
    Jan 21, 2009
  5. snickelfritz macrumors 65816

    snickelfritz

    Joined:
    Oct 24, 2003
    Location:
    Tucson AZ
    #5
    I rebuilt the fla and simplified the actionscript to work with a single reusable function, a variable, an Array, and a for..loop.
    It might seem a bit complicated at first, but it's actually vastly simpler than using frame labels and separate functions for each button.

    The project is now composed of (2) swf files:
    main.swf - this does nothing but load the content.swf
    content.swf - this contains all visual assets and actionscript for your site.​

    Here's the script from the main.swf:
    This loads the content swf and includes a progress indicator.
    Code:
    stage.scaleMode = StageScaleMode.NO_SCALE;
    
    var loader:Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
    
    function onLoaded(e:Event):void
    {
    	removeChild(preloader);
    	preloader = null;
    	addChild(loader.content);
    }
    
    function onProgress(e:ProgressEvent):void
    {
    	var percentage:Number = e.bytesLoaded / e.bytesTotal;
    	preloader.preloaderText.text = Math.ceil(percentage * 100).toString() + "%";
    }
    
    loader.load(new URLRequest("content.swf"));
    
    Here's the script from the content.swf:
    Code:
    stop();
    
    var frameNum:Number;
    var btnLabels:Array = 
    [
    "Home",
    "About",
    "Print Design",
    "Digital Arts",
    "Media",
    "Contact"
    ];
    
    for (var i:Number = 0; i < btnGroup.numChildren; i++)
    {
    	var btn:MovieClip = MovieClip(btnGroup.getChildAt(i));
    	btn.id = i;
    	btn.buttonMode = true;
    	btn.mouseChildren = false;
    	btn.btnLabel.text = String(btnLabels[i]);
    	btn.addEventListener(MouseEvent.CLICK, btnClick, false, 0, true);
    }
    
    function btnClick(e:MouseEvent):void
    {
    	frameNum = e.target.id + 1;
    	gotoAndStop(frameNum)
    }
    
     

    Attached Files:

  6. phadam thread starter macrumors regular

    Joined:
    Jan 21, 2009
    #6
    took me a min to actually understand what you did there and how it all functions. looks great! I really appreciate the help on this. Thanks so much :D
     

Share This Page