Jump to content
Search Community

Marcus Aurelius

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by Marcus Aurelius

  1. Im sure I tried that a while back and it didnt work - well I thought id give it another go. public function pageA() { addEventListener(Event.ADDED_TO_STAGE,EnterFrame,false,0,true); } private function EnterFrame(e:Event):void { trace(e.currentTarget); trace(e.currentTarget.parent); trace(e.currentTarget.parent.parent); removeEventListener(Event.ADDED_TO_STAGE,EnterFrame); addChild(pageAmcA); addChild(pageAmcB); addChild(pageAmcC); pageAmcA.alpha = 0; pageAmcA.x = 1500; pageAmcA.y = 0; pageAmcB.alpha = 0; pageAmcB.x = 1500; pageAmcB.y = stage.stageHeight / 2 - pageAmcB.height / 2; pageAmcC.alpha = 0; pageAmcC.x = 1500; pageAmcC.y = stage.stageHeight - pageAmcC.height; } It kinda work, at least im not getting the error anymore and works fine in the mainIndex fla but now when I test it in I.E. the MovieClips are spaced out based on the stage and not the swfContainer_mc stage size.
  2. Hi Greensock, I thought that LoaderMax is doing that. Am I missing some code before the swf's are loaded or something? I did put it in the intro function in the pageA.swf class and it still gave the same error, not sure what Im doing wrong here. Yea Im using the latest version of all greensock classes. Just for curiosity I downloaded it again and put all the files in the com folder but it is still making the same error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.aWebSite.assets.classes::pageA()[C:\AS3 Flash Website Template with external classes\src\com\aWebSite\assets\classes\pageA.as:48]
  3. Hi carl, Its seems your the only on here today. Thank you again for your reply and your comments. Yea sorry for all the code. ok 1 of the main issues Im having is in the child swf in this case I will use pageA.swf: Try changing the position of a MovieClip, in this example Im using pageAmcC pageAmcC.y = 370; Change it to pageAmcC.y = stage.stageHeight - pageAmcC.height; It works fine when I test it in the pageA fla but then when I test it in the mainIndex fla I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.aWebSite.assets.classes::pageA()[C:\AS3 Flash Website Template with external classes\src\com\aWebSite\assets\classes\pageA.as:48] and im not sure why this happening!!
  4. Hi all, I've been trying to make a multiple swf website using LoaderMax and xml file. This is the structure: Im using: Flash Professional CS5 AS3. Greensock Tweening Platform V11. - src\com\greensock\ (folders structure) Julian Kussman Stage Align Tool Class - src\com\juliankussman\ (folders structure) All the Fla's, Swf's and the html are all in the same place - src\ (folders structure) All the swf's are using classes in - com\aWebSite\assets\classes\ (folders structure) The xml file is in - com\aWebSite\assets\data\xml \(folders structure) 1. parent swf* - mainIndex.swf (loads child swf's). 2. child swf's** - pageA.swf, pageB.swf, pageC.swf, pageD.swf, pageE.swf. *mainIndex.swf Im using LoaderMax.getContent to load the xml and SWFLoader ContentDisplay. The ContentDisplay is in a container called swfContainer_mc. 1. when I try and positon things it doesnt seem to position properly. package com.aWebSite.assets.classes { // Flash Classes import flash.display.MovieClip; import flash.display.Shape; import flash.display.Graphics; import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.FullScreenEvent; import flash.events.MouseEvent; // Greensock Tweening Platform V11 import com.greensock.events.LoaderEvent; import com.greensock.loading.display.ContentDisplay; import com.greensock.loading.LoaderMax; import com.greensock.loading.XMLLoader; import com.greensock.loading.ImageLoader; import com.greensock.loading.SWFLoader; import com.greensock.TweenMax; import com.greensock.easing.*; // Julian Kussman Stage Align Tool Class import com.juliankussman.classes.StageAlignTool; // Asual swfaddress class for deep linking import com.asual.swfAddress.actionScript.*; // Pixelbreaker class for mac mouse scroll import com.pixelbreaker.ui.osx.MacMouseWheel; //----------------------------------------------mainIndex class----------------------------------------------// public class mainIndex extends MovieClip { private var swfArray:Array = new Array(); private var buttonsArray:Array = new Array(); private var xml:XML; private var swf:MovieClip; private var preLoader:Preloader = new Preloader(); private var currentPage:MovieClip = new MovieClip (); private var previousPage:MovieClip = new MovieClip (); private var prevPage:ContentDisplay; private var targetPage:ContentDisplay; private var pageIndex:int; private var targetBtn:MovieClip; private var prevBtn:MovieClip; private var swfContainer_mc:swfContainer = new swfContainer ; private var btnMenuContainer_mc:btnMenuContainer = new btnMenuContainer ; private var buttons:MovieClip = new MovieClip(); private var pages:MovieClip = new MovieClip(); private var pt:PageTitle; private var titleX:Number; private var bar:Shape = new Shape(); private var barFooter:Shape = new Shape(); private var mainBkgrd_mc:mainBkgrd = new mainBkgrd ; private var dur:Number = .5; private var xPos = 20; public function mainIndex() { //-------------------------------------------mainIndex constructor-------------------------------------------// // initial site set-up if (stage == null) { // if stage is null wait till the added to stage event has fired before calling our initial function stage.scaleMode = StageScaleMode.NO_SCALE; stage.align = StageAlign.TOP_LEFT; this.addEventListener(Event.ADDED_TO_STAGE, initSite, false, 0, true); } else { initSite(null); } } //---------------------------------------end of mainIndex constructor----------------------------------------// //--------------------------------------------mainIndex functions--------------------------------------------// private function initSite(e:Event):void { if (this.hasEventListener(Event.ADDED_TO_STAGE)) { //remove listener if it was ever added this.removeEventListener(Event.ADDED_TO_STAGE, initSite); } // instantiate Mac Mouse wheel class MacMouseWheel.setup( this.stage ); // activate Greensocks classes LoaderMax.activate([imageLoader, SWFLoader]); // Julian Kussman StageAlignTool; // align MovieClips from the library to the stage on stage resize // set the minimum page size StageAlignTool.init(stage,800,600); // add mainBkgrd_mc to the stage; addChild(mainBkgrd_mc); // preloader; preLoader.progressText.text = ""; preLoader.childText.text = ""; preLoader.childP.scaleX = 0; preLoader.x = stage.stageWidth / 2; preLoader.y = stage.stageHeight / 2; addChild(preLoader); // position swfContainer_mc swfContainer_mc.x = stage.stageWidth / 2; swfContainer_mc.y = stage.stageHeight / 2; addChild(swfContainer_mc); // position btnMenuContainer_mc btnMenuContainer_mc.x = stage.stageWidth / 2; btnMenuContainer_mc.y = 0; addChild(btnMenuContainer_mc); // position mainBkgrd_mc mainBkgrd_mc.x = 0; mainBkgrd_mc.y = 0; mainBkgrd_mc.scaleX = stage.stageWidth; mainBkgrd_mc.scaleY = stage.stageHeight; drawBar(); drawBarFooter(); // load the xml data var xmlLoader:XMLLoader = new XMLLoader("com/aWebSite/assets/data/xml/nav.xml", { name:"xmlData", container:swfContainer_mc,x: - swfContainer_mc.width / 2,y: - swfContainer_mc.height / 2, maxConnections:1, onProgress:appLoading, onComplete:appLoaded, onChildProgress:childLoading, onChildComplete:childLoaded }); xmlLoader.load(true); } // XMLLoader - onChildProgress:childLoading private function childLoading(e:LoaderEvent):void { preLoader.childP.scaleX = e.target.progress; preLoader.childText.text = "loading " + e.target.name + " page"; } // XMLLoader - onProgress:appLoading private function appLoading(e:LoaderEvent):void { var s:int = int(e.target.progress * 100); preLoader.progressText.text = "progress: " + s.toString() + "%"; } // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); trace(e.target.name + " page"); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); } // XMLLoader - onComplete:appLoaded private function appLoaded(e:LoaderEvent):void { xml = new XML(LoaderMax.getContent("xmlData")); trace(e.target + " is complete!"); trace(e.target.name); trace(xml); preLoader.progressText.text = ""; preLoader.childText.text = ""; TweenMax.to(preLoader.childP, .5, {scaleX:0, ease:Strong.easeIn}); TweenMax.to(preLoader, 1, {alpha:0, onComplete:initApp, onCompleteParams:[swfArray.length]}); } // initApp private function initApp(n:int):void { removeChild(preLoader); var b:MovieClip; for (var i:int = 0; i < n; i++) { b = makeButton(i); buttonsArray[i] = b; buttons.addChild(; buttons.x = stage.stageWidth / 2 - btnMenuContainer_mc.x - buttons.width / 2; buttons.y = 30; } pageIndex = 0; prevPage = ContentDisplay(swfArray[pageIndex]); targetPage = prevPage; prevBtn = MovieClip(buttonsArray[pageIndex]); disable(prevBtn); pt = new PageTitle(); pt.alpha = 0; pt.x = buttons.width; pt.y = 0; pt.pageTitleText.text = " " + String(prevPage.name); buttons.addChildAt(pt, 0); titleX = pt.x; TweenMax.to(pt, 1, {delay: 2.25, alpha:1}); StageAlignTool.registerLocation(swfContainer_mc,StageAlignTool.MC,true); swfContainer_mc.addChild(prevPage); swfContainer_mc.addChild(pages); StageAlignTool.registerLocation(btnMenuContainer_mc,StageAlignTool.TC,true); btnMenuContainer_mc.addChild(buttons); StageAlignTool.registerLocation(mainBkgrd_mc,StageAlignTool.TL,true); //btnMenuContainer_mc.mouseChildren = false; TweenMax.allFrom(buttonsArray, .2, {alpha:0, x:1500}, .25); addEventListener("outro complete", removePage); } // make the bottons from the "Btn" MovieClip in the library private function makeButton(index:int):MovieClip { var _b:MovieClip = new btnMc(); _b.page = ContentDisplay(swfArray[index]); _b.id = index; _b.btnLabel.text = String(_b.page.name); _b.btnLabel.width = _b.btnLabel.textWidth + 40; _b.btnBase.width = _b.btnLabel.width; _b.addEventListener(MouseEvent.MOUSE_DOWN, DOWNCLICK); _b.addEventListener(MouseEvent.ROLL_OVER, ROLLOVER); _b.addEventListener(MouseEvent.ROLL_OUT, ROLLOUT); _b.buttonMode = true; _b.mouseChildren = false; _b.x = xPos + 2; xPos = _b.x + _b.btnBase.width; _b.y = 0; return _b; } private function ROLLOVER(e:MouseEvent):void { targetBtn = MovieClip(e.currentTarget); targetBtn.addEventListener(MouseEvent.ROLL_OUT, ROLLOUT); btnOver(targetBtn); } private function ROLLOUT(e:MouseEvent):void { targetBtn = MovieClip(e.currentTarget); btnOut(targetBtn); } private function btnOver(mc:MovieClip):void { TweenMax.to(mc.btnLabel, .2, {tint:0x333333}); TweenMax.to(mc.btnBase, .2, {tint:0xFF6600}); } private function btnOut(mc:MovieClip):void { TweenMax.to(mc.btnLabel, .2, {removeTint:true}); TweenMax.to(mc.btnBase, .2, {removeTint:true}); } private function DOWNCLICK(e:MouseEvent):void { targetBtn = MovieClip(e.currentTarget); targetPage = targetBtn.page; enable(prevBtn); disable(targetBtn); pageTransition(); btnMenuContainer_mc.mouseChildren = false; trace("btns disabled"); } private function disable(mc:MovieClip):void { mc.mouseEnabled = false; mc.removeEventListener(MouseEvent.ROLL_OUT, ROLLOUT); TweenMax.to(mc.btnLabel, .2, {tint:0xFF6600}); TweenMax.to(mc.btnBase, .2, {tint:0x999999}); } private function enable(mc:MovieClip):void { mc.mouseEnabled = true; TweenMax.to(mc.btnLabel, .2, {removeTint:true}); TweenMax.to(mc.btnBase, .2, {removeTint:true}); } private function pageTransition():void { pt.pageTitleText.text = " " + String(targetPage.name); swfContainer_mc.addChild(targetPage); targetPage.alpha = 0; var pageOut:MovieClip = prevPage.rawContent;//the root of the child swf pageOut.pagesOutroComplete(); TweenMax.to(pt, dur, {delay:dur*0, alpha:0, x:0, motionBlur: true}); } private function removePage(e:Event):void { var pageIn:MovieClip = targetPage.rawContent;//the root of the child swf pageIn.pagesOutro(); swfContainer_mc.removeChild(prevPage); prevBtn = targetBtn; TweenMax.to(prevPage, dur, {delay:dur*1, alpha:0, ease:Cubic.easeIn, onComplete:addPage}); trace("removePage: " + prevPage.name); } private function addPage():void { prevPage = targetPage; TweenMax.to(targetPage, dur, {delay:dur*0.25, alpha:1, ease:Cubic.easeOut, onComplete:introComplete}); trace("addPage: " + targetPage.name); } private function introComplete():void { var pageIn:MovieClip = targetPage.rawContent;//the root of the child swf pageIn.pagesIntro(); TweenMax.to(pt, dur, {delay:dur*2.5, alpha:1, x:titleX, motionBlur:true, onComplete:introCompleted}); trace("introComplete: " + targetPage.name); } private function introCompleted():void { btnMenuContainer_mc.mouseChildren = true; trace("introCompleted: " + targetPage.name); trace("btns enabled"); } private function drawBar():void { var duration:Number = 0.75; var g:Graphics = bar.graphics; g.beginFill(0xFF9900, 1); g.drawRect(0,0,stage.stageWidth, 30); g.endFill(); bar.alpha = 1; bar.scaleX = stage.stageWidth; //TweenMax.to(bar, duration, {delay:duration*0.25, alpha:1, width:stage.stageWidth, ease:Expo.easeOut}); addChild(bar); } private function drawBarFooter():void { var gr:Graphics = barFooter.graphics; gr.beginFill(0x0099FF, 1); gr.drawRect(0,0,stage.stageWidth, 30); gr.endFill(); barFooter.alpha = 1; barFooter.y = stage.stageHeight - barFooter.height; barFooter.scaleX = stage.stageWidth; addChild(barFooter); } //-----------------------------------------end of mainIndex functions-----------------------------------------// //-------------------------------------------end of mainIndex class-------------------------------------------// } //-----------------------------------------------end of package-----------------------------------------------// } xml: <?xml version="1.0" encoding="UTF-8"?> <nav> <item title="Welcome"> <SWFLoader load="true" name="Welcome" centerRegistration = "true" url="pageA.swf"/> </item> <item title="About Us"> <SWFLoader load="true" name="About Us" centerRegistration = "true" url="pageB.swf"/> </item> <item title="Services"> <SWFLoader load="true" name="Services" centerRegistration = "true" url="pageC.swf"/> </item> <item title="Portfolio"> <SWFLoader load="true" name="Portfolio" centerRegistration = "true" url="pageD.swf"/> </item> <item title="Contact Us"> <SWFLoader load="true" name="Contact Us" centerRegistration = "true" url="pageE.swf"/> </item> </nav> **pageA.swf 1. It all appears to be working but when I try and position a MovieClip in the child swf with stage.stageWidth and stage.stageHeight the parent swf throws an error: TypeError: Error #1009: Cannot access a property or method of a null object reference. package com.aWebSite.assets.classes { // Flash Classes import flash.display.MovieClip; import flash.display.Shape; import flash.display.Graphics; import flash.display.StageScaleMode; import flash.display.StageAlign; import flash.display.DisplayObject; import flash.events.Event; import flash.events.EventDispatcher; import flash.events.FullScreenEvent; import flash.events.MouseEvent; // Greensock Tweening Platform V11 import com.greensock.events.LoaderEvent; import com.greensock.loading.display.ContentDisplay; import com.greensock.loading.LoaderMax; import com.greensock.loading.XMLLoader; import com.greensock.loading.ImageLoader; import com.greensock.loading.SWFLoader; import com.greensock.TweenMax; import com.greensock.easing.*; public class pageA extends MovieClip { private var pageAmcA:pageAmcA_mc = new pageAmcA_mc (); private var pageAmcB:pageAmcB_mc = new pageAmcB_mc (); private var pageAmcC:pageAmcC_mc = new pageAmcC_mc (); public function pageA() { addChild(pageAmcA); addChild(pageAmcB); addChild(pageAmcC); pageAmcA.alpha = 0; pageAmcA.x = 1500; pageAmcA.y = 0; pageAmcB.alpha = 0; pageAmcB.x = 1500; pageAmcB.y = 185; pageAmcC.alpha = 0; pageAmcC.x = 1500; pageAmcC.y = 370; //pagesIntro(); addEventListener(Event.ADDED_TO_STAGE,EnterFrame,false,0,true); } private function EnterFrame(e:Event):void { trace(e.currentTarget); trace(e.currentTarget.parent); trace(e.currentTarget.parent.parent); removeEventListener(Event.ADDED_TO_STAGE,EnterFrame); } public function pagesIntro():void { TweenMax.to(pageAmcA,1,{delay:2,alpha:1,x:0}); TweenMax.to(pageAmcB,1,{delay:2.25,alpha:1,x:0}); TweenMax.to(pageAmcC,1,{delay:2.5,alpha:1,x:0}); trace("pageA: Intro"); } public function pagesOutro():void { TweenMax.to(pageAmcA,0.5,{delay:0.25,alpha:0,x:1500}); TweenMax.to(pageAmcB,0.5,{delay:0.5,alpha:0,x:1500}); TweenMax.to(pageAmcC,0.5,{delay:0.75,alpha:0,x:1500}); trace("pageA: Outro"); } public function pagesOutroComplete():void { TweenMax.to(pageAmcA,1,{delay:0.25,alpha:0,x:1500}); TweenMax.to(pageAmcB,1,{delay:0.5,alpha:0,x:1500}); TweenMax.to(pageAmcC,1,{delay:0.75,alpha:0,x:1500,onComplete:outroCompleted}); trace("pageA: OutroComplete"); } public function outroCompleted():void { dispatchEvent(new Event("outro complete",true)); trace("pageA: outroCompleted"); } } } What am I doing wrong?? Sorry if there is loads of code I will post the files i have with the exception of greensock.
×
×
  • Create New...