Jump to content
Search Community

UbiAssassin

Premium
  • Posts

    46
  • Joined

  • Last visited

Everything posted by UbiAssassin

  1. Thanks Carl. I actually re-added the (e:TimelineEvent):void. I re-started CS4 and it gave me the real error that I need to debug: TypeError: Error #2007: Parameter child must be non-null. at flash.display::DisplayObjectContainer/addChild() at imageLightningMain/initTitleLightning() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at com.refunk.timeline::TimelineWatcher/watch() This error shows up and the lightning code does not engage at the right time, but after a bit of a delay it starts working as intended. Maybe it is because I am adding this new movie into a movie that it thinks no longer exists. I am using a timeline label on the very last checkpoint of the container movie. There is also a stop(); command on that last checkpoint of the container movie. The label is the timeline event cue that tells the new lightning movie to be added into the container and then start. Could it be since the container movie has reached its final position and stopped, it is considered no longer there for the addChild command? I have another way to fix this issue that I will probably use and it will completely remove the issue of me trying to load the lightning movie into the container. The error-prone method was just a way to circumvent performance issues of having more than two FX bolts present at the same time. I just have to re-write things a bit to correctly time and remove the bolt animations in the container movie to avoid the performance issue and the error listed above. I just would like to know what types of things specifically cause the (TypeError: Error #2007: Parameter child must be non-null.) issue so that I can avoid them in the future. Thanks again!
  2. Here is the error that I am getting, even though the chunk of code that is causing it eventually works. It will continue to output the error: ArgumentError: Error #1063: Argument count mismatch on imageLightningMain/initTitleLightning(). Expected 0, got 1. at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at com.refunk.timeline::TimelineWatcher/watch() Here is the actual class file that is causing the problem: package { import com.greensock.loading.display.ContentDisplay; import flash.display.*; import flash.events.*; import com.greensock.*; import com.greensock.easing.*; import com.greensock.loading.LoaderMax; import com.refunk.events.TimelineEvent; import com.refunk.timeline.TimelineWatcher; public class imageLightningMain extends MovieClip { //======================================================== //*** Variable declarations for TimeLineWatchers.*** // //======================================================== private var imageLightningWatcher:TimelineWatcher; private var titleLightningMC:ContentDisplay = LoaderMax.getContent("titleLightningmcs.swf"); public function imageLightningMain() { //========================================================================================== //*** Set up TimeLineEvent and a Watcher that will allow the Title Lightning FX to Run.*** //*** Function to clean up when the processes are complete.*** // //========================================================================================== imageLightningWatcher = new TimelineWatcher(this); imageLightningWatcher.addEventListener(TimelineEvent.LABEL_REACHED, initTitleLightning); } private function initTitleLightning():void { trace("titleLightning Activated"); addChildAt(titleLightningMC, 0); LoaderMax.getLoader("titleLightningmcs.swf").rawContent.play(); imageLightningWatcher.removeEventListener(TimelineEvent.LABEL_REACHED, initTitleLightning); imageLightningWatcher.dispose(); imageLightningWatcher = null; } } } Is there anything about this setup that jumps out to you as incorrect? I cannot seem to find the issue. Thanks!
  3. Is there a way in LoaderMax to play the index.html file instead of the main.swf file? I tried using a DataLoader, but that was not getting recognized. Since I load my preloader first, I have to tell something to play at the end of the preloader class instead of just loading through an html like I did on my old site. My old site just has a preloader built into the first frames of the main movie and all of its .as code was on the main timeline. I don't really need the html file, but I don't like the fact that my site will just autsize to the browser window regardless of how small or large it is. I have tried the noScale option, but there seems to be no easy way to keep my site from miniaturizing when the browser is dragged down to be super small. Actually I would prefer to just have a solid way to keep my site from being scaled up or down from 1024 x 768 using just the swf file, but if html is still the most solid way to do that, then I just need to launch the html at the end of the preloader. Thanks.
  4. Voila! I found a great way to get around my issue! There is an awesome little library called TimeLineWatcher http://www.adobe.com/devnet/flash/articles/timelinewatcher.html. I just added a label to the correct place on the Main movie's timeline. My main movie class just sits waiting on an eventlistener for that label to be reached. Problem solved Maybe someone else can solve something with this as well. Thanks everyone
  5. keep in mind autoPlay:false only prevents the loaded swf's timeline from advancing, it doesn't prevent code from executing. Yes, thank you, that helped Sadly I cannot seem to find a way that does not error-out to pause the Class and only allow it to run when the mainSite.swf is actually called to play. If I put things in the MainClass to stop its progress, then it just errors out or halts the progress forever. I am not sure how to send a signal from the preloader class that it can access in the MainClass>.< Everything I have tried thus far has not worked. Is there a way to update a variable from one Class to another? Do you have a code example of a fake event to fire in the end of the preloader class that I could listen for in the main class? I was thinking that if I could create some fake event in the final function of my preloader class then my main class could just wait for that event before it progresses. I have not really been able to get it working yet though. Thanks! Ok, so I tried using LocalConnection to create the communication I needed. I get this error(Error #2044: Unhandled StatusEvent:. level=error, code=). Here is my preloader code: package { import com.greensock.core.TweenCore; import flash.display.*; import flash.events.*; import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.easing.*; import flash.display.MovieClip; import flash.net.LocalConnection; import flash.text.TextField; public class Levelforge_Preloader extends MovieClip { private var connToMain:LocalConnection; //=============================================================== //***Create Content Loaders, and LoaderMax Queue*** //=============================================================== private var navSwish:MP3Loader = new MP3Loader("http://levelforge.com/MP3/vwoom-Public_D-148.mp3", {name: "navSwishSound", rawProgress: 1, autoPlay: false, autoDispose: true, onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 55296}); private var navRollOver:MP3Loader = new MP3Loader("http://levelforge.com/MP3/ayuigo-xrikazen-80.mp3", {name: "navOverSound", rawProgress: 1, autoDispose: true, autoPlay: false, onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 33792}); private var navButtonClick:MP3Loader = new MP3Loader("http://levelforge.com/MP3/button-11.mp3", {name: "navClickSound", rawProgress: 1, autoDispose: true, autoPlay: false, onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 7168}); private var song1:MP3Loader = new MP3Loader("http://levelforge.com/08 Hunted (Instrumental).mp3", {name: "Hunted", rawProgress: 1, autoDispose: true, autoPlay: false, volume: .35, onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 6617088}); private var song2:MP3Loader = new MP3Loader("http://levelforge.com/WITHOUT INST.mp3", {name: "Without", rawProgress: 1, autoDispose: true, autoPlay: false, volume: .35, onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 2148352}); private var levelforgeMainSwf:SWFLoader = new SWFLoader("http://levelforge.com/WebsiteFlash10/Levelforge_NewAS3.swf", {name: "mainSite", rawProgress: 1, autoPlay: false, width: 1024, height: 768, scaleMode: "none", onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 574464}); private var queue:LoaderMax = new LoaderMax({name: "mainQueue", rawProgress: 1, onProgress: progressHandler, onComplete: completeHandler}); public function Levelforge_Preloader() { var preloader:SelfLoader = new SelfLoader(this, {name: "self", rawProgress: 1, onProgress: progressHandler, onComplete: loaderHandler, estimatedBytes: 23552}); //======================================================================== //***Set up what needs to be Loaded and Load it. Add Event Listeners.*** //======================================================================== LoaderMax.defaultAuditSize = false; queue.append(preloader); queue.append(navSwish); queue.append(navRollOver); queue.append(navButtonClick); queue.append(song1); queue.append(song2); queue.append(levelforgeMainSwf); queue.load(); queue.addEventListener(LoaderEvent.COMPLETE, completeHandler); queue.addEventListener(LoaderEvent.PROGRESS, progressHandler); } //====================================================================================================== //***Functions that Handle Progress and Completion. They also control the Movie Progression Updates.*** //====================================================================================================== private function progressHandler(event:LoaderEvent):void { //trace("Watching Progress Now"); var percent:Number = event.target.bytesLoaded / event.target.bytesTotal; var circleLoaderProgress:Number = Math.round((event.target.bytesLoaded / event.target.bytesTotal) * 100); myLoadText.text = Math.round(percent * 100) + "%".toString(); circleLoader.gotoAndStop(circleLoaderProgress); } private function loaderHandler(event:LoaderEvent):void { trace(event.target + " complete"); } private function completeHandler(event:LoaderEvent):void { trace(event.target + " complete"); TweenMax.to(this, 1, {autoAlpha: 0, ease: Quad.easeIn}); removeEventListener(LoaderEvent.PROGRESS, progressHandler); removeEventListener(LoaderEvent.COMPLETE, completeHandler); TweenMax.delayedCall(0, runMainSite); TweenMax.delayedCall(0, sending); } private function runMainSite():void { trace("Run Main Site"); LoaderMax.getLoader("mainSite").rawContent.play(); LoaderMax.getLoader("mainSite").dispose(false); } public function sending():void { trace("Sending Message"); connToMain = new LocalConnection(); connToMain.send("beginMainClass", "waitOnPreloader"); } } } The error is thrown right after the trace "Sending Message." Here is the receiver code and method in my MainClass: connToMain = new LocalConnection(); connToMain.connect("beginMainClass"); //later in the code is the function: private function waitOnPreloader():void { trace("Connection Message Received"); TweenMax.delayedCall(.5, initButtonSounds); } Hopefully that makes sense.
  6. This is probably a ridiculous question, but I assumed that the class for my Main.swf would not start running until the Main.swf was actually told to play. I am loading the main.swf in my preloader.swf, but I am setting it to autoPlay: false. During my cleanup phase in the preloader class, the main class is starting to play before I tell the Main.swf to play. Do I need to do something extra to halt the class file's progress? I thought that it would not activate until its parent movie was actually set to play. Here is the cleanup section of my preloader: private function completeHandler(event:LoaderEvent):void { trace(event.target + " complete"); removeEventListener(LoaderEvent.PROGRESS, progressHandler); removeEventListener(LoaderEvent.COMPLETE, completeHandler); TweenMax.delayedCall(1, cleanPreloaderA); } private function cleanPreloaderA():void { removeChildAt(0); removeChildAt(1); TweenMax.delayedCall(0.1, cleanPreloaderB); } private function cleanPreloaderB():void { trace("Cleanup Preloader"); removeChildAt(0); removeChildAt(1); TweenMax.delayedCall(0.1, runMainSite); } private function runMainSite():void { trace("Run Main Site"); removeChildAt(0); LoaderMax.getLoader("mainSite").rawContent.play(); } } } I have several functions that clean up various parts of the preloader setup, and the very last function activates my mainsite.swf. The problem that I am having is that the class for the mainsite.swf is starting during the end of the preloader class instead of after the completion of the "runMainSite" function, which I did not think was possible. I am guessing this is happening because the mainsite is loaded therefore its class is loaded and setting the swf to autoPlay: false does not stop the class file from proceeding? Thanks
  7. Hello again, I hope that this question is not completely daft, but I have 3 sounds that I load in MP3Loaders currently. I am finding that many of my website's .as files need to access these same sounds. At first I just added vars to each .as script using MP3Loaders to load the same sounds. I am not disposing of the loaders from the original .as files that already loaded these sounds however. Can I just tell that sound to play in an .as file that is called well after the sound has been loaded and not disposed of in a previous .as file? Or do I have to just keep cloning the MP3 Loader logic into each new .as file that needs to access the sounds? I assume that I can just grab the already loaded content into a var in my new .as file and then use it as needed instead of creating new loader instances everywhere. I am trying to be efficient but I am also learning everything for the first time, so I am not aware of a lot of things. I know about getLoader,but I am not 100% sure how it works. I have tried to access the private var MP3Loaders from the other .as files with getLoader, but I am not sure how to do this currently. Any help would be appreciated so that I can keep my overhead down as much as possible and just use what is already loaded instead of calling multiple loads for the same content. Or does a loader just skip any overhead if the content it is calling is already present and loaded? Here is an example of one of the MP3Loaders that I call early in my movie: private var musButtonClick:MP3Loader = new MP3Loader("http://levelforge.com/MP3/button-11.mp3", {autoPlay: false, volume: 1}); I would love to just have acess to this in another .as file. Like a global variable in games, that can be called regardless of where you are in your script.
  8. I turned off AuditSize, set the loading to rawProgress, and added the rest of my graphics. My preloader is working exactly as I wanted. Thanks for your input Greensock! It helped me a lot Finished code: package { import flash.display.*; import flash.events.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.TweenMax; import flash.display.MovieClip; import flash.text.TextField; public class Levelforge_Preloader extends MovieClip { //============================================== //***create a SelfLoader, Content Loaders, and LoaderMax Queue*** //============================================== public function Levelforge_Preloader() { var loader:SelfLoader = new SelfLoader(this, {name: "self", rawProgress: 1, onProgress: progressHandler, onComplete: completeHandler, autoDispose: true, estimatedBytes: 23552}); var navSwish:MP3Loader = new MP3Loader("http://levelforge.com/MP3/vwoom-Public_D-148.mp3", {name: "navSwishSound", rawProgress: 1, autoPlay: false, container: this, autoDispose: true, onProgress: progressHandler, onComplete: completeHandler, estimatedBytes: 55296}); var navRollOver:MP3Loader = new MP3Loader("http://levelforge.com/MP3/ayuigo-xrikazen-80.mp3", {name: "navOverSound", rawProgress: 1, autoPlay: false, container: this, autoDispose: true, onProgress: progressHandler, onComplete: completeHandler, estimatedBytes: 33792}); var navButtonClick:MP3Loader = new MP3Loader("http://levelforge.com/MP3/button-11.mp3", {name: "navClickSound", rawProgress: 1, autoPlay: false, container: this, autoDispose: true, onProgress: progressHandler, onComplete: completeHandler, estimatedBytes: 7168}); var levelforgeMainSwf:SWFLoader = new SWFLoader("http://levelforge.com/WebsiteFlash10/Levelforge_NewAS3.swf", {name: "mainSite", rawProgress: 1, autoPlay: true, container: this, autoDispose: true, onProgress: progressHandler, onComplete: completeHandler, estimatedBytes: 6052864}); var queue:LoaderMax = new LoaderMax({name: "mainQueue", rawProgress: 1, onProgress: progressHandler, onComplete: completeHandler}); //======================================================================== //***Set up what needs to be Loaded and Load it. Add Event Listeners.*** //======================================================================== LoaderMax.defaultAuditSize = false; queue.append(loader); queue.append(navSwish); queue.append(navRollOver); queue.append(navButtonClick); queue.append(levelforgeMainSwf); queue.load(); queue.addEventListener(LoaderEvent.COMPLETE, completeHandler); queue.addEventListener(LoaderEvent.PROGRESS, progressHandler); } //====================================================================================================== //***Functions that Handle Progress and Completion. They also control the Movie Progression Updates.*** //====================================================================================================== private function progressHandler(event:LoaderEvent):void { //trace("Watching Progress Now"); var percent:Number = event.target.bytesLoaded / event.target.bytesTotal; var circleLoaderProgress:Number = Math.round((event.target.bytesLoaded / event.target.bytesTotal) * 100); myLoadText.text = Math.round(percent * 100) + "%".toString(); circleLoader.gotoAndStop(circleLoaderProgress); } private function completeHandler(event:LoaderEvent):void { trace(event.target + " complete"); removeEventListener(LoaderEvent.PROGRESS, progressHandler); removeEventListener(LoaderEvent.COMPLETE, completeHandler); } } }
  9. Ok, I have solved all of the issues, except for a very jumpy preloader bar. I switched from the more exact methods to an attempt at "rawProgress," but it did not seem to fully remove the issue. Here is my current code. I also updated the entire pre-loader code lower in the message: private function progressHandler(event:LoaderEvent):void { //trace("Watching Progress Now"); var percent:Number = event.target.bytesLoaded / event.target.bytesTotal; var loaderBarProgress:Number = event.target.rawProgress; myLoadText.text = Math.round(percent * 100) + "%".toString(); circleLoader.gotoAndPlay(loaderBarProgress); } Can you see anything in that chunk of code that would help explain the loader bar animation craziness? =============================================================================================== Ok, thanks to your help I have managed to approach this from the ground up. I have solved almost all of the problems: I created a new Preloader.swf with its own .as file. It now loads the content for me as needed. The text progress indicator is working beautifully, but my preloader animation bar is doing some crazy stuff. I kind of moves forward then flicks back. It never goes all the way around or associates itself with the number percentage. I assume it is because I am not sure how to attach the animation to the progress correctly. How does this look to you? Here is the partial functionality in action: http://levelforge.com/WebsiteFlash10/Levelforge.swf package { import flash.display.*; import flash.events.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.TweenMax; import flash.display.MovieClip; import flash.text.TextField; public class Levelforge_Preloader extends MovieClip { //============================================== //***create a SelfLoader and LoaderMax Queue*** //============================================== public function Levelforge_Preloader() { var loader:SelfLoader = new SelfLoader(this, { name: "self", onProgress: progressHandler, onComplete: completeHandler, estimatedBytes: 24576 } ); var navSwish:MP3Loader = new MP3Loader("http://levelforge.com/MP3/vwoom-Public_D-148.mp3", { autoPlay: false, container: this, estimatedBytes: 57344 } ); var navRollOver:MP3Loader = new MP3Loader("http://levelforge.com/MP3/ayuigo-xrikazen-80.mp3", { autoPlay: false, container: this, estimatedBytes: 36864 } ); var navButtonClick:MP3Loader = new MP3Loader("http://levelforge.com/MP3/button-11.mp3", { autoPlay: false, container: this, estimatedBytes: 8192 } ); var levelforgeSwf:SWFLoader = new SWFLoader("http://levelforge.com/WebsiteFlash10/Levelforge_NewAS3.swf", { autoPlay: true, container: this, estimatedBytes: 6053888 } ); var queue:LoaderMax = new LoaderMax({onProgress: progressHandler, onComplete: completeHandler}); //============================================== //***Set up what needs to be Loaded and Load it.*** //============================================== queue.append(loader); queue.append(navSwish); queue.append(navRollOver); queue.append(navButtonClick); queue.append(levelforgeSwf); queue.load(); queue.addEventListener(LoaderEvent.COMPLETE, completeHandler); } private function progressHandler(event:LoaderEvent):void { //trace("Watching Progress Now"); var percent:Number = event.target.bytesLoaded / event.target.bytesTotal; var loaderBarProgress:Number = event.target.rawProgress; myLoadText.text = Math.round(percent * 100) + "%".toString(); circleLoader.gotoAndPlay(loaderBarProgress); } private function completeHandler(event:LoaderEvent):void { trace(event.target + " complete"); } } } Thanks again!
  10. Yeah that all sounds very good. Thanks for taking the time to look at my mess hehe. Sadly I cobbled together stuff in code and it really makes no sense. I have been trying to re-work it all in a way that makes sense to me and have been failing. Starting simple and having the pre-loader as a flash movie of its own that uses LoaderMax to load the main page and maybe the sounds for now is a much better route. I can just have an .as file attached to the preloader fla and then load into my main movie when all of the assets that I am trying to call are loaded. My main issue was that all tutorials that I have found thus far were plastering the preloader on frame 1 on the main movie, which really was not the way I wanted to approach it at all. I just wanted to start from somewhere and try to make sense of it. I know preloaders must be simpler than I am making them out to be LOL. Thanks again. I will see what I can do with a simple external preloader for now using the Self Loader approach. Thanks for putting up with all of my questions btw. I am much more capable with timeline tweens and website visuals than I am with straight code. I am really enjoying learning, but it is not an extremely fast process >.<.
  11. Hello again everyone. I have to admit right off, that pre-loaders have been the bane of my existance even back in AS2. This is my first true attempt at creating one on my own and it is not very functional. Basically I followed a tutorial for the visual elements that gave me enough room to do something that looks the way I want it to. I cobbled together the code from studying what little I could find >.< Please excuse the pre-alpha nature of what you see. It is the husk of my up and coming website re-vamp with a giant picture plastered in the middle so that I could test the pre-loader that doesn't function hehe. Here is the link to my test site with the non-functioning pre-loader: http://levelforge.com/WebsiteFlash10/Levelforge_NewAS3.swf Here are all of the source files: http://levelforge.com/WebsiteFlash10/Levelforge_NewAS3.zip Here is the code for my pre-Loader on the very first frame of my timeline: import com.greensock.*; import flash.display.*; import flash.events.*; import flash.display.MovieClip; import flash.text.TextField; import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; var myLoadText:TextField; //This is the Dynamic text field where I want my numberical progress to show, but it does not. var circleLoader:MovieClip; //This is the part of my pre-Loader setup that is supposed to animate, yet it does not. function start(myLoadText:TextField):void { myLoadText=myLoadText; myLoadText.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress); myLoadText.loaderInfo.addEventListener(Event.COMPLETE, onComplete); } function onProgress(e:ProgressEvent):void { var loadBytes:int=Math.round(e.target.bytesLoaded/1024); var totalBytes:int=Math.round(e.target.bytesTotal/1024); var percent:int = (e.target.bytesTotal / e.target.bytesLoaded) * 100; myLoadText.text=String(loadBytes+"of"+totalBytes+"KB Loaded \n"+percent+"% Complete"); circleLoader.gotoAndPlay(percent); } function onComplete(e:Event):void { this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onProgress); this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete); trace("Loaded!"); currentFrame+1; } You will see the preloader interface load, but the blue fill circle and outer white ring are not rotating and doing their thing. The number text in the center is also not updating. I have zipped and added all of my source files and AS3 packets. If someone has the time, could you please take a look and see what I am doing horribly wrong in the preloader section of the setup? I would really appreciate any criticisms and feedback I can get.
  12. Excellent tutorial and suggestion. I really appreciate the help. Sadly in my case, the buttons show an obvious pop at the end as they are re-adjusted and the blur is removed. It is also very obvious that they are blurred when your mouse is over the button and it sits translated until you roll off. It does not bother me that much, but I wish we had a way to control and remove the blurring affect throughout the entire tween process. Thanks again, you helped me a lot. Thank you also for the tutorial link in your response. I want to do something very similar, with the exception of moving the plates into specific positions on my screen instead of random ones.
  13. Thanks. I tried that, but the rotation was not working as intended with that change, and it still blurred for me. Maybe it has something to do with the fact that most of the button functionality happens in the NavButtonScript.as, but it is then accessed in the LevelforgeMain.as and told to translate across the stage. Perhaps the fact that one .as file is accessing the other has something to do with it? I don't see why off the top of my head, but it is not a completely simple setup, so there is probably a lot more room for error. Thanks again for the TweenLite comment. I have since removed all of my TweenLite dependencies and replaced them with TweenMax. Much cleaner that way
  14. Hehe, no worries. Honestly I am only about 4 days in to working with AS3 and greensock. My last site was built on a very small as2 shell and 98% timeline/visual work, so this is all very new to me. Any input that you have would be awesome and by no means considered a bash . I can use TweenMax for everything tweenlite can do I guess can't I? It would be smart for me to consolidate and just rip out the Tweenlite references
  15. Hello again I am re-building my website from scratch in Flash 10 AS3. I have been getting a lot of great help here and I really love the greensock tools! Brilliant stuff. My new issue is that to add more interactivity to my Navigation Buttons on the left panel of my website, I added a Y:-15 degree rotation on rollover and on rollout it goes back to 0 rotation. The problem is that the button and buttonLabel will blur slightly once the button has returned to its position. I was thinking that it was auto-applying a blur due to the rotation, but even trying to use the TweenLite.from BlurFilter to set it back to 0 blur does not fix the issue. I am probably completely missing the point of how this works and am doing it the wrong way. I am very new to this hehe. The issue is happening in these two chunks of my code: Here, I tell the button to rotate on a Mouse over event: private function soundOver(e:MouseEvent):void { navRollOver.gotoSoundTime(0, true); navRollOver.volume = .05; navRollOver.playSound(); TweenLite.to(this, .5, {z: -15}); TweenMax.to(this, .5, {rotationY: -15}); } Here I am trying to tell the button to go back to its normal position: private function onOut(e:MouseEvent):void { TweenLite.to(buttonOutline, 1, {removeTint: true, ease: Quad.easeOut}); TweenLite.to(buttonIndicator, .1, {tint: 0xFF6600, ease: Quad.easeOut}); TweenLite.to(buttonIndicator2, .1, {tint: 0x000000, ease: Quad.easeOut}); TweenLite.to(this, .5, {z: 0}); TweenMax.to(this, .5, {rotationY: 0}); } Here is the full code packet for my buttons: package { import com.greensock.loading.LoaderMax; import com.greensock.loading.MP3Loader; import flash.display.*; import com.greensock.*; import com.greensock.easing.*; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFormat; public class NavButtonScript extends MovieClip { //======================================================== //*** Variable declarations for Button Funtionality.*** // //======================================================== private var buttonField:TextField; private var buttonOutline:Shape; private var buttonIndicator:Shape; private var buttonIndicator2:Shape; //======================================================== //*** Variable declarations for Music Control.*** // //======================================================== private var navRollOver:MP3Loader = new MP3Loader("http://www.levelforge.com/MP3/ayuigo-xrikazen-80.mp3", {autoPlay: false, volume: .15}); private var navButtonClick:MP3Loader = new MP3Loader("http://www.levelforge.com/MP3/button-11.mp3", {autoPlay: false, volume: 1}); private var buttonSfxQueue:LoaderMax = new LoaderMax(); public function NavButtonScript() { //======================================================== //*** Call the Button Movie from the stage.*** // //======================================================== trace(this); TweenMax.to(this, 1, {bevelFilter: {blurX: 5, blurY: 5, strength: 1, angle: 45, distance: 5}, ease: Quad.easeIn}); //======================================================== //*** Load the Button Sounds for Usage.*** // //======================================================== buttonSfxQueue.append(navRollOver); buttonSfxQueue.append(navButtonClick); buttonSfxQueue.load(); //======================================================== //*** Button Definitions and Creation on Stage.*** // //======================================================== buttonOutline = new Shape(); buttonOutline.graphics.beginFill(0x00CBFF, 1); buttonOutline.graphics.drawRect(-2, -2, 119, 32); addChildAt(buttonOutline, 0); buttonIndicator = new Shape(); buttonIndicator.graphics.beginFill(0xFF6600, 1); buttonIndicator.graphics.drawRect(92, 2, 17, 12); addChildAt(buttonIndicator, 1); buttonIndicator2 = new Shape(); buttonIndicator2.graphics.beginFill(0x000000, 1); buttonIndicator2.graphics.drawRect(92, 12, 17, 12); addChildAt(buttonIndicator2, 1); buttonField = new TextField(); buttonField.width = 200; buttonField.height = 30; buttonField.x = -52; buttonField.y = 3; var format:TextFormat = new TextFormat(); format.align = "center"; format.size = 12; format.font = "Verdana"; format.color = "0x65ffff"; buttonField.defaultTextFormat = format; addChild(buttonField); addEventListener(MouseEvent.ROLL_OVER, onOver); addEventListener(MouseEvent.ROLL_OUT, onOut); addEventListener(MouseEvent.MOUSE_DOWN, onClick); addEventListener(MouseEvent.MOUSE_UP, offClick); addEventListener(MouseEvent.MOUSE_OVER, soundOver); mouseChildren = false; buttonMode = true; } //======================================================== //*** Functions for Button Reactions and Button Appearances for the Different Mouse Events.*** // //======================================================== public function setLabel(Label:String):void { buttonField.text = Label; } private function soundOver(e:MouseEvent):void { navRollOver.gotoSoundTime(0, true); navRollOver.volume = .05; navRollOver.playSound(); TweenLite.to(this, .5, {z: -15}); TweenMax.to(this, .5, {rotationY: -15}); } private function onOver(e:MouseEvent):void { TweenLite.to(buttonOutline, .5, {tint: 0x00ff00, ease: Quad.easeIn}); TweenLite.to(buttonIndicator, .1, {tint: 0x000000, ease: Quad.easeIn}); TweenLite.to(buttonIndicator2, .1, {tint: 0xFF6600, ease: Quad.easeIn}); } private function onOut(e:MouseEvent):void { TweenLite.to(buttonOutline, 1, {removeTint: true, ease: Quad.easeOut}); TweenLite.to(buttonIndicator, .1, {tint: 0xFF6600, ease: Quad.easeOut}); TweenLite.to(buttonIndicator2, .1, {tint: 0x000000, ease: Quad.easeOut}); TweenLite.to(this, .5, {z: 0}); TweenMax.to(this, .5, {rotationY: 0}); } private function onClick(e:MouseEvent):void { navButtonClick.gotoSoundTime(0, true); navButtonClick.volume = .1; navButtonClick.playSound(); TweenLite.to(buttonOutline, .1, {tint: 0xff0000, ease: Quad.easeIn}); TweenLite.to(buttonIndicator, .1, {tint: 0x009900, ease: Quad.easeIn}); TweenLite.to(buttonIndicator2, .1, {tint: 0x009900, ease: Quad.easeIn}); } private function offClick(e:MouseEvent):void { TweenLite.to(buttonOutline, .1, {tint: 0x00CBFF, ease: Quad.easeOut}); TweenLite.to(buttonIndicator, .1, {tint: 0xFF6600, ease: Quad.easeOut}); TweenLite.to(buttonIndicator2, .1, {tint: 0x000000, ease: Quad.easeOut}); } } } Thanks ahead of time for any responses Notice in the image that the Home Button is slightly blurred (after I moused-over once), the Contact Button is in the process of a rollover tween, and the rest of the buttons look as they should.
  16. Thank you for finding those errors for me and giving me advice. I have managed to set up my code to allow for two songs to play one after another infinitely, pause either one and unpause them at any time, stop them, and restart the entire sequence. The next thing I will be looking into is a way to control the volume with a slider of some sort. I am really a newbie to all of this, but I am really enjoying AS3 and especially the Greensock functionality. I am having a ball re-building my website from the ground up. Thanks for all of of the hard work that you guys have put into Greensock! Here is my working code: package { import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; public class MainSound extends MovieClip { // ***Site music variables.*** private var pauseButton:NavButtonScript; private var stopButton:NavButtonScript; private var playButton:NavButtonScript; private var song1:MP3Loader = new MP3Loader("http://levelforge.com/08 Hunted (Instrumental).mp3", {name: "Hunted", autoPlay: false, volume: .35, estimatedBytes: 9500}); private var song2:MP3Loader = new MP3Loader("http://levelforge.com/WITHOUT INST.mp3", {name: "Without", autoPlay: false, volume: .35, estimatedBytes: 9500}); private var queue:LoaderMax = new LoaderMax({onComplete: init}); private var queue2:LoaderMax = new LoaderMax({onComplete: init2}); public function MainSound() { queue.append(song1); queue.load(); playSong1(); song1.addEventListener(Event.SOUND_COMPLETE, done); song2.addEventListener(Event.SOUND_COMPLETE, done2); // *** Music buttons.*** pauseButton = new NavButtonScript(); pauseButton.x = 28; pauseButton.y = 115; pauseButton.setLabel("Pause"); addChild(pauseButton); TweenMax.to(pauseButton, 1, {x: 38, y: 200}); pauseButton.addEventListener(MouseEvent.CLICK, pauseSong1); stopButton = new NavButtonScript(); stopButton.x = 28; stopButton.y = 115; stopButton.setLabel("Stop"); addChild(stopButton); TweenMax.to(stopButton, 1, {x: 38, y: 250}); stopButton.addEventListener(MouseEvent.CLICK, stopAllSongs); playButton = new NavButtonScript(); playButton.x = 28; playButton.y = 115; playButton.setLabel("Play"); addChild(playButton); TweenMax.to(playButton, 1, {x: 38, y: 300}); } // *** Music control functions.*** function pauseSong1(e:MouseEvent):void { song1.soundPaused = !song1.soundPaused; } function pauseSong2(e:MouseEvent):void { song2.soundPaused = !song2.soundPaused; } function init(e:LoaderEvent):void { trace("sound1Complete"); pauseButton.addEventListener(MouseEvent.CLICK, startSequence); } function init2(e:LoaderEvent):void { trace("sound2Complete"); pauseButton.addEventListener(MouseEvent.CLICK, startSequence2); } function startSequence(e:MouseEvent):void { TweenLite.killTweensOf(playSong2); song2.pauseSound(); } function startSequence2(e:MouseEvent):void { TweenLite.killTweensOf(playSong1); song1.pauseSound(); } // ***Functions for Switching Songs.*** function done(e:Event):void { trace("done playing song1 now wait"); TweenLite.delayedCall(1, playSong2); queue2.append(song2); queue2.load(); pauseButton.removeEventListener(MouseEvent.CLICK, startSequence); pauseButton.removeEventListener(MouseEvent.CLICK, pauseSong1); pauseButton.addEventListener(MouseEvent.CLICK, pauseSong2); } function done2(e:Event):void { trace("done playing song2 now wait"); TweenLite.delayedCall(1, playSong1); queue.append(song1); queue.load(); pauseButton.removeEventListener(MouseEvent.CLICK, startSequence2); pauseButton.removeEventListener(MouseEvent.CLICK, pauseSong2); pauseButton.addEventListener(MouseEvent.CLICK, pauseSong1); } // ***Functions for playing Song1 and Song2.*** function playSong1():void { trace("Let's play song1"); song1.gotoSoundTime(0, true); song1.playSound(); } function playSong2():void { trace("let's play the next song"); song2.gotoSoundTime(0, true); song2.playSound(); } // ***Functions to Stop and Restart the Music Sequence.*** function stopAllSongs(e:MouseEvent):void { trace("All Songs Stop."); TweenLite.killTweensOf(playSong1); song1.pauseSound(); TweenLite.killTweensOf(playSong2); song2.pauseSound(); pauseButton.removeEventListener(MouseEvent.CLICK, pauseSong1); pauseButton.removeEventListener(MouseEvent.CLICK, pauseSong2); pauseButton.removeEventListener(MouseEvent.CLICK, startSequence); pauseButton.removeEventListener(MouseEvent.CLICK, startSequence2); playButton.addEventListener(MouseEvent.CLICK, restartAllSongs); } function restartAllSongs(e:MouseEvent):void { trace("Restart the Music!"); playButton.removeEventListener(MouseEvent.CLICK, restartAllSongs); song1.gotoSoundTime(0, true); song1.playSound(); pauseButton.addEventListener(MouseEvent.CLICK, pauseSong1); } } }
  17. Excellent. Thank you for the fast response. I am sorry about the misleading post. The pause button is actually working, but only if I list it to pause song1. If I list it to pause both song1 and song2, it will pause one and start the other instead of pausing all sound. I will make those changes that you listed, and I will probably no longer have this issue . I really appreciate the help!
  18. Update: I managed to get the first song to pause, even though I still get this error in my Flash Output window: TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@2bf218e1 to com.greensock.events.LoaderEvent. Code Update: package { import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; public class MainSound extends MovieClip { private var pauseButton:NavButtonScript; public function MainSound() { var song1:MP3Loader = new MP3Loader("http://levelforge.com/08 Hunted (Instrumental).mp3", {name: "Hunted", autoPlay: true, volume: .35, estimatedBytes: 9500}); var song2:MP3Loader = new MP3Loader("http://levelforge.com/WITHOUT INST.mp3", {name: "Without", autoPlay: false, volume: .35, estimatedBytes: 9500}); var queue:LoaderMax = new LoaderMax({onComplete: init}); queue.append(song1); queue.append(song2); queue.load(); playSong1(); song1.addEventListener(Event.SOUND_COMPLETE, done); song2.addEventListener(Event.SOUND_COMPLETE, done2); pauseButton = new NavButtonScript(); pauseButton.x = 28; pauseButton.y = 115; pauseButton.setLabel("Pause"); addChild(pauseButton); pauseButton.addEventListener(MouseEvent.CLICK, pauseSong); function pauseSong(e:MouseEvent):void { song1.soundPaused = !song1.soundPaused; } function init(e:LoaderEvent):void { trace("soundsComplete"); pauseButton.addEventListener(MouseEvent.CLICK, startSequence); } function startSequence(e:LoaderEvent):void { TweenLite.killTweensOf(playSong2); song2.pauseSound(); song1.gotoSoundTime(0, true); } function done(e:Event):void { trace("done playing song1 now wait"); TweenLite.delayedCall(1, playSong2); } function done2(e:Event):void { trace("done playing song2 now wait"); TweenLite.delayedCall(1, playSong1); } function playSong1():void { trace("Let's play song1"); song1.gotoSoundTime(0, true); song1.playSound(); } function playSong2():void { trace("let's play the next song"); song2.gotoSoundTime(0, true); song2.playSound(); } } } } The problem with my current setup is that I can pause the first song, but I cannot pause the second song. If I add this code: function pauseSong(e:MouseEvent):void { song1.soundPaused = !song1.soundPaused; song2.soundPaused = !song2.SoundPaused; } It will pause the first song, start the second. Hit the button again it pauses the second song and starts the first.
  19. I received this error when trying to make a PauseButton work with my cycling MP3's. TypeError: Error #1034: Type Coercion failed: cannot convert flash.events::MouseEvent@2b17b8e1 to com.greensock.events.LoaderEvent. My code is working as I want it to work (First song plays, waits, second song plays, waits, do it again on and on), but I would also like the PauseButton functionality to work as well. Everytime I click on the PauseButton I get the error. I am very new to AS3, so it is probably a simple thing that I have done wrong. Happy Holidays everyone!!! Code: package { import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import flash.display.MovieClip; import flash.events.Event; import flash.events.MouseEvent; public class MainSound extends MovieClip { //private var song1:MP3Loader = new MP3Loader("http://levelforge.com/08 Hunted (Instrumental).mp3", { name: "Hunted", autoPlay: false, volume: .35, estimatedBytes: 9500 } ); //private var song2:MP3Loader = new MP3Loader("http://levelforge.com/WITHOUT INST.mp3", { name: "Without", autoPlay: false, volume: .35, estimatedBytes: 9500 } ); //private var queue:LoaderMax = new LoaderMax( { name: "mainQueue", onProgress:progressHandler, onComplete:completeHandler, onError:errorHandler } ); public function MainSound() { var pauseButton:NavButtonScript; var song1:MP3Loader = new MP3Loader("http://levelforge.com/08 Hunted (Instrumental).mp3", {name: "Hunted", autoPlay: true, volume: .35, estimatedBytes: 9500}); var song2:MP3Loader = new MP3Loader("http://levelforge.com/WITHOUT INST.mp3", {name: "Without", autoPlay: false, volume: .35, estimatedBytes: 9500}); var queue:LoaderMax = new LoaderMax({onComplete: init}); queue.append(song1); queue.append(song2); queue.load(); playSong1(); song1.addEventListener(Event.SOUND_COMPLETE, done); song2.addEventListener(Event.SOUND_COMPLETE, done2); pauseButton = new NavButtonScript(); pauseButton.x = 28; pauseButton.y = 115; pauseButton.setLabel("Pause"); addChild(pauseButton); pauseButton.addEventListener(MouseEvent.CLICK, toggleSong); function toggleSong(e:LoaderEvent):void { song1.soundPaused = !song1.soundPaused; } function init(e:LoaderEvent):void { trace("soundsComplete"); pauseButton.addEventListener(MouseEvent.CLICK, startSequence); } function startSequence(e:LoaderEvent):void { TweenLite.killTweensOf(playSong2); song2.pauseSound(); song1.gotoSoundTime(0, true); } function done(e:Event):void { trace("done playing song1 now wait"); TweenLite.delayedCall(1, playSong2); } function done2(e:Event):void { trace("done playing song2 now wait"); TweenLite.delayedCall(1, playSong1); } function playSong1():void { trace("Let's play song1"); song1.gotoSoundTime(0, true); song1.playSound(); } function playSong2():void { trace("let's play the next song"); song2.gotoSoundTime(0, true); song2.playSound(); } } } } Your tools and forums are awesome btw! Thanks for putting these amazing tools out there for us!
  20. Wow, I knew it had to be something simple. I missed the purpose of the move code all together. That was exactly my problem >.< Thank you very much for the fix and the link! It will take me some time to get used to it, but the efficiency and power of doing most of my animations through script seems immense! Happy Holdays everyone
  21. Hello and I am sorry for posting an error that has been answered many times over. None of the answers really helped me solve what I am doing wrong. So here is what I am trying to do. I am brand new to AS3 as well, which does not help >.< I have a main movie, and I have added another movie at a certain point in my main timeline. 1. When I created the small movie within the main one, I chose to Export to Actionscript and set the class to an AS file that I created earlier. The new movie is called "TitleClip" and it is assigned to the AS file "TitleClip." I just added TitleClip to the Class field before saving the new movie. 2. My TitleClip AS packet has this code inside of it: package { import flash.display.*; import com.greensock.*; import com.greensock.easing.*; public class TitleClip extends MovieClip { public function TitleClip() { trace(TitleClip); TweenMax.to(TitleClip, 1, {delay:2, bevelFilter:{blurX:10, blurY:10, strength:5, angle:45, distance:10}, ease:Quad.easeIn}); } } } I get this error no matter what I try: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.greensock.plugins::FilterPlugin/initFilter() at com.greensock.plugins::BevelFilterPlugin/onInitTween() at com.greensock::TweenLite/init() at com.greensock::TweenMax/init() at com.greensock::TweenMax/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll() I am new to all of this and probably making a very stupid error, so I am sorry for that and any help will be greatly appreciated Basically I just want to know how to packet my AS into movies that I create on the stage so that they can run their code when loaded. I want to keep my main movie's Actions panel as simple as possible. I have done most of my tweens and visuals with timeline work up until now, so the new code-driven workflows are going to take some getting used to for me. Thanks
×
×
  • Create New...