Jump to content


  • Posts

  • Joined

  • Last visited

Posts posted by MDiddy

  1. I started playing with Flex Crop for a mobile app I'm building and ran across something that I think may be useful for others. Forgive me if I overlooked something existing in the API...


    I need to give users the ability to pick an area of their photo to crop to use as a thumbnail image. But there didn't appear to be a way to define a desired rect size for the crop. The crop box seemed to only be able to default to full size of the image. I was able to constrain the scale using of the crop box using the transformManager's constrainScale, but I couldn't find a way to provide a desired rect for the crop box itself.


    After digging through the class I was able to make a couple of small mods that seem to work in my instance:


    //Will be used to store the preferred default rect positioning
    protected var _cropBounds:Rectangle;
    //In the constructor
    public function FlexCrop(target:DisplayObject, manager:TransformManager, attached:Boolean=true, fillColor:uint=0x000000, alpha:Number=0, cropBounds:Rectangle = null) {
    _cropBounds = cropBounds;
    //Replaced the first line of _calibrateBox() with:
    var bounds:Rectangle = _cropBounds?_cropBounds:_target.getBounds(_target);
    Hope its helpful to someone else

  2. Hey everyone,


    I'm wondering if anyone's ever run across a class or component that will create an effect while a total is being calculated....I have to make a server call to get a value and while that's happening, I want to display a string of random numbers of a set length until the value comes back. I googled and didn't come up with anything and figured I'd ask before rolling up my own.



  3. I wouldn't call myself a seasoned vet at all. But I've been sort of monkey patching FlexTransformManager so far to do a proof of concept but sure I'd be happy to give it a go. I started using Flex back in with version 2.0 so I can certainly feel your pain. :) I avoided it unless absolutely necessary. But starting with 4.0 and the new Spark components, I"ve found that component development is much more predictable. They're much more composition-oriented than the Flex 2/3 world.

  4. Hi,


    Just wondering if you're planning on updating the TransformManager component for the latest Flash Builder updates? It seems like it extends Canvas, which isn't available for mobile devices in 4.5.1. The halo components are deprecated anyway so I just wanted to know if its on your radar?


    Thanks for a fantastic set of tools!

  5. Wow thanks alot for this. I knew it had to be simpler than I was imagining. A couple of wrinkles I'm trying to overcome now:


    Adding curved segments to the path

    Using a dashed line for part of the path


    I tried incorporating this class: http://sebastian.formzoo.com/2010/11/06 ... s-for-as3/ for dotted lines, but since its based on making its own sub lines, the path just comes out looking solid.


    I switched around your code a bit to run the onUpdate inside of each individual tween so that I could pass params for each segment. I assumed by moving the onUpdate to the individual tweens, I get the bezier values as they change, but the more I think about it - I may need to add a couple more points and adjust some of these values to get a curve parts to show:


    //XML to describe path:
    //_points is an array of objects that represent this data.
    // I have a setter for the points array in my custom class:
    public function set points(value:Array):void
    		_points = value;
    		t.data = value;
    		for (var i:uint = 0; i<_points.length; i++) {
    			var vo:Object = _points[i] as Object;
    			//vo.isSolid:Boolean that identifies whether the segment is a solid line
                                   //vo.dotted:Array (Array of dashes/gaps for the DottedLine class)
    			if(vo.isBezier) {	
    				t.append(TweenMax.to(dot, vo.duration, {bezierThrough:[{x:vo.pt.x, y:vo.pt.y}], onUpdate:drawSegment,onUpdateParams:[vo.isSolid, vo.dotted]}));
    			} else {					
    			    t.append(TweenLite.to(dot,vo.duration, {x:vo.pt.x, y:vo.pt.y, onUpdate:drawSegment, onUpdateParams:[vo.isSolid, vo.dotted]}));
    private function drawSegment(solidBool:Boolean, dottedArray:Array):void{		
    		if(isSolid) {
    		path.graphics.lineTo(dot.x, dot.y);
    	} else 
    		DashedLine.lineTo(path.graphics, dot.x, dot.y);

  6. Hi I'm looking for a little direction here. I'm not a big animator and I'm creating a map with a few points of interest and I want to animate the route connecting these points. Obviously its a little tricky because the route has to follow certain roads. The map isn't going to be used for navigation purposes so it doesn't need to be super exact. Just wondering what the best approach is to start? I was looking at bezierThrough but it seems like thats more for moving an object rather than highlighting a path.


    Any suggestions would be great


  7. Very sorry I probably shouldn't try to articulate questions that late at night. Thanks for bezierThrough suggestion. I'll do some experiments to see if I can get a satisfying effect.


    For my randomizer question, I know this is outside of the scope of TweenMax but I figured someone may have had to do something similar when creating an animation. I need to get random unique points inside of a circle to don't overlap any other shapes inside the circle. The shapes will be snowflakes all the same default size, but may be slightly scaled/blurred depending on their depth. I can get random points inside a circle using this:


    public static function getRandomPoint(radius:Number):Point {
                               // fetches a random point within this circle radius
                               var p:Point = new Point();
                               var a:Number = (Math.random()*360);
                               var r:Number = (Math.random()*radius);
                               p.x = Math.cos(a * Math.PI/180) * r;
                               p.y = Math.sin(a * Math.PI/180) * r;
                               return p;

    What I can''t seem to figure out is how to ensure that the random points aren't too close to each other. I figured I could iterate through an array of points and check each new random point against the array but I can't wrap my head around how I need to set it up. Hopefully that's a little easier to understand. Had my morning coffee :)

  8. Hey everyone


    I'm Trying to nail down a tween for an effect and I could use a little help. Basically, I'm trying to get an effect similar to a snow globe where a flake would slowly fall slighty influenced by wind. The wrinkle is that my flakes are buttons and have to generally stay where they area but instead just hover and spin and all axis.


    I've also been trying to create a randomized that will get a point that's unique where the shapes don't overlay within a circle. I've got the randomized working to get a random point inside a circle but the returned points just dont seem random enough as they frequently overlap. Any thoughts on either issue are really appreciated.


    Thnk you!

  9. Hi I'm probably doing something wrong but I can't seem to come up with the correct way to do this. I have a timeline app that I'd like to LoaderMax because it seems like it would take a ton of the hassle out of loading all the assets necessary. I have a bunch of png slices that I compose to build out most of the visuals. There are four layers of assets that slide at slightly different rates so I grouped each layer as its own LoaderMax object. My goal was to load each part (ImageLoader) then arrange them, one after the other. Here's my problem:



    When I use a width attribute with ImageLoader nodes, I get a compile error:

    ArgumentError: Error #2004: One of the parameters is invalid.

    at flash.display::Graphics/drawRect()

    at com.greensock.loading.display::ContentDisplay/set loader()

    at com.greensock.loading.display::ContentDisplay()

    at com.greensock.loading.core::DisplayObjectLoader()

    at com.greensock.loading::ImageLoader()

    at com.greensock.loading::XMLLoader$/parseLoaders()

    at com.greensock.loading::XMLLoader$/parseLoaders()

    at com.greensock.loading::XMLLoader$/parseLoaders()

    at com.greensock.loading::XMLLoader/_receiveDataHandler()

    at flash.events::EventDispatcher/dispatchEventFunction()

    at flash.events::EventDispatcher/dispatchEvent()

    at flash.net::URLLoader/onComplete()


    Is this the best practice? How can I avoid this error?

  10. I basically tried using the code form the forum post I linked to, but the sort order still seems to be off.


    private function bringForward():void
    		private function sendBackward():void
    		private function sortBoard():void
    			var clips_array:Array = flexTransformManager.targetObjects;
    			var newArray:Array = [];
    			for (var i : int = 0; i < clips_array.length; i++) {
    				clips_array[i].vo.itemDepth = i;
    				trace(i, flexTransformManager.getChildIndex(clips_array[i]));
    				newArray.push({depth: flexTransformManager.getChildIndex(clips_array[i]), item:clips_array[i]});
    			newArray.sortOn("depth", Array.NUMERIC);
    			var arrangedArray:Array = [];
    			for (var j:uint = 0; j < newArray.length; j++) {
    			//Objects are still not in the correct order in arrangedArray;

  11. Hi I have a couple of controls that utilitze the moveSelectionDepthUp() & moveSelectionDepthDown() methods but I haven't been able to find a built-in function to get an accurate depth of the items on the board t a given moment. Sorry if this has been covered before but I searched the forums and documentation and couldn't really find a definitive answer. the getChildIndex() of the targetObjects seems to be off. Any suggestions?

  12. Hi I checked the API looking for this answer but I couldn't find anything specific. Is there a quick way to throw an Alert to confirm/cancel a delete? I tried listening for the delete event and calling event.preventDefault but it appears the TransformEvents aren't cancelable. I know I can setup my own listeners and handlers - just wondering if something's built-in that I'm overlooking. Just want to take a moment to say that this component is just fantastic. The functionality packed into TransformManager is just incredible.



  13. So I'm trying to get an mx.controls.Image added to a FlexTransformManager, but if I apply verticalCenter & horizontalCenter = 0 to the control, The object can be selected, but I can't move or transform it. The bounding box seems to move, but the object just seems to keep snapping back to its original position. Here's some stub code:

    //Adding object script. The CustomImage is an extended Image with a customVO assigned to it - and the verticalCenter/horizontalCenter style set to 0;
    protected function onImageToAdd(e:CustomEvent):void
    var img:CustomImage = new CustomImage();
    img.addEventListener(CustomEvent.IMAGE_LOADED, onCustomImageLoad);
    img.customVO = e.customVO;
    img.source = e.customVO.fullImage;
    protected function onCustomImageLoad(e:BoardEvent):void
    		//Resize Image to fit and center it
    		var img:CustomImage = e.currentTarget as CustomImage;
    		img.customVO.x = img.x =  (transformManager.width)/2;
    		img.customVO.y = img.y = (transformManager.height)/2;
                           //Delay selectItem to ensure bounding box draws correctly;
    		TweenMax.delayedCall(.25, function():void{transformManager.selectItem(img);});			

    Essentially, when an image is added, I want it to default to the center of the FlexTransformManager, and be selected. This is my first time working with TransformManager, so if there's some best practices or tips anyone has based on this small chunk of code, I'd love to hear it.



  14. Thanks for the info. I signed up for the 'Really Green' membership a few months back so I had the class but never messed with it. Would you or anyone else have any links or reference sites to good FP10 3D examples or books. I'm starting to remember what scared me so much about 3D…the math. I can't even come up with an equation for the orbit path.