Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

phadam

macrumors regular
Original poster
Jan 21, 2009
123
0
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 :(
 
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.
 
here is a zip

thanks!!
 

Attachments

  • gvweb2.1.txt.zip
    434.9 KB · Views: 80
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)
}
 

Attachments

  • phadam_frameNav.zip
    497.4 KB · Views: 69
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.