Jump to content
Search Community

Marcus Aurelius

Members
  • Posts

    29
  • Joined

  • Last visited

Everything posted by Marcus Aurelius

  1. I would of replied sooner but Ive been having trouble with "greensock.loading.display.ContentDisplay" where i have swf's loaded into a sprite that reference the ContentDislay (var swf:ContentDisplay = e.target.content as ContentDisplay) onto a stage of 800px wide and 550px high, but when I put a trace on the sprite's width holding the swf's the is width is 1709px and I cant figure that out. (sorry, I might be better to open a new thread for that, just been working on it all day and totally frustrated). OOpps I forgot to change that. The "Number" i was using for a different "if" statement e.g. "xPos += useHeaderImage && !useHeaderBkgrd ? Number (xml.mainPage.header.Height) : 0;" and for got to take that off. Does the XMLLoader automatically parse the xml file data or do i have to use "parseInt" or parse any xml data? or can I just use any path e.g. "xml.mainPage.headerSpacer.x" or "xml.mainPage.headerSpacer.bkgrdColor" which would have this result. <x>0</x> <bkgrdColor>0xff6699</bkgrdColor> I dont get any errors and it returns the correct values.
  2. I was wondering how LoaderMax, XMLLoader or other loaders parse data? I have got a fare way into setting up a fullscreen website project and have been using variables to parse data from an xml file(for example) : // headerSpacer Variables private var headerSpacerSpt:Sprite = new Sprite(); private var useHeaderSpacer:Boolean; private var headerSpacerSptX:int; private var headerSpacerSptY:int; private var headerSpacerSptHeight:int; private var headerSpacerSptAlpha:Number; private var headerSpacerSptColor:uint; // Create headerSpacer private function makeHeaderSpacer():void { useHeaderSpacer = stringToBoolean(xml.mainPage.headerSpacer.useBkgrd.text()); headerSpacerSptX = parseInt(xml.mainPage.headerSpacer.x); headerSpacerSptY = parseInt(xml.mainPage.headerSpacer.y); headerSpacerSptHeight = parseInt(xml.mainPage.headerSpacer.Height); headerSpacerSptAlpha = Number (xml.mainPage.headerSpacer.bkgrdAlpha); headerSpacerSptColor = uint(xml.mainPage.headerSpacer.bkgrdColor); if (useHeaderSpacer) { var headerSpacerBar:Graphics = headerSpacerSpt.graphics; headerSpacerBar.beginFill(headerSpacerSptColor,headerSpacerSptAlpha); headerSpacerBar.drawRect(0,0,maxWidth,headerSpacerSptHeight); headerSpacerBar.endFill(); addChild(headerSpacerSpt); headerSpacerSptX = Number(xml.mainPage.headerSpacer.x); headerSpacerSptY = Number(xml.mainPage.headerSpacer.y); headerSpacerSpt.x = headerSpacerSptX; headerSpacerSpt.y = headerSpacerSptY; headerSpacerSpt.scaleX = maxWidth; } } When I noticed that if I just put the path e.g. xml.mainPage.headerSpacer.x I get the same result if I was to put e.g. private var headerSpacerSptX:int; headerSpacerSptX = parseInt(xml.mainPage.headerSpacer.x); headerSpacerSptX = Number(xml.mainPage.headerSpacer.x); headerSpacerSpt.x = headerSpacerSptX; So I guess my question is: Has LoaderMax or the XMLLoader already parsed the xml data through: // load the xml data var xmlLoader:XMLLoader = new XMLLoader("com/siteA/assets/data/xml/config.xml",{name:"xmlData", requireWithRoot:this.root, container:swfContainer, maxConnections:1, estimatedBytes:10000, onProgress:appLoading, onComplete:appLoaded, onChildProgress:childLoading, onChildComplete:childLoaded}); XML.ignoreWhitespace = true; xmlLoader.load(true); // XMLLoader - onComplete:appLoaded private function appLoaded(e:LoaderEvent):void { xml = new XML(LoaderMax.getContent("xmlData")); } or do I need to put all that extra code to parse the data.
  3. The other part Im am using a Boolean statement inside the document class so I can have a .jpg or .swf. xml: <!-- Logo Setup --> <logo> <logoX>5</logoX> <logoY>5</logoY> <useImage>true</useImage> <useSwf>false</useSwf> <ImageLoader url="com/siteA/assets/images/logos/ivanko_logo.png" name="logoImage" estimatedBytes = "8000" load="true" alpha="1"/> <SWFLoader url="logo.swf" name="logoSwf" estimatedBytes = "8000" load="true" alpha="1"/> </logo> AS3: // Logo Variables private var logoX:int; private var logoY:int; private var useImageLogo:Boolean; private var useSwfLogo:Boolean; private var logoImageSpt:Sprite = new Sprite(); private var logoSwfSpt:Sprite = new Sprite(); useImageLogo = stringToBoolean(xml.mainPage.logo.useImage.text()); useSwfLogo = stringToBoolean(xml.mainPage.logo.useSwf.text()); if (useImageLogo) { addChild(logoImageSpt); var logoImage:ContentDisplay = LoaderMax.getContent("logoImage"); logoImageSpt.addChild(logoImage); trace("logoImage :" + " LOADED"); } else if (useSwfLogo) { addChild(logoSwfSpt); var logoSWF:ContentDisplay = LoaderMax.getContent("logoSwf"); logoSwfSpt.addChild(logoSWF); trace("logoSWF :" + " LOADED"); } logoX = parseInt(xml.mainPage.logo.logoX); logoY = parseInt(xml.mainPage.logo.logoY); logoImageSpt.x = logoX; logoImageSpt.y = logoY; logoSwfSpt.x = logoX; logoSwfSpt.y = logoY; Its all seems to be working ok at the moment. I will post/update the attached files on the "Loading Multiple swf's with page transitions" thread as it is an on-going project, if thats ok?
  4. Ok, I will try and simplify this. 1. in the main document class I have: var swfArray:Array = new Array(); var swf:Sprite; var prevPage:ContentDisplay; var targetPage:ContentDisplay; var pages:MovieClip = new MovieClip(); var currentPage:MovieClip = new MovieClip(); var previousPage:MovieClip = new MovieClip(); var pageIndex:int; // load the xml data var xmlLoader:XMLLoader = new XMLLoader("com/siteA/assets/data/xml/config.xml",{name:"xmlData", requireWithRoot:this.root, container:swfContainer_mc, maxConnections:1, estimatedBytes:10000, onChildComplete:childLoaded }); XML.ignoreWhitespace = true; xmlLoader.load(true); // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is LoaderMax) { trace("this is a LoaderMax: " + e.target); } else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); } } // add swfContainer_mc to the stage addChild(swfContainer_mc); // position swfContainer_mc swfContainer_mc.x = maxWidth / 2 - minWidth / 2; swfContainer_mc.y = maxHeight / 2 - minHeight / 2; pageIndex = 0; prevPage = ContentDisplay(swfArray[pageIndex]); targetPage = prevPage; The swfArray is being used for the pages (Welcome, About Us, Services e.t.c.) in the xml file. So what ever SWFLoaders I have in the xml file it will add them to the swfArray. So if I wanted to load a logo swf in a different mc it wont work because of the array. I have had a break through from a very kind gentleman at actionscript.org. It was to do with the SWFLoaderVars but I couldnt figure out how to get it to work. But he has got it to work. This is the code that I was missing; else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; var swfLoader:SWFLoader = LoaderMax.getLoader(e.target.name); if (swfLoader.vars.array) { swfArray.push(swf); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace(swfLoader.vars.array); } else { //trace(e.target.url + " = " + e.target.name + " page"); trace("this is an swf: " + e.target); }
  5. How would I use a custom node in the SWFLoader for example: xml: <page title="Welcome"> <SWFLoader name="Welcome" url="pageA.swf" estimatedBytes = "99999" load="true" requireWithRoot = "true" array="true" alpha="1"/> </page> and in the function: else if (e.target is SWFLoader) { if(array== true)// node inside xml SWFLoader's { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); } else { trace(e.target.url + " = " + e.target.name + " page"); trace("this is an swf: " + e.target); } This might be a solution.
  6. But I dont know how to get the <swfPages></swfPages> <page></page> node instead of the SWFLoader?
  7. I have tried everything but I still cant get it to work, my latest attempt was to put this code into the child complete function: // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is LoaderMax) { trace("this is a LoaderMax: " + e.target); else if (e.target is SWFLoader) { xml = e.target.content; var swf:ContentDisplay = e.target.content as ContentDisplay; var swfData:XMLList = xml.swfPages.page; for each (var page:XML in swfData) { }trace("SWF Name: " + page.@name); swfArray.push(page.@name); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace(e.target.url + " = " + e.target.name + " page"); trace("this is an swf: " + e.target); } } but I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert com.greensock.loading.display::ContentDisplay@258fa741 to XML. I dont know what else to do.
  8. Ok I have had another look at it and I cant figure out how to do it. I can do it using normal flash loaders e.g.: xml: <?xml version="1.0" encoding="utf-8"?> <configSettings> <!-- MAIN PAGE CONFIGURATION SETTINGS --> <mainPage> <!-- Logo Setup --> <logo></logo> <!-- header Setup --> <header></header> <!-- footer Setup --> <footer></footer> </mainPage> <!-- END OF MAIN PAGE CONFIGURATION SETTINGS --> <!-- Swf page Setup --> <swfPages> <!-- Welcome page --> <page title="Welcome"> <url>pageA.swf</url> </page> <!-- About Us page --> <page title="About Us"> <url>pageB.swf</url> </page> <!-- Services page --> <page title="Services"> <url>pageC.swf</url> </page> <!-- Portfolio page --> <page title="Portfolio"> <url>pageD.swf</url> </page> <!--Contact Us page --> <page title="Contact Us"> <url>pageE.swf</url> </page> </swfPages> </configSettings> AS3: import flash.display.*; import flash.events.*; import flash.net.*; var xml:XML; var xmlLoader:URLLoader = new URLLoader(); var swfArray:Array = new Array(); //Adding an event listener to notify when loading is completed xmlLoader.addEventListener(Event.COMPLETE, LoadXML); //Load the XML file; xmlLoader.load(new URLRequest("config.xml")); function LoadXML(e:Event):void { var i:Number; var totalSwfs:Number; xml = new XML(e.target.data); totalSwfs = xml.configSettings.swfPages.length(); for (i = 0; i < totalSwfs; i+=1) { swfArray.push( {title: xml.configSettings.swfPages[i].page.toXMLString(), url: xml.configSettings.swfPages[i].url.toString()} ); } trace (xml); } but I cant seem to get it to work with the XMLLoader... My problem I think has to do with how the swf pages and btns are calling the content display: AS: // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is LoaderMax) { trace("this is a LoaderMax: " + e.target); } else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace(e.target.url + " = " + e.target.name + " page"); trace("this is an swf: " + e.target); } else if (e.target is ImageLoader) { trace("this is a image: " + e.target); } } var pageIndex:int; pageIndex = 0; prevPage = ContentDisplay(swfArray[pageIndex]); targetPage = prevPage; prevBtn = MovieClip(buttonsArray[pageIndex]); 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; } But again not sure how to resolve it.
  9. Ok I put the code in the xml file (not all the data is here just to save over coding this post): <!-- Logo Setup --> <logo> <useImage>false</useImage> <useSwf>true</useSwf> <ImageLoader url="com/siteA/assets/images/logos/ivanko_logo.png" name="logoImage" estimatedBytes = "8000" load="true"/> <SWFLoader url="com/siteA/assets/swfs/logo.swf" name="logoSWF" estimatedBytes = "4000" load="false"/> </logo> <logoX>5</logoX> <logoY>5</logoY> </logo> and my AS is this: useImageLogo = stringToBoolean(xml.mainPage.logo.useImage.text()); useSwfLogo = stringToBoolean(xml.mainPage.logo.useSwf.text()); if(useImageLogo) { addChild(logoImageSpt); var logoImage:ContentDisplay = LoaderMax.getContent("logoImage"); logoImageSpt.addChild(logoImage); } else if (useSwfLogo) { addChild(logoSwfSpt); var logoSWF:ContentDisplay = LoaderMax.getContent("logoSwf"); logoSwfSpt.addChild(logoSWF); } logoX = parseInt(xml.mainPage.logo.logoX); logoY = parseInt(xml.mainPage.logo.logoY); logoImageSpt.x = logoX; logoImageSpt.y = logoY; logoSwfSpt.x = logoX; logoSwfSpt.y = logoY; This is an extension of my other work and its not working probably because I have other swf being loaded in a array and the array tries to get the logo swf also: I dont know how to stop the swf array using the logo swf. this is part code for swf arrays e.t.c. // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is LoaderMax) { trace("this is a LoaderMax: " + e.target); } else if (e.target is CSSLoader) { trace("this is a css: " + e.target); } else if (e.target is XMLLoader) { trace("this is a xml: " + e.target); } else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace(e.target.url + " = " + e.target.name + " page"); trace("this is an swf: " + e.target); } else if (e.target is ImageLoader) { trace("this is a image: " + e.target); } } // XMLLoader - onComplete:appLoaded private function appLoaded(e:LoaderEvent):void { xml = new XML(LoaderMax.getContent("xmlData")); styles = LoaderMax.getContent("customCSS"); parseFile(LoaderMax.getContent("xmlData")); 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]}); trace("xml and css loaded"); trace(LoaderMax.getContent("customCSS")); trace(e.target + ", is complete!"); trace(e.target.content + ", is complete!"); }
  10. Hi guys, Ive been trying to figure out how set an image or swf via xml data with XMLLoader: xml: <?xml version="1.0" encoding="UTF-8"?> <configSettings> <!-- MAIN PAGE CONFIGURATION SETTINGS --> <mainPage> <!-- Logo Setup --> <logo> <useImage>true</useImage> <useSwf>false</useSwf> <logoImageUrl><ImageLoader url="com/siteA/assets/images/logos/ivanko_logo.png" name="logoImage" estimatedBytes = "8000" container= "this"load="true"/></logoImageUrl> <logoSwfUrl></logoSwfUrl> <logoX>5</logoX> <logoY>5</logoY> </logo> </mainPage> </configSettings> This is the AS3 code (Im using lots of code and wont add it all, so hope you get the idea?): package { // Flash Classes import flash.display.*; import flash.geom.*; import flash.text.*; import flash.utils.getDefinitionByName; import flash.utils.getQualifiedClassName; import flash.events.* // Greensock Tweening Platform V11 import com.greensock.*; // activate Greensocks classes; LoaderMax.activate([LoaderMax, CSSLoader, XMLLoader, SWFLoader, ImageLoader]); //----------------------------------------------mainIndex class----------------------------------------------// public class mainIndex extends MovieClip { // XML Variables private var xml:XML; // Logo Variables private var logoX:int; private var logoY:int; private var logoWidth:int; private var logoHeight:int; private var useImageLogo:Boolean; private var useSwfLogo:Boolean; private var logoImageUrl:String; private var logoSwfUrl:String; private var logoSWF:MovieClip; private var logoContainer:Sprite = new Sprite(); public function mainIndex():void { addChild(logoContainer); logoImageUrl = xml.mainPage.logo.logoImageUrl.text(); logoSwfUrl = xml.mainPage.logo.logoSwfUrl.text(); useImageLogo = stringToBoolean(xml.mainPage.logo.useImage.text()); useSwfLogo = stringToBoolean(xml.mainPage.logo.useSwf.text()); if(useImageLogo) { logoImageUrl; } else { logoSwfUrl; } logoX = parseInt(xml.mainPage.logo.logoX); logoY = parseInt(xml.mainPage.logo.logoY); } public static function stringToBoolean($string:String):Boolean { return ($string.toLowerCase() == "true" || $string.toLowerCase() == "1"); } Any help would be great.
  11. Many thanks Carl, That worked great. It surely is simple when you know how.
  12. Hi, I'm not sure if this is a Greensock question or a AS3 question. I was wondering how to tile a background using an image pulled from an xml file e.g. xml file: <?xml version="1.0" encoding="UTF-8"?> <configSettings> <ImageLoader url="com/siteA/assets/images/footerBar.png" name="footerImage" estimatedBytes = "1000" container= "this" load="true"/> </configSettings> AS3 code: var footerImage:ContentDisplay = LoaderMax.getContent("footerImage"); footerContainer = new Sprite(); footerContainer.graphics.beginBitmapFill("footerImage"); footerContainer.graphics.drawRect(0, 0, stage.stageWidth, footer.height); footerContainer.graphics.endFill(); footer.addChild(footerContainer); This doesnt work for some reason. There is obviously a lot more code but hope you get the idea. This is how I would do it if the image was in the Library: var footerContainer:Sprite; var footerImage:BitmapData = new tileImg(0,0); footerContainer = new Sprite(); footerContainer.graphics.beginBitmapFill(footerImage); footerContainer.graphics.drawRect(0, 0, stage.stageWidth, footerImage.height); footerContainer.graphics.endFill(); addChild(footerContainer); But cant seem to figure it out using XMLLoader e.t.c.
  13. Here is an updated version with help from Carl Schooff (thank you Carl) includes CSS, XML data and embedded fonts. Hope it helps someone. Oh and if there are any developers who would like to clean up my code by all means please feel free, as I'm sure it needs it. Anyways here are the files, you just need to add greensock to the com folder. AS3 Flash Website Template with external classes update.zip
  14. Yes I wondered if it was something you might not normally assist with but after much searching I found what I was looking for. If you dont do the following and try and embed the font it will not show. It appears to be a very common problem. This is the link where I found the solution http://www.dotstrosi...ally-different/ This is for fonts in the library, I couldnt get loading a swf for font/s to work for me. Here is the AS3 code : import flash.utils.getDefinitionByName; public class mainIndex extends MovieClip { // register fonts Font.registerFont(getDefinitionByName("accidentalPresidency") as Class); Font.registerFont(getDefinitionByName("gunPlay") as Class); } and this is the code for the css : c1 { font-family: Accidental Presidency; font-size:20px; letter-spacing:1; color: #ff6699; } c2 { font-family: Gunplay; font-size:14px; letter-spacing:5; color: #33ccff; } Many thanks for all your though Carl, very much appreciated.
  15. I have come across a problem with embedding the dynamic text field fonts, as it is still part of the post I wasnt sure wheather to post it here or start a new thread? When I embed the font lets say in the contentText.embedFonts = true; the text isnt visible. I have tried to embed the font via linkage in the mainIndex.fla but still doesnt work. I did try using an swf for the font but couldnt get that to work either. Let me know if I need to start a new thread of if its ok to keep it here? Kind regards Marcus
  16. No it is all working ok at the moment. Its understanding how the XMLLoader works when using a xml file to load data. I get confused with all the LoaderMax .getContent, .getData e.t.c. stuff. Im getting there very slowly. You posted a link to another thread where greensock suggested using: // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is CSSLoader) { trace("this is a css: " + e.target); } else if (e.target is XMLLoader) { trace("this is an xml: " + e.target); } else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); trace(e.target.url + " = " + e.target.name + " page"); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace("this is an swf: " + e.target); } } Its knowing how to use XMLLoader e.t.c. and how they all work I guess. In the examples here on greensock and in the api docs it shows you how to code it in flash, which I understand but when it comes to using the xml file I get confused and really not sure how to code things. My aim is to make the whole site as dynamic as possible. And Im trying to structure it like so: 1. have all the mainIndex data, images e.t.c. animate/fade in first (all via 1 xml file. which Im not sure is the right way). 2. then have the first swf animate in while the other swf's load in the background. A bit like a splash screen but Im not sure how to code it as Ive said Im not very good with AS3. Because im self teaching I dont know the right and wrong ways of doing things.
  17. But I cant seem to get this to work: // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is CSSLoader) { trace("this is a css: " + e.target); } else if (e.target is XMLLoader) { trace("this is an xml: " + e.target); } else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); trace(e.target.url + " = " + e.target.name + " page"); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace("this is an swf: " + e.target); } }
  18. Ok i found out how to do it, I was putting things in the wrong place. // this goes in the class private var header:headerContainer = new headerContainer(); // this goes inside the initSite private function initSite(e:Event):void { // add header to the stage addChild(header); header.x = 0; header.y = 0; // load the xml data var xmlLoader:XMLLoader = new XMLLoader("com/siteA/assets/data/xml/config.xml", { name:"xmlData", requireWithRoot:this.root, container:swfContainer_mc, maxConnections:1, estimatedBytes:10000, onProgress:appLoading, onComplete:appLoaded, onChildProgress:childLoading, onChildComplete:childLoaded }); XML.ignoreWhitespace = true; xmlLoader.load(true); } // XMLLoader - onComplete:appLoaded private function appLoaded(e:LoaderEvent):void { xml = new XML(LoaderMax.getContent("xmlData")); trace("xml and css loaded"); trace(LoaderMax.getContent("customCSS")); styles = LoaderMax.getContent("customCSS"); parseFile(LoaderMax.getContent("xmlData")); trace(e.target + ", is complete!"); trace(e.target.content + ", is complete!"); 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]}); } it wasnt working because I was referencing: parseFile(xml.content); instead of: parseFile(LoaderMax.getContent("xmlData"));
  19. Hi Carl, Ok, Im trying to put your code with the code I have, but I cant get it to work! my xml file: <?xml version="1.0" encoding="UTF-8"?> <configSettings> <mainPage> <content><![CDATA[<c1>This is a content text box</c1> <c2>more text than you can shake a stick at when living in the woods</c2> <c3>Another text field with css and xml which is selectable to</c3> <c4>and another one for good luck</c4>]]> </content> </mainPage> <CSSLoader url="com/siteA/assets/data/css/sample.css" name="customCSS" load="true"/> <page title="Welcome"> <SWFLoader name="Welcome" url="pageA.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="About Us"> <SWFLoader name="About Us" url="pageB.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="Services"> <SWFLoader name="Services" url="pageC.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="Portfolio"> <SWFLoader name="Portfolio" url="pageD.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="Contact Us"> <SWFLoader name="Contact Us" url="pageE.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> </configSettings> and my AS3 Code: // XML Variables var xml:XML; // CSS Variables var styles:StyleSheet = new StyleSheet(); // Arrays var swfArray:Array = new Array(); // load the xml data var xmlLoader:XMLLoader = new XMLLoader("com/siteA/assets/data/xml/config.xml", { name:"xmlData", requireWithRoot:this.root, container:swfContainer_mc, maxConnections:1, estimatedBytes:10000, onProgress:appLoading, onComplete:appLoaded, onChildProgress:childLoading, onChildComplete:childLoaded }); xmlLoader.load(true); // XMLLoader - onChildComplete:childLoaded private function childLoaded(e:LoaderEvent):void { if (e.target is CSSLoader) { trace("this is a css: " + e.target); } else if (e.target is XMLLoader) { trace("this is an xml: " + e.target); } else if (e.target is SWFLoader) { var swf:ContentDisplay = e.target.content as ContentDisplay; swfArray.push(swf); trace(e.target.url + " = " + e.target.name + " page"); currentPage = e.target.rawContent; previousPage = e.target.rawContent; currentPage.pagesIntro(); trace("this is an swf: " + e.target); } } // XMLLoader - onComplete:appLoaded private function appLoaded(e:LoaderEvent):void { xml = new XML(LoaderMax.getContent("xmlData")); trace("xml and css loaded"); trace(LoaderMax.getContent("customCSS")); parseFile(xml.content); styles = LoaderMax.getContent("customCSS"); 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]}); } Not sure what Im doing wrong.
  20. Hi carl, Thank you again. I would of replied sooner but my internet was down. Ok that looks quite simply enough, guess its easier when you know how. So now lets say I have a image to load as well as the css and I want them to load in sequence e.g. load css wait until it has loaded then load the image.
  21. Ok Ive managed to create some text fields with css and xml and cdata but I still cant figure out how to do the same using XMLLoader and LoaderMax. Anyone have any suggestions pretty please. Here are the files of what I have using flash loaders..... xml & css.zip
  22. Hi carl, I do apologise Im not always good at explaining myself. I do understand how the css and xml works in my previous thread now. My problem is that Im trying to apply things without understanding the structure of the code. Because I have been concentrating on loading swf's and getting them to animate in and out, I didnt set up the mainIndex swf first and have objects do things first before the swf' are visible. Ok I think I'll start from the beginning (As I have said recently I am not at all experienced with writting AS3 and LoaderMax e.t.c. but I am trying.):- Lets say I have a text field on stage that I want to apply css and xml data to through LoaderMax. How do I do it? This is how one could do it normally, using flash class files: new fla called "xml & css" for example, with a MovieClip in the library called "content_mc" with a linkage of "content_mc". css: h1 { font-family:Arial, Helvetica, sans-serif; font-size:20px; color: #ff6699; font-weight: bold; } h2 { font-family:Arial, Helvetica, sans-serif; font-size:15px; color: #33ccff; } h3 { font-family:Arial, Helvetica, sans-serif; font-size:24px; color: #ff6600; font-weight: bold; } h4 { font-family:Arial, Helvetica, sans-serif; font-size:12px; color: #ff3366; } xml: <?xml version="1.0" encoding="utf-8"?> <configSettings> <mainPage> <content><![CDATA[<h1>This is a header text box</h1> <h2>This is a footer text box</h2> <h3>Another text field with css and xml</h3> <h4>and another one for good luck</h4>]]></content> </mainPage> </configSettings> and AS3 code: import flash.display.MovieClip; import flash.display.*; import flash.text.TextFormat; import flash.text.AntiAliasType; var container:content_mc = new content_mc(); // Set up the xml file objects var xmlData:XML = new XML(); XML.ignoreWhitespace = true; var xmlLoader:URLLoader = new URLLoader(); // CSS external document var cssLoader:URLLoader = new URLLoader(); var cssRequest:URLRequest = new URLRequest("css/sample.css"); var styles:StyleSheet = new StyleSheet(); cssLoader.load(cssRequest); cssLoader.addEventListener(Event.COMPLETE, onCSSComplete); function onCSSComplete(e:Event):void { styles.parseCSS(cssLoader.data); xmlLoader.load(new URLRequest("xml/xml.xml")); xmlLoader.addEventListener(Event.COMPLETE, LoadXML); trace("CSS has loaded."); } function LoadXML(e:Event):void { xmlData = new XML(e.target.data); parseFile(xmlData); } function parseFile(xmlContent:XML):void { stage.addChild(container); var contents:TextField = new TextField(); contents.styleSheet = styles; contents.htmlText = xmlContent.mainPage.content.text(); contents.width = 400; contents.x = 10; contents.y = 10; //contents.embedFonts = true; contents.antiAliasType = "advanced"; contents.multiline = true; contents.autoSize = "left"; contents.wordWrap = true; container.addChild(contents); } but I cant figure out how to this with LoaderMax and a xml file
  23. I was wondering how to load more than one loader via xml? Im using a xml file which has a SWFLoader loading extenal swf's but I want to add other loaders for the mainIndex.swf before the SWFLoader loads the swf's. This is the xml file code: <?xml version="1.0" encoding="UTF-8"?> <configSettings> <mainSettings> <CSSLoader name="mainIndexCss" url="mainIndexStyle.swf" estimatedBytes = "99999" load="true"/> </mainSettings> <page title="Welcome"> <SWFLoader name="Welcome" url="pageA.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="About Us"> <SWFLoader name="About Us" url="pageB.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="Services"> <SWFLoader name="Services" url="pageC.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="Portfolio"> <SWFLoader name="Portfolio" url="pageD.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> <page title="Contact Us"> <SWFLoader name="Contact Us" url="pageE.swf" estimatedBytes = "99999" load="true" alpha="1"/> </page> </configSettings> with the <mainSettings> <CSSLoader name="mainIndexCss" url="mainIndexStyle.swf" estimatedBytes = "99999" load="true"/> </mainSettings> as an example as Im not sure if this is written correctly. and in the mainIndex.as in the mainIndex constructor I have this code: // load the xml data var xmlLoader:XMLLoader = new XMLLoader("com/siteA/assets/data/xml/config.xml", { name:"xmlData", requireWithRoot:this.root, container:swfContainer_mc, maxConnections:1, estimatedBytes:10000, onProgress:appLoading, onComplete:appLoaded, onChildProgress:childLoading, onChildComplete:childLoaded }); XML.ignoreWhitespace = true; xmlLoader.load(true); and in functions I have this code: // 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.url + " = " + 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(LoaderMax.getContent("xmlData").content.getStyle("h1").fontSize); //output 24px trace(e.target + ", is complete!"); trace(e.target.content + ", is complete!"); 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]}); } Dont know how to apply the CSSLoader and how to add to the xmlLoader?
  24. I forgot to attach the updated files for anyone wishing to look at it or (its a long shot) help tweak the coding as I have already said I am very inexperienced with AS3 (worth ago LOL).
  25. Yep your right it is unrelated to LoaderMax and it's all working ok. I found that the liquid stage class (Julian Kussman Stage Align Tool Class) I am using was the problem. I have been using his class because I found it easier than other liquid stage classes I have found (although there are a few issues in his class) bering in mind I am at the bottom of the food chain when it comes to Action Script 2 or 3. A massive thanks to you and your continued effort in the production of your Greensock Tweening Platform (which I have been using for years now) and I would say it is most possibly THE BEST platform out there (not that I have grasped hardly anything about how to utilize its potential but I am still trying to learn). P.S. just a little note - I have noticed that the majority of the tutorials out there for your tweening platform are directed at Images, Videos and single swf loading but I cant find hardly any tutorials for Multiple Loading of swf's, animating child swf movie clips/assets but perhaps Im not looking in the right places.
×
×
  • Create New...