Jump to content
GreenSock

mrEmpty

Members
  • Posts

    140
  • Joined

  • Last visited

Posts posted by mrEmpty

  1. Hello.

     

    OK, now I have managed to purchase (happy face) I gave this a go. It's not perfect, and I just tacked it onto some previous experiment so there may be code in there thats not doing anything, but anyway:

     

    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;
    
    	//test throw vars - how many?!?!???!?!?!
    	public var tolerance:Number = 10;  //tolerance for mouse down up tracking
    	public var mouseDX:Number;
    	public var mouseUX:Number;
    	public var bounds:Object = {top:400, bottom:400};
    	public var currentY:Number;
    	public var lastY:Number;
    	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);
    
    		currentY = newMC.y;
    		lastY = newMC.y;
    	}
    
    	private function xmlCompleteHandler(event:LoaderEvent):void
    	{
    		//take the panel tags from the xml and put them in an xml list array
    		var panels:XMLList = event.target.content.panel;
    		var panelsText:XMLList = event.target.content.dText;
    		var queue:LoaderMax = new LoaderMax({maxConnections:1});
    		//run through a loop for each panel item
    		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 _mouseUpHandler(event:MouseEvent):void
    	{
    		dragging = false;  //i am not dragging
    		removeEventListener(MouseEvent.MOUSE_MOVE, _mouseMoveHandler);
    		mouseUX = mouseY;
    		_mouseLogic();
    	}
    
    	private function _mouseMoveHandler(event:MouseEvent):void
    	{
    		newMC.y = mouseY - offset;  //move the movieclip withthe mouse (in Y only) taking into account that offset
    	}
    
    	//if the mouse up is not within 10 pixels of the mouse down, we can ignore it as a click and just work on it as a throw...
    	private function _mouseLogic():void
    	{
    		lastY = currentY;
    		currentY = mouseY;
    		vy = currentY - lastY;
    
    		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:50}, ease:Strong.easeOut});
    		}
    		else if (Math.abs(mouseDX - mouseUX) < tolerance)
    		{
    			trace("Mouse up was within range of mouse down (10px), so is a button press :)");
    		}
    	}
    
    
    }
    }

     

    This lets you drag, when you release it checks the distance between mouse down and up and if it's within tolerance it considers it a click, otherwise it doesn't. The Throwprops is fed last and currentY (which are actually the same as mouseUX and mouseDX so I should reuse them - doh) and from that you can get the throwing. Like I say, it's not great and needs me to spend more than 30 minutes on it.

     

    Current problems I'm having are the drag performance isn't too great and I need to work out which nester movie clip I'm over if a click is considered a click. I may roll the mouse logic into something that gets and event so I can grab the currentTarget. I think that would work? I'm still very new to Flash so feel free to laugh but know each time you do a Mongoose dies ;)

  2. Hello.

     

    I'm using Chrome and Safari on OSX 10.7 and 10.6. My ISP is Virgin Media but I've also tried Bee which use BT Internets lines (although I'm stealing that connection from down the road so it's not too reliable).

     

    As for the process, I fill out the form and submit and get a blank page which never moves forwards. I can confirm I'm not being charged. I've contacted my ISP who are looking into it.

     

    UPDATE: It worked, I just purchased. It's 100% my ISP and/or my location. I'm in my local pub using wifi and the payment page was super fast. If my ISP ever get back to me I'll forward on what they say in case it can help.

  3. //if the mouse up is not within 10 pixels of the mouse down, we can ignore it as a click and just work on it as a throw...
    	private function _mouseLogic():void
    	{
    		if (Math.abs(mouseDX - mouseUX) > tolerance)
    
    		{
    			trace("Mouse up was not within range of mouse down (10px), so is not a button press");
    		}
    		else if (Math.abs(mouseDX - mouseUX) < tolerance)
    		{
    			trace("Mouse up was within range of mouse down (10px), so is a button press :)");
    		}
    
    	}

     

    You'll need the vars to record the mouse down and up and the tolerance var sets the distance away from mouse down allowed to still consider it a click.

     

    I still can't purchase Shockingly Green as the payment page won't load, but when I do and get the throw props class I'll try this and post an example if it works. It should I think.

  4. One thing, this code:

     

    package
    {
    
    import flash.display.MovieClip;
    import com.greensock.loading.*;
    import com.greensock.events.LoaderEvent;
    import com.greensock.loading.display.ContentDisplay;
    import com.greensock.TweenMax;
    import flash.events.MouseEvent;
    
    
    public class Panels extends MovieClip
    {
    	public var maxComs:Number = 2;
    	public var pWidth:Number;
    	public var pHeight: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);
    		stage.addEventListener(MouseEvent.MOUSE_UP, _mouseUpHandler, false, 0, true);
    	}
    
    	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();
    		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 {
    		trace(event.target.vars.numb);
    		var pane:panel= new panel(event.target.content, event.target.vars.description);
    		pane.alpha = 1;
    		pane.y = (event.target.vars.numb * pHeight);
    		pane.alpha = 0;
    		newMC.addChild(pane);
    
    		TweenMax.to(pane, 1,{alpha:1});
    	}
    
    	private function _mouseDownHandler(event:MouseEvent):void
    	{
    		newMC.startDrag();
    	}
    
    	private function _mouseUpHandler(event:MouseEvent):void
    	{
    		newMC.stopDrag();
    	}
    
    
    }
    
    }

     

    which loads the images and the text, puts them into the container class and put them into an empty movieclip in a column, traces the number i as it loads each image. It traces 1, 2, 3, 4, 0 but never 5. And it traces them in order: 1, 0, 3, 2, 4. Why is this?

  5. Oh sorry, yeah that kinda reads bad! I meant thanks to saying I'd come a long way progress wise, when really it's all just a mix of Google and your help. So I wrote it to give across the opposite of what I intended. So apologies for that. You've been great.

     

    Think it's my ISP. I borrowed my neighbours wifi and that works, but it's slow and buggy. I'll try from work tomorrow.

     

    So now the basics are working, I better think up something pretty to do with it, fill it with cool stuff and test it on an Android tablet. :)

     

    Thanks again for all the help. And apologies for my innate ability to offend.

  6. Hello.

     

    Thanks :) But not really. Google plus your tutorials and the stuff on the LoaderMax page have really helped. It's now working. In the end I wrote something similar for iOS, then wrote that using standard AS3 syntax from the Obj-C code, then took that and replaced the standard stuff with the LoaderMax stuff. Hey, if it works!

     

    But the goldmine you gave me was the text in the Vars. Wow. I like that.

     

    And LoaderMax (which assume simply extends the default XML stuff then adds loads of cool stuff?) seems faster. That may just be my excitement though.

     

    I'm having real trouble purchasing the Extremely Green, wondering if it's my ISP as when I choose to purchase my browser just sits there. But I 100% am buying. I wanna trow me some stuff around and split up some text along with loading many things from an XML file. :D

     

    Have to ay I didn't want to move to Flash but this is a giggle.

  7. Hello :)

     

    Day 2 of my real attempt to get Actionscript to make sense to me. :) It's proving hard because all I do is play with TweenMax and wonder why it doesn't exist for iOS. Anyhoo...

     

    Not sure if this is appropriate and if it is, if this is the correct place. So please delete and shout at me if needs be.

     

    I have a custom class, a basic UI reusable test thing. It's class code:

     

    package  {
    
    import flash.display.MovieClip;
    import flash.display.Sprite;
    
    
    public class panel extends MovieClip {
    	private var panelSprite:Sprite = new Sprite();
    
    	public function panel(pText:String, pSprite:Sprite) {
    		//create and place the sprite
    		panelSprite.width = 320;
    		panelSprite.height = 151;
    		panelSprite.x = panelSprite.y = 0;
    		addChildAt(panelSprite, 0);
    
    		//populate my panel
    		panelText.text = pText;
    		panelSprite = pSprite;
    	}
    }
    
    }

     

    Now, as you can see it demands a sprite and some text. My XML contains both (shamelessly stolen from Jack)...

     

    <?xml version="1.0" encoding="utf-8"?>
    
    
    
    
    
    
    

     

    I want to create a new instance of my custom class and fill each one with an image and the corresponding string. So I load up the XML...

     

    public function Panels()
    	{
    		//read the XML
    		var xmlLoader:XMLLoader = new XMLLoader("assets/panels.xml", {onComplete:xmlCompleteHandler});
    		xmlLoader.load();
    	}

     

    Then my thought would be to run through a loop and pass the stuff through. Here I hit a tree...

     

    private function xmlCompleteHandler(event:LoaderEvent):void
    	{
    		//take the panel tags from the xml and put them in an xml list array
    		var panels:XMLList = event.target.content.panel;
    		var panelsText:XMLList = event.target.content.dText;
    		var queue:LoaderMax = new LoaderMax();
    		//run through a loop for each panel item
    		for (var i:int = 0; i < panels.length(); i++)
    		{
    			//add an image loader for each panel item
    			queue.append(new ImageLoader("assets/" + panels[i].@file, {}); //err, um, what happens now?
    		}
    	}

     

    You see I thought I'd go through the panel tags, and for each one I'd create a new panel. panel wants a sprite which would be the image, but it also needs a string. I can get one or the other to work, but not both. Do I need to create two loaders, images and strings, then do another loop to create the panel classes and pass through the data from two arrays created by the original two loaders? Or what? This is making me crazy (in a good way) and the ark nights and nicely bubbling dumpling stew isn't helping me concentrate.

     

    So please help otherwise my waistline will expand even more and my knowledge will stay small and shrivelled.

     

    Thank you.

  8. Blimey, that's a nice response :)

     

    Jumping straight to the license, I only need to purchase if I want the extra stuff? I could code the extra bit I want using TweenMax, but it's good to support this stuff so I'll buy it anyway. Just waiting for my confirmation e-mail to let me purchase :)

     

    I've seen your tutorial, good job. I'll go through it again as I watched it whilst stressed and asleep.

     

    Today my plan is to take the ugliest UI component ever made and get it populated with data. I have managed this with E4X, but I have a feeling LoaderMax will be worth knowing for future projects.

     

    As for the move from iOS. I'll keep doing that, in my oen time and maybe freelance, but my new job is almost 100% Flash based. I took it for the opportunity to learn a new tech properly and because it allows me to be in charge of my own projects. No doubt I'll move back to Cocoa and iOS again, or maybe mix it all up. I do love the idea of how easy it is to publish AIR for Android though. May buy a Samsung tablet today... :)

     

    Must convince the lady first though ;)

     

    Thanks.

  9. Hello :)

     

    I'm used to developing for the iPhone, so Obj-C is my tool of choice, coupled with XCode. Flash is very strange to me, it does alien things. ;) Anyway, I better start getting to grips with it because I've got a job which involves using it for 95% of my time. So much for all the effort to learn to develop for iOS. I'm about to purchase a Shockingly Green for myself.

     

    To the point (sorry, rambling). I can get LoaderMax to load in a collection of images and stick them on my screen. They load from a standard XML with no specific LoaderMax stuff in it, this is key for me as if I do end up using it at work they will be giving me normal XML. What I now need to figure out (and remember, I've been doing AS3 seriously since 10am GMT today) is how to use it to populate a nested Movieclip of stuff. Is there anything online I could be pointed towards? I can provide more info and my current code if that would help?

     

    And one more thing. My new job is for a not-for-profit organisation. After playing with TweenMax for a bit I know I want all of the Greensock stuff available to me as my deadlines will be mental tight. What do we need to purchase?

  10. Hello.

     

    Using this code:

     

    swatchWaveTimeline.insertMultiple([new TweenLite(card001, 2, { rotationZ:-25 } ),
    											new TweenLite(card002, 2, { rotationZ:-25 } ),
    											new TweenLite(card003, 2, { rotationZ:-25 } ),
    											new TweenLite(card004, 2, { rotationZ:-25 } ),
    											new TweenLite(card005, 2, { rotationZ:-25 } ),
    											new TweenLite(card006, 2, { rotationZ:-25 } )],
    											0, TweenAlign.START,
    											0.2);										
    
    		swatchWaveTimeline.insertMultiple([new TweenLite(card001, 2, { rotationZ:25 } ),
    											new TweenLite(card002, 2, { rotationZ:25 } ),
    											new TweenLite(card003, 2, { rotationZ:25 } ),
    											new TweenLite(card004, 2, { rotationZ:25 } ),
    											new TweenLite(card005, 2, { rotationZ:25 } ),
    											new TweenLite(card006, 2, { rotationZ:25 } )],
    											3, TweenAlign.START,
    											0.2);

     

    with this timeline var:

     

    var swatchWaveTimeline:TimelineMax = new TimelineMax({repeat:-1, repeatDelay:0});

     

    works fine, but after the first complete cycle, the movie clips snap back to 0 rotation before going to positive 25, then to neg 25, then snap back to 0 and start again. Do I need to tell TweenMax/Lite to use the current value as the starting value?

     

    Thank you.

     

    E.

  11. Hello.

     

    I have a question regarding TweenGroup. I have a series of 6 movieclips, I want them to rotate 30 degrees one way, stagger 0.5 seconds between them, then onComplete rotate 30 degrees the other way, same stagger, then repeat.

     

    So far it seems I need to call a function on a mouse event to start the first tween series, then call a second function to do the second tween, then call a third function to start the third tween etc etc. Can I simple get TweenGroup to tween one way with stagger, then reverse, with stagger?

     

    Regards.

     

    E.

×