Jump to content
GreenSock

Aksel

Members
  • Posts

    10
  • Joined

  • Last visited

Aksel's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. This worked fine.t.hanks alot. Will need to read up on timelinelite anyways it seem to get it to pause properly upon mouse rollover.
  2. Thanks Really getting closer to completing this finally now all due to your great help Basically now the slideshow works as intended.. and i've rewritten the code ...however it seems that after the first round of slides..it shows the first image again..and then it stops tweening. I've tried tracing some output and see that the code still keeps running through the diffirent switch functions which i've created..but the first image just stands there without fading out after the first round. This is the code I'm using now: public class mySlideshow extends MovieClip { private var fadeTid:int = 3; // her styres farten på fade-effekten private var pauseTid:int = 4; // her styres tiden hvert bilde vises før ny overgang starter // ---------------------------------------------------------------------------------------------------------- var bildeKlipp = new bilde1(); var bildeKlipp2 = new bilde2(); var bildeKlipp3 = new bilde3(); var fade_in1:TweenLite = TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 1, paused: true}); var fade_ut1:TweenLite = TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 0, paused: true}); var fade_in2:TweenLite = TweenLite.to(bildeKlipp2, fadeTid,{autoAlpha: 1, paused:true}); var fade_ut2:TweenLite = TweenLite.to(bildeKlipp2, fadeTid,{autoAlpha: 0, paused: true}); var fade_in3:TweenLite = TweenLite.to(bildeKlipp3, fadeTid,{autoAlpha: 1, paused:true}); var fade_ut3:TweenLite = TweenLite.to(bildeKlipp3, fadeTid,{autoAlpha: 0, paused:true}); public function mySlideshow():void{ bildeKlipp.x = 0; bildeKlipp.y = 0; bildeKlipp.alpha = 1; bildeKlipp.buttonMode = true; bildeKlipp.name = "bilde1"; this.addChild(bildeKlipp); bildeKlipp2.x = 0; bildeKlipp2.y = 0; bildeKlipp2.buttonMode = true; bildeKlipp2.name = "bilde2"; this.addChild(bildeKlipp2); TweenLite.to(bildeKlipp2,0,{autoAlpha: 0}); bildeKlipp3.x = 0; bildeKlipp3.y = 0; bildeKlipp3.buttonMode = true; bildeKlipp3.name = "bilde3"; this.addChild(bildeKlipp3); TweenLite.to(bildeKlipp3,0,{autoAlpha: 0}); pauseFunksjon("start1"); } public function startTween(c:String):void{ switch(c){ case "start1": fade_ut1.play(); fade_in2.play(); pauseFunksjon("start2"); break; case "start2": fade_ut2.play(); fade_in3.play(); pauseFunksjon("start3"); break; case "start3": fade_ut3.play(); fade_in1.play(); pauseFunksjon("start1"); break; } } public function pauseFunksjon(b:String):void{ switch({ case "start1": TweenLite.delayedCall(pauseTid, startTween,["start1"]); break; case "start2": TweenLite.delayedCall(pauseTid, startTween, ["start2"]); break; case "start3": TweenLite.delayedCall(pauseTid, startTween, ["start3"]); break; } } Any ideas why the fadefunction of the images stop after "bildeKlipp" (image1) displays for the second time? }
  3. Hi, thanks for replying I'm getting sooomewhat closer (babysteps! ).. I'll paste my current code in as I started over again to regain som control over what actually is happening here hehe package{ import com.greensock.TweenLite; import com.greensock.plugins.TweenPlugin; import com.greensock.plugins.AutoAlphaPlugin; TweenPlugin.activate([AutoAlphaPlugin]); import flash.display.MovieClip; import flash.events.MouseEvent; import flash.net.URLRequest; import flash.net.navigateToURL; public class mySlideshow extends MovieClip { private var bilde1_adresse:String = "url1"; private var bilde2_adresse:String = "url2"; private var bilde3_adresse:String = "url3"; private var bilde4_adresse:String = "url4"; private var fadeTid:int = 2; // duration of the fade private var pauseTid:int = 3; // duration of pause // ---------------------------------------------------------------------------------------------------------- private var request1:URLRequest = new URLRequest(bilde1_adresse); private var request2:URLRequest = new URLRequest(bilde2_adresse); private var request3:URLRequest = new URLRequest(bilde3_adresse); private var request4:URLRequest = new URLRequest(bilde4_adresse); var bildeKlipp = new bilde1(); var bildeKlipp2 = new bilde2(); var bildeKlipp3 = new bilde3(); var tween1:TweenLite = TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 0}); var tween2:TweenLite = TweenLite.to(bildeKlipp2, fadeTid,{autoAlpha: 1, onComplete:testPause}); public function mySlideshow():void{ bildeKlipp.x = 0; bildeKlipp.y = 0; bildeKlipp.alpha = 1; bildeKlipp.buttonMode = true; bildeKlipp.name = "bilde1"; this.addChild(bildeKlipp); bildeKlipp2.x = 0; bildeKlipp2.y = 0; bildeKlipp2.buttonMode = true; bildeKlipp2.name = "bilde2"; this.addChild(bildeKlipp2); TweenLite.to(bildeKlipp2,0,{autoAlpha: 0}); TweenLite.delayedCall(pauseTid, startTween1); } public function startTween1():void{ trace("in tween1"); tween1.play(); tween2.play(); } public function testPause():void{ trace("in testpause"); } } } I need to have the tween variables availible to other functions.. Seems now that the tweens are triggered already upon declaration of tween1, tween2 etc.. bildeKlipp starts tweening as soon as the movie starts. What I wish is that bildeKlipp is visible upon start of the movie..then after end of TweenLite.delayedCall(pauseTid, startTween1); it should start to tween as stated in the function "startTween1".
  4. Hmm.. but I had already created a function which had both tween1(); and tween2(); inside... Still it seems to wait until tween1(); completes before starting on tween2(); The variables contains the following: var tween1:TweenLite = TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 0}); var tween2:TweenLite = TweenLite.to(bildeKlipp2, fadeTid,{autoAlpha: 1, onComplete:testPause}); Where fadeTid is an int telling how long the fadeeffect should last.
  5. Hi guys, thanks again for your quick replies I've managed to resolve the errors. Was creating the variable containing the tween in the wrong place Now...on to another probably very basic / silly question I'm trying to do the following in a function: tween1.play(); tween2.play(); Basically tween1 is fading OUT one image and tween2 is fading IN another image... Doesn't seem to go quite well though as it keeps waiting until tween1 is completely faded out before starting to fade in image2.. Any advice on how to accomplish the wanted effect? (i want the images to cross-fade into one another
  6. Hi, thanks alot for your quick reply I'm trying to put the tweens into variable like this: var tween1:TweenLite = TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 0}); then i try to start it : tween1.play(); But i keep getting spammed with these errors: Error: Cannot tween a null object. at com.greensock::TweenLite() at com.greensock::TweenLite$/to() at gamezoneSlideshow() TypeError: Error #1006: value is not a function. at com.greensock::TweenLite/renderTime() at com.greensock.core::SimpleTimeline/renderTime() at com.greensock::TweenLite$/updateAll() So obviously I'm doing something wrong here
  7. Hi, I've created a slideshow using your fine tweenlite class. First off...it's probably created really poorly regarding effectiveness and should be using arrays instead of hard code each function to each seperate movieclip. But my coding skills are not quite up there and had to do it this way Any tips here are appriciated though. And a question I have is...I need to make a mouse event listener which pauses the current tween when the mouse if rolling over the scene. Any advice on how to achieve this? Here is my code: package{ import com.greensock.TweenLite; import com.greensock.plugins.TweenPlugin; import com.greensock.plugins.AutoAlphaPlugin; TweenPlugin.activate([AutoAlphaPlugin]); import flash.display.MovieClip; import flash.events.MouseEvent; import flash.net.URLRequest; import flash.net.navigateToURL; public class mySlideshow extends MovieClip { // --------------------------------------------------------------------------------------------------------------------------------------- private var bilde1_adresse:String = "some-url-here"; private var bilde2_adresse:String = "some-url-here"; private var bilde3_adresse:String = "some-url-here"; private var bilde4_adresse:String = "some-url-here"; private var fadeTid:int = 2; // fading time private var pauseTid:int = 3; // pausetime private var bildeAntall:int = 3; // 3 or 4 images ? // ------------------------------------------------------------------------------------------------------------------------------------ private var bildeKlipp:MovieClip; private var bildeKlipp2:MovieClip; private var bildeKlipp3:MovieClip; private var bildeKlipp4:MovieClip; private var request1:URLRequest = new URLRequest(bilde1_adresse); private var request2:URLRequest = new URLRequest(bilde2_adresse); private var request3:URLRequest = new URLRequest(bilde3_adresse); private var request4:URLRequest = new URLRequest(bilde4_adresse); public function mySlideshow():void{ bildeKlipp = new bilde1(); bildeKlipp.x = 0; bildeKlipp.y = 0; bildeKlipp.alpha = 1; bildeKlipp.buttonMode = true; bildeKlipp.addEventListener(MouseEvent.CLICK, clickHandler); bildeKlipp.addEventListener(MouseEvent.MOUSE_OVER, overHandler); bildeKlipp.addEventListener(MouseEvent.MOUSE_OUT, outHandler); bildeKlipp.name = "bilde1"; this.addChild(bildeKlipp); bildeKlipp2 = new bilde2(); bildeKlipp2.x = 0; bildeKlipp2.y = 0; bildeKlipp2.buttonMode = true; bildeKlipp2.addEventListener(MouseEvent.CLICK, clickHandler2); bildeKlipp2.addEventListener(MouseEvent.MOUSE_OVER, overHandler); bildeKlipp2.addEventListener(MouseEvent.MOUSE_OUT, outHandler); bildeKlipp2.name = "bilde2"; this.addChild(bildeKlipp2); TweenLite.to(bildeKlipp2,0,{autoAlpha: 0}); bildeKlipp3 = new bilde3(); bildeKlipp3.x = 0; bildeKlipp3.y = 0; bildeKlipp3.buttonMode = true; bildeKlipp3.addEventListener(MouseEvent.CLICK, clickHandler3); bildeKlipp3.addEventListener(MouseEvent.MOUSE_OVER, overHandler); bildeKlipp3.addEventListener(MouseEvent.MOUSE_OUT, outHandler); bildeKlipp3.name = "bilde3"; this.addChild(bildeKlipp3); TweenLite.to(bildeKlipp3,0,{autoAlpha: 0}); if(bildeAntall==4){ bildeKlipp4 = new bilde4(); bildeKlipp4.x = 0; bildeKlipp4.y = 0; bildeKlipp4.buttonMode = true; bildeKlipp4.addEventListener(MouseEvent.CLICK, clickHandler4); bildeKlipp4.addEventListener(MouseEvent.MOUSE_OVER, overHandler); bildeKlipp4.addEventListener(MouseEvent.MOUSE_OUT, outHandler); bildeKlipp4.name = "bilde4"; this.addChild(bildeKlipp4); TweenLite.to(bildeKlipp4,0,{autoAlpha: 0}); } startTween(); } public function startTween():void{ TweenLite.delayedCall(pauseTid, startTween1); } public function startTween1():void{ if(bildeAntall==4){ TweenLite.to(bildeKlipp4, fadeTid,{autoAlpha: 0}); } else{ TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 0}); TweenLite.to(bildeKlipp2, fadeTid,{autoAlpha: 1, onComplete:testPause}) } } public function testPause():void{ TweenLite.delayedCall(pauseTid, startTween2); } public function startTween2():void{ TweenLite.to(bildeKlipp2, fadeTid,{autoAlpha: 0}); TweenLite.to(bildeKlipp3, fadeTid,{autoAlpha: 1, onComplete:testPause2}); } public function testPause2():void{ trace("her da?"); TweenLite.delayedCall(pauseTid, startTween3); } public function startTween3():void{ trace("hmm"); TweenLite.to(bildeKlipp3, fadeTid,{autoAlpha: 0}); if(bildeAntall==4){ TweenLite.to(bildeKlipp4, fadeTid,{autoAlpha: 1, onComplete:pause3}); } else{ trace("tjoho!"); TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 1, onComplete:pause4}); } } public function pause3():void{ TweenLite.delayedCall(pauseTid, startTween4); } public function startTween4():void{ TweenLite.to(bildeKlipp4, fadeTid,{autoAlpha: 0}); TweenLite.to(bildeKlipp, fadeTid,{autoAlpha: 1, onComplete:pause4}); } public function pause4():void{ TweenLite.delayedCall(pauseTid, startTween1); } public function clickHandler(e:MouseEvent):void{ try{ navigateToURL(request1, '_self'); } catch(e:Error){ trace("En feil oppstod"); } } public function clickHandler2(e:MouseEvent):void{ try{ navigateToURL(request2, '_self'); } catch(e:Error){ trace("En feil oppstod"); } } public function clickHandler3(e:MouseEvent):void{ try{ navigateToURL(request3, '_self'); } catch(e:Error){ trace("En feil oppstod"); } } public function clickHandler4(e:MouseEvent):void{ try{ navigateToURL(request4, '_self'); } catch(e:Error){ trace("En feil oppstod"); } } public function overHandler(e:MouseEvent):void{ switch(e.target.name){ case "bilde1": // need some way to pause the current tween here... break; case "bilde2": // need some way to pause the current tween here... break; case "bilde3": // need some way to pause the current tween here... break; case "bilde4": // need some way to pause the current tween here... break; } } public function outHandler(e:MouseEvent):void{ trace("ute igjen!"); } } }
  8. Thanks for your reply Now I have a few more (probably stupid) questions...but bare with me please This is the code I have now to load the xml file and its images: script.as: package scriptet{ import com.greensock.loading.ImageLoader; import com.greensock.events.LoaderEvent; import com.greensock.*; import com.greensock.loading.*; import com.greensock.loading.display.*; import flash.display.Sprite; import flash.utils.Timer; public class script extends Sprite{ var my_speed:Number; var my_total:Number; var my_images:XMLList; var my_timer:Timer; public function script(){ LoaderMax.activate([imageLoader]); var loader:XMLLoader = new XMLLoader("slideshow.xml", {onComplete:completeHandler, estimatedBytes:50000}); loader.load(); function completeHandler(event:LoaderEvent):void { trace("XML and queue1 loaded!"); addChild( LoaderMax.getContent("image1") ); addChild( LoaderMax.getContent("image2") ); addChild( LoaderMax.getContent("image3") ); //grab the LoaderMax named "queue2" that was defined in the XML and start loading it now var queue2:LoaderMax = LoaderMax.getLoader("queue2"); queue2.addEventListener(LoaderEvent.COMPLETE, queue2CompleteHandler); queue2.load(); } function queue2CompleteHandler(event:LoaderEvent):void { trace("queue2 loaded!"); } } } } Slideshow.xml: <?xml version="1.0" encoding="iso-8859-1"?> Now from what I understand, the first image is loaded by itself and displayed before it starts loading queue # 2. Which is great, and what I wanted to do. Now for the next goal: Start the slideshow, tweening between the images loaded. Preferably with a timer speed set up in the XML file which I had in my old code like this: my_speed=my_xml.@SPEED; This didn't seem to work with the greensock.loading.XMLLoader class. I'm also trying to attach a link to each images set in the xml file. In my old code i just used the "Title" tag in the xml file where i set up a clickable link which is added to each image in the slideshow. Sorry again for probably some complete basic questions here...but I'm very new to this so trying to learn as I go. Thanks in advance for any help you might provide!
  9. Hi all. I've been struggling a bit with a slideshow I'm trying to create. It's working at the moment as intended..however.. Currently I'm preloading some images from my xml file..apparantly it loads all images before displaying them. As you noticed by now probably, i'm very new to flash, so excuse my ignorance to the field What I'm trying to achieve is: Preload the FIRST image and displaying it, before loading the other images so that there won't be an empty stage while the user waits for the other images to load. I just recently came across the Loading class you have ..and haven't yet managed to implement this..so I hope you wizards may help me on my way The current code I've been using is: import fl.transitions.Tween; import fl.transitions.easing.*; import fl.transitions.TweenEvent; var my_speed:Number; var my_total:Number; var my_images:XMLList; Mouse.cursor = "button"; var my_loaders_array:Array=[]; var my_labels_array:Array=[]; var my_success_counter:Number=0; var my_playback_counter:Number=0; var my_slideshow:Sprite = new Sprite(); var my_image_slides:Sprite = new Sprite(); var my_label_slides:Sprite = new Sprite(); var my_preloader:TextField; var my_timer:Timer; var my_prev_tween:Tween; var my_tweens_array:Array=[]; var my_xml_loader:URLLoader = new URLLoader(); my_xml_loader.load(new URLRequest("forside.xml")); my_xml_loader.addEventListener(Event.COMPLETE, processXML); function processXML(e:Event):void { var my_xml:XML=new XML(e.target.data); my_speed=my_xml.@SPEED; my_images=my_xml.IMAGE; my_total=my_images.length(); loadImages(); my_xml_loader.removeEventListener(Event.COMPLETE, processXML); my_xml_loader=null; } function loadImages():void { for (var i:Number = 0; i < my_total; i++) { var my_url:String=my_images[i].@URL; var my_loader:Loader = new Loader(); my_loader.load(new URLRequest(my_url)); my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); my_loaders_array.push(my_loader); var my_label:TextField = new TextField(); my_label.text=my_images[i].@TITLE; my_label.autoSize=TextFieldAutoSize.LEFT; my_labels_array.push(my_label); } my_preloader = new TextField(); my_preloader.text="Laster inn bilder..."; my_preloader.autoSize=TextFieldAutoSize.CENTER; my_preloader.x = (stage.stageWidth - my_preloader.width)/2; my_preloader.y = (stage.stageHeight - my_preloader.height)/2; addChild(my_preloader); } function onComplete(e:Event):void { my_success_counter++; if (my_success_counter==my_total) { startShow(); } var my_loaderInfo:LoaderInfo=LoaderInfo(e.target); my_loaderInfo.removeEventListener(Event.COMPLETE, onComplete); } function startShow():void { removeChild(my_preloader); my_preloader=null; addChild(my_slideshow); my_slideshow.addChild(my_image_slides); my_slideshow.addChild(my_label_slides); nextImage(); my_timer=new Timer(my_speed*1000); my_timer.addEventListener(TimerEvent.TIMER, timerListener); my_timer.start(); } function nextImage():void { var my_image:Loader=Loader(my_loaders_array[my_playback_counter]); my_image.addEventListener(MouseEvent.CLICK, klikketbilde); my_image_slides.addChild(my_image); my_image.x = (stage.stageWidth - my_image.width)/2; my_image.y = (stage.stageHeight - my_image.height)/2; my_tweens_array[0]=new Tween(my_image,"alpha",Strong.easeOut,0,1,1,true); var my_label:TextField=TextField(my_labels_array[my_playback_counter]); my_label_slides.addChild(my_label); my_label.x=my_image.x; my_label.y=my_image.y+my_image.height; my_tweens_array[1]=new Tween(my_label,"alpha",Strong.easeOut,0,1,1,true); } function timerListener(e:TimerEvent):void { hidePrev(); my_playback_counter++; if (my_playback_counter==my_total) { my_playback_counter=0; } nextImage(); } function hidePrev():void { var my_image:Loader=Loader(my_image_slides.getChildAt(0)); my_prev_tween=new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true); my_prev_tween.addEventListener(TweenEvent.MOTION_FINISH, onFadeOut); var my_label:TextField=TextField(my_label_slides.getChildAt(0)); my_tweens_array[2]=new Tween(my_label,"alpha",Strong.easeOut,1,0,1,true); } function onFadeOut(e:TweenEvent):void { my_image_slides.removeChildAt(0); my_label_slides.removeChildAt(0); } function klikketbilde(e:MouseEvent):void{ var my_image:Loader=Loader(my_loaders_array[my_playback_counter]); my_timer.stop(); //my_images[i].@TITLE; switch(my_image.name){ case "instance4": navigateToURL(new URLRequest(my_images[0].@TITLE),"_self"); break; case "instance7": navigateToURL(new URLRequest(my_images[1].@TITLE),"_self"); break; case "instance10": navigateToURL(new URLRequest(my_images[2].@TITLE),"_self"); break; case "instance13": navigateToURL(new URLRequest(my_images[3].@TITLE),"_self"); break; case "instance16": navigateToURL(new URLRequest(my_images[4].@TITLE),"_self"); break; case "instance19": navigateToURL(new URLRequest(my_images[5].@TITLE),"_self"); break; } }
×