Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...

Marcus Aurelius

Members
  • Posts

    29
  • Joined

  • Last visited

About Marcus Aurelius

  • Birthday 02/25/1970

Profile Information

  • Gender
    Male
  • Location
    United Kingdom
  • Interests
    Graphic Design

Marcus Aurelius's Achievements

Newbie

Newbie (1/14)

0

Reputation

  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
×