Share Posted January 16, 2011 Ok, I'm stumped and at this point convinced I'm coming at this from the wrong angle. Please help! I'm trying to load text into a specific container, contentBox, that has scrollBar functionality in a separate scrollBar.as file. Nav buttons would load the associated data into this container. My approach was to try and specify the contentBox as a target for the DataLoader but no luck. Here's where I'm at (sorry if it's a bit messy, clean up is usually the celebratory "it works!" step) package { import flash.events.*; import flash.display.Loader; import flash.display.MovieClip; import flash.filters.*; import flash.net.URLVariables; import flash.utils.ByteArray; import flash.text.TextFormat; import flash.text.TextField; import com.greensock.events.LoaderEvent; import com.greensock.*; import com.greensock.plugins.*; import com.greensock.easing.*; import com.greensock.loading.*; public class Screenings extends MovieClip { TweenPlugin.activate([GlowFilterPlugin]); var subNav:SubNav = new SubNav(); var contentBox:ContentBox = new ContentBox(); var textLoader:DataLoader = new DataLoader("assets/copy/screenings.txt", {name:"text",x:0,y:0, onComplete:transitionIn, estimatedBytes:900}); var buildTimeline:TimelineLite = new TimelineLite(); var currentNav:MovieClip; var contentFormat:TextFormat = new TextFormat(); public function Screenings() { subNav_mc.addEventListener(MouseEvent.MOUSE_OVER, subNavOver, false, 0, true); subNav_mc.addEventListener(MouseEvent.MOUSE_OUT, subNavOut, false, 0, true); subNav_mc.addEventListener(MouseEvent.CLICK, subNavClick, false, 0, true); contentBox.x = 140; contentBox.y = 179; contentBox.alpha = 0; buildTimeline.append(new TweenLite(horizBar_mc, .8, {x:0, ease:Sine.easeIn})); buildTimeline.append(new TweenLite(contentBox, .4, {alpha:1,ease:Sine.easeOut})); buildTimeline.append(new TweenLite(subNav_mc, .4, {alpha:1,ease:Sine.easeOut})); addChildAt(contentBox,2); subNav_mc.alpha = 0; TweenMax.to(subNav_mc.screenings, 0, {glowFilter:{color:0xffffff, alpha:1, strength:1.5, blurX:8, blurY:8, quality:2,ease:Sine.easeOut}}); contentBox.drag.visible = false; contentBox.scrollBar.visible = false; textLoader.load(); contentFormat.size = 14; contentBoxTitle.defaultTextFormat = contentFormat; } public function transitionIn(event:LoaderEvent):void { TweenLite.to(contentBox, 1, {alpha:1}); } function subNavOver(e:MouseEvent):void { subNav_mc.buttonMode = true; subNav_mc.screenings.mouseChildren = false; subNav_mc.news.mouseChildren = false; subNav_mc.pressReleases.mouseChildren = false; var navItem:MovieClip = e.target as MovieClip; if (navItem != currentNav) { TweenMax.to(navItem, .3, {glowFilter:{color:0xffffff, alpha:1, strength:1.5, blurX:8, blurY:8, quality:2,ease:Sine.easeOut}}); } } function subNavOut(e:MouseEvent):void { var navItem:MovieClip = e.target as MovieClip; if (navItem != currentNav) { TweenMax.to(navItem, .3, {glowFilter:{alpha:0}}); } } function subNavClick(e:MouseEvent):void { contentBoxTitle.text = e.target.name.toUpperCase(); TweenMax.to(subNav_mc.screenings, .3, {glowFilter:{alpha:0}}); var navItem:MovieClip = e.target as MovieClip; if (currentNav != null) { TweenMax.to(currentNav, .3, {glowFilter:{alpha:0}}); } TweenMax.to(navItem, 0, {glowFilter:{color:0xffffff, alpha:1,strength:1.5, blurX:8, blurY:8, quality:2,ease:Sine.easeOut}}); currentNav = navItem; function loadNext(swfUrl:String):void { textLoader.dispose(true); textLoader= new DataLoader(swfUrl, {name:"text",x:0,y:0, onComplete:transitionIn, requireWithRoot:this.root, estimatedBytes:900}); textLoader.load(); } if (currentNav == navItem) { TweenLite.to(contentBox, 1, {alpha:0, ease:Sine.easeOut, onComplete:loadNext, onCompleteParams:["assets/copy/" + e.target.name + ".txt"]}); } } } } Thanks for your help! Link to comment Share on other sites More sharing options...
Share Posted January 16, 2011 I don't see anywhere that you take the text and put it anywhere. So the DataLoader loads the text but you don't do anything with it. I assume you meant to do that in the method that you're calling when the DataLoader completes (transitionIn()) like: public function transitionIn(event:LoaderEvent):void { contentBox.text = textLoader.content; TweenLite.to(contentBox, 1, {alpha:1}); } Right? Link to comment Share on other sites More sharing options...
Author Share Posted January 16, 2011 ah man, yup, that was it as well as I was ignoring the children of the contentBox. ContentBox is a movieclip, within that is another movieclip called container_mc (used for scrolling a mask, and within that is the text box. So I wasn't loading AND I wasn't targeting the right object. genius... thank you! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now