Jump to content


  • Posts

  • Joined

  • Last visited


0 Newbie
  1. I have an for loop going though XML nodes and loading a bunch of images. I would like the containers to default to 'this', but if a border:Boolean is true, I would like it to reference the appropriate border_mc. What's the cleanest way to conditionally set the container variable within my ImageLoaderVars?
  2. Ok, I have discovered that the above framerate problem stems from adding an eventListener for Event.RESIZE... I would like to keep using this function, however; any ideas? Thanks edit: The above is untrue. It seems in point of fact, that the problem is with the function that is called by the aforementioned eventListener. If I edit out the listener, and put in a single call the checkStageSize, I get the same loss of FPS. If I comment out that single call, the FPS is fine again..! This is wierd, is it not? Is the framerate collapsing simply because I have scaled _all_ of my content, thus it's recalculating scale at the beginning of each enterFrame???
  3. Hi again, before I get back to things, I have noticed something quite disturbing. It seems that when I use preloader to load a pre-compiled swf (currently the site as whole) my FPS drops by about half...! Any ideas why this could be? The pre-compiled swf plays at perfect framerate when compiled from within it's original fla. As it's not too heavy, I've attached my preloader code, in case you can see anything there: package { import flash.display.MovieClip; import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.text.TextField; import flash.system.Capabilities; import com.greensock.*; import com.greensock.easing.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.LoaderMax; import com.greensock.loading.SWFLoader; import com.greensock.loading.data.SWFLoaderVars; import com.greensock.loading.display.ContentDisplay; import flash.events.*; public class preloader extends MovieClip { // SET UP MOVIE CLIP VARIABLE(S) // public var mcContent:MovieClip;// = new MovieClip(); public var tlSpinner:TimelineMax = new TimelineMax( { repeat: -1 } ); // CONSTRUCTOR FUNCTION // public function preloader() { // *** SET UP STAGE PROPERTIES *** // stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; // register to re-check when stage size changes stage.addEventListener( Event.RESIZE, onResize, false, 0, true ); // - Initial Resize of mcContent to match screen resolution of user - // stage.dispatchEvent(new Event(Event.RESIZE)); // *** LOADING CODE *** // var config:SWFLoaderVars = new SWFLoaderVars(); config.container(this); config.x(0); config.y(0); config.alpha(0); config.visible(false); config.onComplete(_completeHandler); // Functions are at end of file config.onProgress(_progressHandler); // USE THIS? config.autoDispose(true); // LOAD MAIN SWF var swf:SWFLoader = new SWFLoader("swfs/main.swf", config); swf.load(); // - Rotate Spinner - // tlSpinner.append(TweenLite.to(mcProgress.mcSpinner, 1.2, { rotation: 315, ease:SteppedEase.create(8) } )); } private function _progressHandler(event:LoaderEvent):void { // USE PROGRESS DATA TO UPDATE "LOADING..." MC var percent = int(event.target.progress * 100) + "%"; mcProgress.txtProgress.text = percent; //trace("loading... " + event.target.progress); } private function _completeHandler(event:LoaderEvent):void { // - Add loaded Content into a variable - // var currentContent:ContentDisplay = event.target.content; mcContent = MovieClip(currentContent.rawContent.getChildByName("mcContent")); mcContent.alpha = 0; mcContent.visible = false; currentContent.rawContent.removeChild(currentContent.rawContent.getChildByName("mcContent")); // - Add loaded content to the stage - // this.addChild(mcContent); // - Hide progress bar, and show main content - // TweenLite.to(mcProgress, 0, { autoAlpha: 0, immediateRender: false } ); TweenLite.to(mcContent, 0, { autoAlpha: 1, immediateRender: false } );// delay: 1 } ); tlSpinner.stop(); } private function onResize( e:Event ) { checkStageSize(); } // do the scaling here private function checkStageSize():void { var wid:Number = stage.stageWidth; var hei:Number = stage.stageHeight; var needToScaleDown:Boolean = (wid < 1366); // or some other test var scale:Number; var ratio:Number = 0.562; if ( needToScaleDown ) { if (wid > 768) { scale = wid/1366; this.scaleX = this.scaleY = scale; } else if (wid <= 768) { scale = 768/1366; this.scaleX = this.scaleY = scale; } } else { this.scaleX = this.scaleY = 1; } if (wid > 1366) { this.x = (wid / 2) - (this.width / 2); this.y = (hei / 2) - (this.height / 2); } } } }
  4. Hi, Thanks again for the info. Much appreciated as always. Yeah, apologies for the complicated explanation. I'm still getting used to coding/working with flash and actionscript, and likely my code reflects that . (for posterity, a current test version of the site can be viewed at kama.is/test.html, to give you at least an idea of what I'm working with) Re your pointers: 1) I would ultimately only have one (homepage) swf using my documentClass; I should note that my subpages have some classes linked via objects on the stage, such as my scrollbars - these instantiate "documentClass(root)" as an mc in order to locate and affect appropriate content. I think this is where one problem lies. This breaks the compile of a few of my subpages, as they are obviously trying to reference a clip that does not exist...(solved the problem in my current test, by loading all of my pages together) Does that make any more sense? 2) I agree (though file size isn't _major_ issue in this case) re the redundancy of loading classes repeatedly in subpages. I will definitely look into getClass(); sounds like a common 'class-container' swf would be sensible, as well as good coding practice imho - What is simplest way to compile such a swf? Should it have a doc class that "includes/imports" the shared classes? 3) The error you speak of is exactly the problem. It's just I've been having a little trouble figuring it out. Your response here definitely sounds like it could help. I won't ramble on any longer, as I have couple of ideas worth trying first Cheers (I'll likely be back )
  5. I guess a simpler question might be, should I have a document class only for my preloader? Or should it be ok to load a swf that has it's own document class? (in my case ultimately, load a swf with its own document class, as well as other swf "pages" that have mc's linked to other classes that reference the main document class as a MovieClip - ie. I have scrollbars on several pages that reference the document class in order to add content via xml to mc's on the stage) nb. I am now realising that my problems could be because I am not having completely isolated classes (such as scrollbar, navbutton, etc) -- I have kind of hard-coded links between them and my mc's on stage... Could this be the heart of the matter?
  6. Thank you. Part of the issue may well be to do with code running before mc's are present on the stage; I will make sure to check through my code. Yeah, sorry for not posting some examples... this is the first flash site I've built, and in part it might be a little convoluted I've been learning techniques and best practices throughout...still very much am. If I can think of way to simplify and post an example file, I will. If not, would you be ok to look over my production code if I send to you over pm perhaps? I want to keep this as last resort, mostly because though my code is commented, it's perhaps not done that well for anyone else other than me in places Back to the issue - I have been experimenting and trying to solve problems. I have just noticed that because I am now compiling the "pages" all separately, I am seeing just how reliant they are on my documentClass. Further, I _just_ discovered that I am therefore compiling the documentClass separately for each page swf...which means any edits to that class means I then have to recompile all pages again...I think I could have done this website a bit better than I have done though it's been an excellent learning experience. Would I be correct in saying that I should remove any reliance of each page upon the documentClass, so that they compile as just (badly) displayed content? Then ammend my documentClass to contain ALL of my code (apart from supplementary external classes) - as well as listen for appropriate ADDED_TO_STAGE to be safe? ^ At least this is what I am feeling should be step 1. Then perhaps once that's cleared, I won't need to edit much else within my code (at least regarding loading)... [for the record to give you an idea what I am working on, you can check out the current state of this website by going to http://www.kama.is - it should load quick enough on good connection] edit: I should perhaps point out, at the moment, I am simply seeking to load all pages together (the mcContent) instead of separate pages (that will come after - sensible?) A further question or two - At the moment I have a separate preloader class (document class for preload.swf) which loads a swf with mcContent in it. Should I place the documentClass (currently the document class for the mcContent swf (and ultimately the "page" mc's) into the preloader document class (well, combine them, I guess)? This way, all code will be within the preloader...is that good idea? I'm guessing I would then have to make sure my code checks for the successful loading (adding to stage) of all necessary parts (currently just mcContent, though ultimately all separate page swf's) - before it runs any code... Thanks again
  7. Hi, I want to believe I'm not the only one to have had this issue (it is usually the case ). I had built my site with each "page" as a movie clip on it's own layer on timeline (within a content_mc). Each page_mc contains its relevant other movie clips. Everything is on frame one. Most actionscript is within a document class and other classes. I was having crazy trobule with splitting the pages into separate swf's, so I thought I would start simple instead. I have created a preloader.swf which loads the "complete" site main.swf The (initial) problem Even using this method, I am running straight away into trouble as the code within my document class (gets loaded with main.swf) refers to mc's that I have built using the flash IDE. However, because all of these are now within another display object, or something, all of my references are now incorrect (I guess). Does this sound correct, and thus I need to go through and alter _all_ of my class code, or am I perhaps missing something beautiful and simple that can make all my problems go away? Thank you - please ask questions; I am having trouble getting my head around this (as everything worked beautifully before I separated things out to use with LoaderMax) and thus have not necessarilly explained things that well... Peace
  8. Thank you, Zync. Much appreciated. I thought it would come to this. So am I right in saying then, that I need to take each of my "page" mc's (with all their nested content) and resave them as separate swf's? Furthermore, each page has a background image, and various other images, etc that are currently within the flash ide library. Would it be better to use loaders to load all of this content as well? Or would it be enough to split up the pages as mentioned above, and just load each complete page, as necessary? Thanks again (will read up on GAIA) and looking forward to your tutorials [edit] : though looking at it, would it not be too much of a pain to start using GAIA now, as I've already basically built my website? I'm already slightly concerned how much of my code is going to "break" simply by splitting up the pages into separate swf's... Peace
  9. Hi, I have built/almost completed a website (around 3.5MB currently) - and would like to construct a sensible preloader for it. However, as I have been learning both AS3 and greensock code throughout this project, I decided not to read up on loaders until now (perhaps not the greatest idea, but I had to start somehwere ). The site is all within a single movie clip on frame 2 of the main flash ide stage. Within that mc I have everything on frame 1. All my site "pages" are single mc's containing all their necessary sub mc's. I would like my preloader to first load the home page, and display pretty much immediately; then in the back ground, keep loading the other "page" mc's; but should a user click on of the nav menu links, to prioritise the load of that "page" over the others...etc. In order to achieve this, must I break apart those "page" mc's in to separate .swf's??? This is the impression I'm getting from what I'm reading (apart from selfLoader - am reading currently). Any advice would be greatly appreciated! Cheers
  10. Thanks, Carl. Seems strange, I know, but I've literally tested: Place one layer above another. Lower layer has mc linked to external class. When it refers to its own parent (this.parent[subClip]) it returns error as I mentioned before. However, if all I do is place the layer that's above, below the other layer, the class code works fine... I guess I'll have to programatically edit z position. Any useful links, else I'll do the classic google.
  11. Please still read the post above. I have discovered that this error comes from the order my layers are in, on the Flash IDE timeline. Let me first clarify a little. I am setting up re-usable code for scrollbars. I created a scrollbar class. Functions within this class then use the name of a scrollbar instance to reference and find its relevant mc constituents (i.e scroller, textbox, textbox_mask). It then will place the scroller, trigger import of appropriate text, etc... So, though I have found a "solution" to my above issue, it forces me to place the scroller mc underneath the scrollbar mc (in my layers), which is obviously not preferable. Do I have to place the layers underneath (as appropriate in IDE), and then control z-order in actionscript? Or is there another way? I'm not certain...
  12. I may not be the best guy for this, but between us perhaps we can figure something out. Specifically regarding the problem surfacing when using lots of traces, I have no idea what could be wrong. However, I have seen couple things worth mentioning in your code. Initially, I'm not sure that you need the two function, "addInitialTweens()" and "onInitialTweenComplete". Your "onInitialTweenComplete()" function uses appendMultiple, but you are only appending one tween. Try changing this (at least while you're only adding one tween) to .append instead (and obviously then remove the []). You could do something like: private function createTimeline():void { // note the use of onComplete for the timeline instance. You can still do it as you had before, but this way, it will always run at timeline completion, // so you can mess with the tweens within the timeline as much as you like... _timeline = new TimelineMax( { onComplete: onFollowUpComplete } ); _timeline.pause(); } private function addInitialTweens():void { var tween:TweenMax = new TweenMax( _rectangle, 0.25, { x: 450, } ); _timeline.append(tween); // add follow-up tween var followUpTween:TweenMax = new TweenMax( _rectangle, 0.25, { y: 450, } ); _timeline.append(followUpTween); _timeline.play(); } ultimately I'm not sure this will help much, but let me know what you think, or what happens Peace
  13. thank you very much, Carl. Shall be giving this a more thorough read tomorrow in case I go down this path. However, will this mean that when a user clicks link the full page transition will occur before animating to another page (if the user clicked two links, one shortly after the other)? Would have been nice to be able to interrupt the transitions...however, for now I've gone with a really simple solution. On menu click, all menu items are disabled. The transition timeline then fires function to re-enable appropriate items onComplete. ----------------------------------------------------------------------------------------------------------- I do have another question though I have an external class which is using syntax as follows to access other items on stage: trace(this.parent[refStr]); trace(this.parent["mcName"]); In some instances, the above traces will output "[object MovieClip]". However, in some instances (my important ones ) they output "undefined". I have triple+ checked instance names, etc and can't figure out any reason why some should work and not others! Any ideas? Many thanks, Michael
  14. Hi, Having an interesting problem (well, perhaps frustrating is more apt)... I have a classic issue of finding the best way to transition between my website "pages". I think my problem may lie in the way I'm using tlPgTrans (my transition timeline) - or perhaps the problem is with autoAlpha being not fully complete. When I click on a nav button, the code shown below removes tlPgTrans (my transition timeline) if it exists, re-iterates it so I have clean canvas, and then, using Case statements, first ammends all appropriate page transition tweens, then plays the timeline. The problem I face is when a nav button is clicked and then another is clicked very soon after. It seems to work on occasion/mostly but there are times where the tweens from the second (quickly after) click are not run. The page finishes tweening, ending up in the wrong location (page destination from first click). This then breaks further navigation as what's on screen does not match my currentPage var. Another issue is within "Switch(to) > Case bioMark" in the below code. When the tlPgTrans is first ammended with this it runs as expected. However on consequent transitions to this page, the tweens, particularly (if not only) the tweenmax.fromTo play much faster... I imagine my second problem is tied in with the first. I'm looking for a clean page navigation solution. If what I'm doing is heading down wrong path, I'm definitely open to suggestion. Please don't hesitate to ask if you'd like more info Cheers! Currently here is a snippet of the relevant code (hopefully with useful comments): (the tlPgTrans was originally declared outside of function, but not currently) public function transPage(from:String, to:String):void { // clear previous page transition tweens /* if (tlPgTrans) { trace("clear tweens from tlPgTrans"); tlPgTrans.clear(); trace("tweens cleared"); } */ if (tlPgTrans) { // experimenting... tlPgTrans.complete(); tlPgTrans.kill(); } // re-iterate transition timeline var tlPgTrans:TimelineMax = new TimelineMax( { paused:true, autoRemoveChildren:true } ); trace(from + " -> " + to); // the following function uses a currentPage var to first make nav menu item clickable again // then changes currentPage to equal the "to" variable // then makes the new currentPage nav menu item un-clickable editPgMark(to); // append page "out" tweens switch (from) { case homeMark: //trace("from Home"); tlPgTrans.appendMultiple(TweenMax.allTo([mcContent.mcHomePage.mcScene, mcContent.mcHomePage.mcHomeTitle, mcContent.mcHomePage.mcPhonetics, mcContent.mcHomePage.mcHomeArrow, mcContent.mcHomePage.mcHeadphones, mcContent.mcHomePage.mcHeadphonesShadow], 2, { autoAlpha:0 }, 0, pauseTLs, [homeMark])); break; case bioMark: //trace("from Bio"); tlPgTrans.append( TweenMax.to(mcContent.mcBioPage, 2, { autoAlpha:0 }) ); break; case stageMark: // stage out tweens break; case classMark: // class out tweens break; case galleryMark: // gallery out tweens break; case contactMark: tlPgTrans.append(TweenMax.to(mcContent.mcContactPage, 2, { autoAlpha:0 } )); break; case otsMark: // on-the-side out tweens break; default: // error message perhaps? } switch (to) { case homeMark: //trace("going to Home"); tlKama.resume(); tlSway.resume(); tlPgTrans.appendMultiple(TweenMax.allTo([mcContent.mcHomePage.mcScene, mcContent.mcHomePage.mcHomeTitle, mcContent.mcHomePage.mcPhonetics, mcContent.mcHomePage.mcHomeArrow, mcContent.mcHomePage.mcHeadphones, mcContent.mcHomePage.mcHeadphonesShadow], 2, { autoAlpha:1 }, 0)); break; case bioMark: //trace("going to Bio"); // the following is temp test code. I will probably use this case to fade in the mcBioPage and trigger another timeline or function to do the rest // mcBioImg I would like to populate dynamically and animate through range of photos accessed via XML tlPgTrans.append( TweenMax.to(mcContent.mcBioPage, 2, { autoAlpha:1 } ) ); tlPgTrans.append( TweenMax.from(mcContent.mcBioPage.mcString, .3, { x: -30, ease: Linear.easeOut } ) ); tlPgTrans.append( TweenMax.from(mcContent.mcBioPage.mcBioImg, 4, { y: -200 } ), 1 ); tlPgTrans.append( TweenMax.to(mcContent.mcBioPage.mcBioImg, 5, { y: 1200 } ) ); break; case stageMark: //trace("going to Stage"); break; case classMark: //trace("going to Class"); break; case galleryMark: //trace("going to Gallery"); break; case contactMark: //trace("going to Contact"); tlPgTrans.append(TweenMax.to(mcContent.mcContactPage, 2, { autoAlpha:1 } )); break; case otsMark: //trace("going to On-the-Side"); break; default: // error code? } tlPgTrans.play(); } Thanks again.