Jump to content
Search Community

mrEmpty

Members
  • Posts

    140
  • Joined

  • Last visited

Everything posted by mrEmpty

  1. No! Go to the pub on a Saturday night or try new Greensock features... hmmm.
  2. The same code will work, just assign an event listener to start the function running. So remove up(); from the main body, and replace it with an: addEventListener(MouseEvent.MOUSE_DOWN, up); So that way the movie clip will sit still until you mouse down. Of course you'll need a helper function to handle the mouse event, and a second main function to hold the tween. Anyway, another zip attached. Click the box...
  3. Ahh, in that case use a fromTo. TweenLite.fromTo(myMC, 1, {y:600},{y-100});
  4. Did you call your up function? up(); Also, you need to put a negative value to make it move up, my bad. I come from iOS so I keep getting -/+ mixed up zip attached.
  5. Thank you, I forgot about this question. Thanks for that, I'll download and try it out now. One thing, if you click reverse on yours, you have to click forward twice to get it working. This is the problem I currently have.
  6. private function up():void { TweenMax.to(movieclip, 1, {y:movieclip.y + 10, ease:Linear.easeNone, onComplete:up}); }
  7. Hello. BlitMask is the bomb! Wow! I'm still not getting more than 11fps on my Galaxy tablet I've been given for testing, but on a PC system, woah! Woosh. Anyway, I'm using BitmapMode to keep things fast. I have noticed that is I wish to use wrap, I cannot disable bitmap mode? Is this correct? It seems to be that the original items need to be visible on stage at the end of a tween to be able to interact with them, hence the disabling the bitmap mode. That makes sense I guess, but I wanted to clarify that? For example, if I had three stage size movie clips on the stage, they are children of another movie clip which is the target for the blitmask. These movie clips have simple interaction in them, lets say a little round sprite that grows if you mouse over. I want those three movie clips to tween left and wrap, or right, or both, but the wrap is important. Blitmask does this for me (thanks Mr. Greensock, the purchase was worth it to support this alone) but onComplete:disableBitmapMode will then kill the wrap, and the clips may be way off stage at this point. See the issue? Any way around it? I have read the documentation And I have a sample FLA I can post.
  8. I solved it, it was the BlitMask. The correct code is: bMask = new BlitMask(master, master.x, master.y, master.width, master.height);
  9. OK. I've moved the creation of the BlitMask to after the for loop: private function setupMain(event:LoaderEvent):void { var panels:XMLList = event.target.content.panel; for (var i:int = 0; i < panels.length(); i++) { var box:NavBox = new NavBox(800, 450); master.addChild(box); box.x = box.width * i; } confMaster(); } private function confMaster():void { addChild(master); bMask = new BlitMask(master, 0, stage.stageHeight, stage.stageWidth, stage.stageHeight); bMask.smoothing = true; bMask.wrap = true; } So now I'm loading the XML, creating an XMLList, using that to create my instance of NavBox and adding them to master. I then run a function (confMaster) that adds master (which has 5 instance of NavBox in it) and creates the blitmask. Still not joy though
  10. Hello. I have a strange problem, I'm using LoaderMax in the code but I don't think that's the problem. But as I really can't figure this out, and a simpler version of this code without LoaderMax works, I thought I'd post. I have an empty MovieClip: public var master:MovieClip = new MovieClip(); I'm using a for loop to run through an XMLList populated with stuff from an XMLLoader: private function setupMain(event:LoaderEvent):void { trace("setupMain"); var panels:XMLList = event.target.content.panel; trace(panels.length()); for (var i:int = 0; i < panels.length(); i++) { trace("for start"); var box:NavBox = new NavBox(800, 450); master.addChild(box); box.x = box.width * i; box.y = 100; trace(box.x); trace(box.y); } } The problem is, the instances of box do not appear. If I add them to the stage they do, but if I add them to master they don't. If I trace the positions it appears as if they are added to the display list, but they don't show up. Now, if I ignore the entire loading thing this problem goes away. But I don't think LoaderMax is the issue at all. Complete code just in case it helps: package { import flash.display.MovieClip; import flash.display.DisplayObject; import flash.text.GridFitType; import mx.core.BitmapAsset; import flash.events.MouseEvent; import com.greensock.loading.LoaderMax; import com.greensock.loading.ImageLoader; import com.greensock.events.LoaderEvent; import com.greensock.loading.XMLLoader; import com.greensock.BlitMask; import com.greensock.TweenMax; import com.fingerpuk.ui.NavBox; public class Treasures03 extends MovieClip { //embed the background image [Embed(source="assets/Grid.png")] const Grid:Class; //create master container public var master:MovieClip = new MovieClip(); //create my BlitMask private var bMask:BlitMask = new BlitMask(master, 0, stage.stageHeight, stage.stageWidth, stage.stageHeight); public function Treasures03() { init(); } private function init():void { //configure the BlitMask bMask.smoothing = true; bMask.wrap = true; //load the background image var grid:DisplayObject = new Grid(); addChild(grid); //configure the master addChild(master); trace("master added"); //load and parse the config xml var xmlLoader:XMLLoader = new XMLLoader("assets/config.xml", {onComplete:setupMain}); xmlLoader.load(); //set up test listener on stage, delete later master.addEventListener(MouseEvent.MOUSE_DOWN, testBlit); } private function setupMain(event:LoaderEvent):void { trace("setupMain"); var panels:XMLList = event.target.content.panel; trace(panels.length()); for (var i:int = 0; i < panels.length(); i++) { trace("for start"); var box:NavBox = new NavBox(800, 450); master.addChild(box); box.x = box.width * i; box.y = 100; trace(box.x); trace(box.y); } } private function testBlit(event:MouseEvent):void { trace("testBlit"); TweenMax.to(master, 3, {x:-3000, onUpdate:bMask.update}); } } }
  11. Well this isn't pretty but it works, kinda: private function createTimeLine():void { tl = new TimelineMax({/*onComplete:playAgain*/}); //Panel1 - Attractor tl.addLabel("Panel1", tl.duration); tl.append( TweenMax.fromTo( Panel1, 1, {x:1280}, {x:posX, immediateRender:true})); tl.append( TweenMax.fromTo( Panel4, 1, {x:posX}, {x:-1280, onComplete:tl.pause, immediateRender:false}), -1); //Panel2 tl.addLabel("Panel2", tl.duration); tl.append( TweenMax.fromTo( Panel2, 1, {x:1280}, {x:posX, immediateRender:true})); tl.append( TweenMax.fromTo( Panel1, 1, {x:posX}, {x:-1280, onComplete:tl.pause, immediateRender:false}), -1); //Panel3 tl.addLabel("Panel3", tl.duration); tl.append( TweenMax.fromTo( Panel3, 1, {x:1280}, {x:posX, immediateRender:true})); tl.append( TweenMax.fromTo( Panel2, 1, {x:posX}, {x:-1280, onComplete:tl.pause, immediateRender:false}), -1); //Panel4 tl.addLabel("Panel4", tl.duration); tl.append( TweenMax.fromTo( Panel4, 1, {x:1280}, {x:posX, immediateRender:true})); tl.append( TweenMax.fromTo( Panel3, 1, {x:posX}, {x:-1280, onComplete:tl.pause, immediateRender:false}), -1); } private function goForward(event:MouseEvent):void { if (currentPanel < 1) { currentPanel = 4; } else if (currentPanel > 4) { currentPanel = 1; } tl.gotoAndPlay("Panel" + currentPanel); currentPanel = currentPanel + 1; trace("Panel" + currentPanel); trace("play"); } private function goBackward(event:MouseEvent):void { if (currentPanel > 4) { currentPanel = 1; } else if (currentPanel < 1) { currentPanel = 4; } tl.gotoAndPlay("Panel" + currentPanel); currentPanel = currentPanel - 1; trace("reverse"); trace("Panel" + currentPanel); } What I need to work out is why I can't get the labelled tweens to play in reverse. And I'd like to work out why Carl's code works and mine doesn't.
  12. I've been going through Carl's wonderful video tutorials, and I noticed he was doing something very similar to what I want to do. So I'm using the pause and play method to start and stop my timeline. However, when I get to the last tween in the timeline, it restarts straight away without using the pause: tl.addLabel("Panel1", tl.duration); tl.append( TweenMax.fromTo( Panel1, 1, {x:1280}, {x:posX, immediateRender:true})); tl.append( TweenMax.fromTo( Panel4, 1, {x:posX}, {x:-1280, alpha:0, onComplete:tl.pause, immediateRender:false}), -1); //Panel2 tl.addLabel("Panel2", tl.duration); tl.append( TweenMax.fromTo( Panel2, 1, {x:1280}, {x:posX, alpha:1, immediateRender:true})); tl.append( TweenMax.fromTo( Panel1, 1, {x:posX}, {x:-1280, alpha:0, onComplete:tl.pause, immediateRender:false}), -1); //Panel3 tl.addLabel("Panel3", tl.duration); tl.append( TweenMax.fromTo( Panel3, 1, {x:1280}, {x:posX, alpha:1, immediateRender:true})); tl.append( TweenMax.fromTo( Panel2, 1, {x:posX}, {x:-1280, alpha:0, onComplete:tl.pause, immediateRender:false}), -1); //Panel4 tl.addLabel("Panel4", tl.duration); tl.append( TweenMax.fromTo( Panel4, 1, {x:1280}, {x:posX, alpha:1, immediateRender:true})); tl.append( TweenMax.fromTo( Panel3, 1, {x:posX}, {x:-1280, alpha:0, onComplete:tl.pause, immediateRender:false}), -1); With regards to my initial problem, I had a thought just now so wil try then and report back.
  13. Hello. I'm using TimelineMax to create something very simple, items scroll in from the right and move to the left, one item per button press. Have to say, TimelineMax is making this very easy I'm pausing the timeline after each object tweens, and then using timeline.play(); in a function, called from a button, to play the next tween. It's working well. What I'd like to do is to use another movie clip to play the tweens backwards, again one at a time. However, if I call timeline.reverse(); if plays through the entire timeline ignoring the pauses. I wondered if I should be using labels and some logic to work out where I am, then playing the corresponding labels part of the timeline in reverse?
  14. I'll give that a go later and see if it works. I think you get what I'm asking, and that code looks like what was in my head. Thank you
  15. Don't worry, I have no idea how to explain it. I'll try to draw it up in a few scribbles. Basically, I want to get values of where the mouse is in X from the edge of a sprite or movie clip. That's fine. What I then want to do is divide the width of said sprite or movie clip by n (for ease we'll say 10) and as the mouse moves over each point given by n (in this case, 0, 10, 20, 30, 40, 50, 60 70, 80, 90) something happens. So if you are under 10, you trace out "I am under 10", as you move into under 20, it traces "20" etc etc. It's like a very granular version of tracking the mouseX.
  16. Hello. Not sure how to describe this. Imagine a square sprite, 200 pixels. Now imagine that sprite contains a sprite which is 800 pixels wide. That sprite is split into 4 200pixel squares itself. As you move your mouse from far left to far right of the first sprite, the second wider sprite moves the other way. That's all good. Now, the bit I'm having difficulty working out. The second sprite is split into 4 section, I want to take the position of the cursor, and feed that into the tween so that as we get within x pixels of 0, 25, 50, 75% etc the sprite tweens at that point. So at far left, sprite section 1 is showing in the top sprite, we move slowly to the right, when we get near 25% the sprite section 2 tweens in, 50% sprite section 3 tweens in etc. I can deal with taking the width of the sprite and working out the points the tween should fire at, but the (if within x pixels of) part I can't fathom. Any ideas? Cheers
  17. In Flash have you set up your paths correct? On the main bar, screen right, next to the stage size params there is a little Spanner icon (all from my head this is, so it may be slightly off). Click that, you'll get all the info about your FLA and how it'll compile etc. Anyway, in there you can set up where your external libraries are. Put the com folder into a folder called something like Actionscript on the root of your drive or wherever you are happy to have it, and add that folder to the libraries list.
  18. You mean the default built-in Flash XMLLoader? OK, I'll take a look into that. Thank you.
  19. Hello. After lots of very fun fiddling with LoaderMax it's time to build something real. I have a need to display many types of content (images, custom nested movieclip, SWF, video player etc into an app, each to be treated as a separate page which you flick through. That's all fine and dandy, I can cope with all of that. What I need to know is is my thought process for the loading correct? I was thinking of loading in the XML, and running it through a loop. For each of the items (for example, I haven't started so all this is made up) I'd check the type and then run a switch or conditional. If content is SWF for example it would use a SWF loader and pass that thing onto he stage or wherever it ends up. If it's MC it would use then run through all the sub0tags and fill an instance of that custom movieclip with the content. Is that a sensible way, or should I look into using LoaderMax in the XML file itself? The content will be updated by non-programmers, who are used to seeing basic XML but nothing more than a bunch of human readable tags with words or a URL in-between. I'm really looking forward to tackling this. Although I'm still very new to Flash and have only 5 days to get this built. :s Cheers.
  20. One thing, what are these parameters on the end of a ThrowProps instance? etc etc}}, 1, 0.3, 1);
  21. Replace my last function with this, very small change here, and it works... private function _mouseUpHandler(event:MouseEvent):void { removeEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); mouseUX = mouseDX; mouseDX = mouseY; vy = mouseDX - mouseUX; if (Math.abs(mouseDX - mouseUX) > tolerance) { trace("Mouse up was not within range of mouse down (10px), so is not a button press"); ThrowPropsPlugin.to(newMC, {throwProps:{y:{velocity:vy*2, min:bounds.top, max:bounds.bottom}, resistance:20}}, 10, 0.25, 1); } else if (Math.abs(mouseDX - mouseUX) < tolerance) { trace("Mouse up was within range of mouse down (10px), so is a button press :)"); //and will it work? No! trace("the detected button press was on: " + event.target.name); } } So you can use ThrowProps (which rocks) along with nested sprites or movie clips and know which button you clicked if you are within a range you can set, otherwise it'll be a throw with an ignored button press. Flash is so much fun I'm now going to make something much less ugly.
  22. Hello. I don't know why I asked the question! I know I can use a standard tween to trace the mouse, but last night after not mooch sleep for a few days I had a moment of clarity about an idea to do with DynamicProps and it following the mouse! But I cannot for the life of me remember what it was. However, thank you for answering.
  23. Hello. With DynamicProps, is it possible to keep it hunting for the mouse even it it reaches it? In the example when it hits the target it stops, I'd like it to keep going. Cheers.
  24. Hello. Tidied it a little bit, maybe I should start a new thread but this is all to do with the same thing I guess? package { import flash.display.MovieClip; import flash.events.*; import flash.utils.getTimer; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; import com.greensock.loading.display.ContentDisplay; import com.greensock.TweenMax; import com.greensock.*; import com.greensock.easing.*; import com.greensock.plugins.*; TweenPlugin.activate([ThrowPropsPlugin]); public class Panels extends MovieClip { public var pWidth:Number; public var pHeight:Number; public var tolerance:Number = 10; //tolerance for mouse down up tracking public var mouseDX:Number; public var mouseUX:Number; public var bounds:Object = {top:50, bottom:-150}; public var vy:Number = 0; public var dragging:Boolean = false; public var offset:Number; public var newMC:MovieClip = new MovieClip(); public function Panels() { var xmlLoader:XMLLoader = new XMLLoader("assets/panels.xml", {onComplete:xmlCompleteHandler}); xmlLoader.load(); pWidth = 320; pHeight = 181; addChild(newMC); newMC.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDownHandler, false, 0, true); newMC.addEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler, false, 0, true); mouseDX = newMC.y; mouseUX = newMC.y; } private function xmlCompleteHandler(event:LoaderEvent):void { var panels:XMLList = event.target.content.panel; var panelsText:XMLList = event.target.content.dText; var queue:LoaderMax = new LoaderMax({maxConnections:1}); for (var i:int = 0; i < panels.length(); i++) { queue.append(new ImageLoader("assets/" + panels[i].@file, {name:"panel" + i, description:panels[i].@dText, numb:[i], onComplete:setupPanels}) ); } queue.load(); } private function setupPanels(event:LoaderEvent):void { var pane:panel= new panel(event.target.content, event.target.vars.description); pane.y = (event.target.vars.numb * pHeight); pane.alpha = 0; newMC.addChild(pane); TweenMax.to(pane, 1,{alpha:1, delay:0.25}); } private function _mouseDownHandler(event:MouseEvent):void { TweenMax.killTweensOf(newMC); dragging = true; //i am now dragging offset = newMC.mouseY; //setting the offset from the origin addEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); mouseDX = mouseY; } private function _mouseMoveHandler(event:MouseEvent):void { newMC.y = mouseY - offset; //move the movieclip with the mouse (in Y only) taking into account that offset } private function _mouseUpHandler(event:MouseEvent):void { dragging = false; //i am not dragging removeEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler); mouseUX = mouseY; //_mouseLogic(); //here we go, let's make this better... or really screw things up mouseUX = mouseDX; mouseDX = mouseY; vy = mouseDX - mouseUX; if (Math.abs(mouseDX - mouseUX) > tolerance) { trace("Mouse up was not within range of mouse down (10px), so is not a button press"); ThrowPropsPlugin.to(newMC, {throwProps:{y:{velocity:vy, min:bounds.top, max:bounds.bottom}, resistance:20}}); } else if (Math.abs(mouseDX - mouseUX) < tolerance) { trace("Mouse up was within range of mouse down (10px), so is a button press :)"); //and will it work? trace("the detected button press was on: " + event.target); } } } } It all works apart from: a: cannot get to which nested movie clip has been clicked on and b: I don't like the motion of the throw. I need to read up more about the properties it needs. Anyway, if anyone has any suggestions...
×
×
  • Create New...