Share Posted May 17, 2014 I cant get crop to work, is it possible to use it with dynamically added images? var myTargets:Array = []; var manager:TransformManager = new TransformManager({targetObjects:myTargets,constrainScale:false,forceSelectionToFront:true,allowDelete:true,autoDeselect:false,handleSize:35}); Link to comment Share on other sites More sharing options...
Share Posted May 18, 2014 I don't quite follow your question. It looks like you're passing "cropMode:true" into a TransformManager which isn't right. There is no such thing. Perhaps you meant to create Crop instances first? See http://greensock.com/as/docs/transform/com/greensock/transform/Crop.html for the crop class docs. Link to comment Share on other sites More sharing options...
Author Share Posted May 18, 2014 Sorry I just pasted the wrong code in there! I'm looking a crop instance for dynamically added images, I'm adding images as there taken, to my manager function showMedia( loader:Loader ):void { loader.width = 640; loader.height = 480; loader.y = 109.35; loader.x = 160; /*loader.rotation = 90;*/ this.addChild( loader ); manager.addItem(loader); } and here is my manager var myTargets:Array = []; var manager:TransformManager = new TransformManager({targetObjects:myTargets,constrainScale:false,forceSelectionToFront:true,allowDelete:true,autoDeselect:false,handleSize:35}); in the example it shows each crop made one at a timecan I some how set up a crop with "myTargets" var mc1Crop:Crop = new Crop(mc1, manager); var mc2Crop:Crop = new Crop(mc2, manager); var mc3Crop:Crop = new Crop(mc3, manager); Link to comment Share on other sites More sharing options...
Share Posted May 19, 2014 You need to create a Crop instance for each one. And make sure you do that AFTER your image completely loads. Does that answer your question? Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 So you cant us it for dynamic content? you would need to know the name of the object your adding ? Link to comment Share on other sites More sharing options...
Share Posted May 19, 2014 Sure, you can use it for dynamic content. Just create your crop instance after you load your dynamic content. Perhaps I'm misunderstanding your question. Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 I'm not sure where to add it? Before I add it to the manager? var imageLoaderCrop:Crop = new Crop(loader); manager.addItem(loader); Link to comment Share on other sites More sharing options...
Share Posted May 19, 2014 Nope, you don't add it to the manager - the Crop does that for you. You pass the TransformManager instance to the Crop so that it knows how to associate things. Check out the example in the docs. import com.greensock.transform.*; //create the TransformManager first var manager:TransformManager = new TransformManager(); //now create Crop objects for mc1, mc2, and mc3 which are all DisplayObjects on the stage var mc1Crop:Crop = new Crop(mc1, manager); var mc2Crop:Crop = new Crop(mc2, manager); var mc3Crop:Crop = new Crop(mc3, manager); So once you create your TransformManager, you can add as many Crops as you want, whenever you want. Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 Nope, you don't add it to the manager - the Crop does that for you. You pass the TransformManager instance to the Crop so that it knows how to associate things. Check out the example in the docs. import com.greensock.transform.*; //create the TransformManager first var manager:TransformManager = new TransformManager(); //now create Crop objects for mc1, mc2, and mc3 which are all DisplayObjects on the stage var mc1Crop:Crop = new Crop(mc1, manager); var mc2Crop:Crop = new Crop(mc2, manager); var mc3Crop:Crop = new Crop(mc3, manager); So once you create your TransformManager, you can add as many Crops as you want, whenever you want. Ok but it still looks like I would need to know the name of the object, but in my code its being loaded from a camera so I don't know what the name will be? right now all the pictures loaded manager as loader and it works fine how could I add a crop into this scenario? function showMedia( loader:Loader ):void { loader.width = 640; loader.height = 480; loader.y = 109.35; loader.x = 160; /*loader.rotation = 90;*/ this.addChild( loader ); manager.addItem(loader); } Link to comment Share on other sites More sharing options...
Share Posted May 19, 2014 Try replacing this: manager.addItem(loader); ...with this: var crop:Crop = new Crop(loader, manager); But also keep in mind that you must ensure that your image has finished loading before you do this, otherwise its dimensions might actually be 0x0 when the Crop is trying to figure out its size. Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 dang, I get this eror message when I test that code Scene 1, Layer 'cam', Frame 2, Line 197 1046: Type was not found or was not a compile-time constant: Crop. Scene 1, Layer 'cam', Frame 2, Line 197 1180: Call to a possibly undefined method Crop. Note: I added import com.greensock.transform.*; and don't get the eror Link to comment Share on other sites More sharing options...
Share Posted May 19, 2014 Glad you figured out that you just needed the import statement. Is it working as expected now? Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 Yes thank you, I'm wondering why my transformManager was working with out that code? import com.greensock.transform.*; Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 Is it possible to call the crop with a button instead of double clicking? Link to comment Share on other sites More sharing options...
Share Posted May 19, 2014 Sure, you can set the Crop instance's "cropMode" to true or false whenever you want. So use a button to do it, or whatever. Link to comment Share on other sites More sharing options...
Author Share Posted May 19, 2014 Cool thanks! Link to comment Share on other sites More sharing options...
Author Share Posted June 14, 2014 I would like to use a button to turn on and off Crop,is there an equivalent to "manager.deleteSelection(); " for cropMode true? I'm adding my imageLoader to new Crop shown below: but I want to use a button "on click" to change the "cropped true" of whatever object is slected and then agin to false with a finished button.but my var crop:Crop = new Crop(imageLoader,manager); is not accessible out side the function imageLoadedso I get an error that flash docent know what Crop is?any ideas would be most welcome function imageLoaded ( event:Event ):void{ log2 ( "Image loaded asynchronously." ); imageLoader.width = 640; imageLoader.height = 480; imageLoader.y = 109.35; imageLoader.x = 660; imageLoader.rotation = 90; this.addChild ( imageLoader ); var crop:Crop = new Crop(imageLoader,manager); } Link to comment Share on other sites More sharing options...
Share Posted June 21, 2014 If I understand your question correctly, you just need to declare your variable outside your function: var crop:Crop; function imageLoaded(...) { ... crop = new Crop(...); } ..then you can still access that variable outside of that function. Link to comment Share on other sites More sharing options...
Author Share Posted June 21, 2014 Thanks for the reply, and yes ,sorry my question is confusing! what I'm wondering is is there something like manager.deleteSelection(); for cropMode true?or would it be something like crop.Selection = cropped "true";or Crop.Selection.cropMode = true; Link to comment Share on other sites More sharing options...
Share Posted June 21, 2014 Are you saying you want to remove/delete the crop, so that the whole (uncropped) DisplayObject shows? There's a destroy() method. Link to comment Share on other sites More sharing options...
Author Share Posted June 21, 2014 Thanks, I'm trying to set the Crop instance's "cropMode" to true or false with a button, but I cant find the current selection I have been trying manager.configureCropMode but no luck I tried crop.configureCropMode(true); and this function cropitFunction (event:MouseEvent):void{ this.manager.configureCropMode(true); } Link to comment Share on other sites More sharing options...
Share Posted June 25, 2014 Do you mean something like this?: button.addEventListener(MouseEvent.CLICK, toggleCropMode); function toggleCropMode(e:MouseEvent):void { this.crop.cropMode = !this.crop.cropMode; //just toggles it either direction } Link to comment Share on other sites More sharing options...
Author Share Posted June 26, 2014 Thank you Jack! thats it exactly!! Link to comment Share on other sites More sharing options...
Author Share Posted July 23, 2014 One more crop qustion, After adding images to the crop crop = new Crop(imageLoader,manager); I can no longer tween their alpha, if I set alpha to 1 it turns black TweenMax.to(manager.selectedTargetObjects,.75,{alpha:1}); Is it possible to have both? Link to comment Share on other sites More sharing options...
Author Share Posted July 23, 2014 So it looks like I'm only changing the alpha of the crop mask? is there a way to get at the image underneath? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now