LetsFlex

Module Loader

by sucka on Dec.17, 2008, under Actionscript

Here is a quick and easy way of using ModuleLoader to load other sections of your “site”, just remember that the modules that you are loading are not any ol’ regular swfs like the ones that you can export from flash, they are modules specifically for the ModuleLoader.

 

MXML File

<?xml version="1.0" encoding="utf-8"?>
	<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
		layout="absolute"
		themeColor="#FF6600"
		backgroundGradientAlphas="[1.0, 1.0]"
		backgroundGradientColors="[#222222, #444444]">

	<mx:Script>
		<![CDATA[
			import mx.controls.Alert;
			import mx.controls.buttonBarClasses.ButtonBarButton;
			import mx.events.ItemClickEvent;
			import mx.utils.ObjectUtil;

			private function buttonBar_itemClick(evt:ItemClickEvent):void {
				if (evt.label == "Home") {
					modLoader.url = "Page01.swf";
			}

			if (evt.label == "About") {
				modLoader.url = "Page02.swf";
			}

			if (evt.label == "Contact") {
				modLoader.url = "Page03.swf";
			}
		}
		]]>
	</mx:Script>

	<mx:Array id="arr">
		<mx:Object label="Home" page="Page01.swf" />
		<mx:Object label="About" page="Page02.swf" />
		<mx:Object label="Contact" page="Page03.swf" />
	</mx:Array>

	<mx:Label y="19" text="Mini Site" color="#FF6600" fontWeight="bold" fontSize="20" horizontalCenter="-150"/>

	<mx:ToggleButtonBar id="buttonBar"
		dataProvider="{arr}"
		itemClick="buttonBar_itemClick(event);"
		horizontalCenter="73"
		top="22"
		width="254"/>

	<mx:ModuleLoader id="modLoader"
		url="Page01.swf"
		backgroundColor="#EEEEEE"
		horizontalCenter="0"
		top="50"
		width="400" height="300"/>

</mx:Application>
	
:
No comments for this entry yet...

Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

Archives

All entries, chronologically...