crunchie

Members
  • Content count

    15
  • Joined

  • Last visited

Community Reputation

0 Newbie

About crunchie

  • Rank
    Member
  1. Hi again. I do remove it before adding a new one using the destroy() method. I have a method in my Product Class (AddAsset($asset:DisplayObject):void). This handles both Images and Textfields but the only issue is with the textField DisplayObjects. The Images appear to come in fine. As long as I remove the width and height of the textField everything appears to work, however I now need to reload the textField information from a web service, so it may lead to complications if I cannot declare this information. I will keep you posted. Regarding the FLA, it is a bit difficult to do a simple fla as it is now quite a large class library. Thanks for your help so far.
  2. Hey there. I don't update any of the dimensions. I simply remove it from the stage and then add it back later (followed by adding it to the new transformmanager). I only set the width as above when I create the instance of the textField. Everything looks as it should until I click on it and then the text shifts.
  3. Not sure how relevant it is, but my TextField is actually a class that inherits from TextField. (AssetText)
  4. Actually using Flash CS4 with Flash player 9.
  5. *UPDATE* Jack, our application is pretty big now, so it is hard to determine exactly what is going on easily here, however I thought I should let you know that I did find the problem with the textField shifting (my previous post). If I set autoSize on the textField and I declare a width, the off axis issue appears, however if I do not declare a width, the issue vanishes. e.g. var t = new AssetText(); t.type = TextFieldType.INPUT; //t.width = (_preview.width - _textboxPadding); // IF I UNCOMMENT THIS LINE, THE TM HANDLES AND TF POSITION WILL BE COMPLETELY OFF //t.height = (_preview.height - _textboxPadding); // IF I UNCOMMENT THIS LINE, THE TM HANDLES AND TF POSITION WILL BE COMPLETELY OFF t.autoSize = TextFieldAutoSize.CENTER; t.multiline = true; t.useRichTextClipboard = false; t.wordWrap = true; t.maxChars = 100; t.embedFonts = true; t.antiAliasType = AntiAliasType.ADVANCED; t.sharpness = 100;
  6. Hi again. I decided to go back to basics and simply remove and add-back to the same bounds. With an image all is fine, but on the textfield, when I select it the text shoots off to the left and the handles are in the same place. On deselecting and the reselecting the textfield has changed position. Any ideas why this has happened? I wrote a small test to see if it was out of bounds and it isn't. Thanks
  7. Thanks for the quick reply. My situation is a little unique. Maybe if illustrate:- 1. Create a transformManager and setBounds. 2. Add a textField, move / scale / rotate it, set text. 3. If the user changes product, remove textField from stage, but keep in memory with x / y / rotation / text properties etc. Destroy current instance of transformManager 4. Create a new transformManager (with different size and setBounds based on new Product. 5. Add the textField back to the transformManager <-- (this is where my issue arises. Often the textField will now be too big and out of the bounds. I want to now determine how much I need to scale it down to fit and (with a bit of luck, scale the text accordingly. I have been looking at the matrix.scale method, and I have had limited luck with it. Alas, i don't fully understand how to use it. So far I have:- var plateRec:Rectangle = _plate.getBounds(this); // TransformManager Bounds var tfRec:Rectangle = _tf.getBounds(_plate); // textField bounds var matrx:Matrix = new Matrix(); matrx.scale((plateRec.width / tfRec.width),(plateRec.height / tfRec.height)) if(matrx.a < 1 && matrx.d < 1) { _tf.transform.matrix = matrx; } if(matrx.a < 1 && matrx.d > 1) { _tf.transform.matrix = new Matrix(matrx.a,0,0,1,0,0); } if(matrx.a > 1 && matrx.d < 1) { _tf.transform.matrix = new Matrix(1,0,0,matrx.d,0,0); } Thanks for your help so far. [edit] I am using AS3 [/edit]
  8. Hi. Unfortunately geometry is not my strong point and I am on a deadline. I am trying to determine if a textfield is larger and / or outside the bounds of the transformManager. If it is larger, I need to scale it and make sure it is always in the confines of the transformManager space. On a side note, i need to scale the size of the text accordingly. Can someone explain the best way to go about this please? Thanks in advance
  9. crunchie

    getBounds help

    I am using a slider component to scale my transform item, however my (poor) calculation as to what max width and height could be for the item is flawed and the max width or height ends up bigger than it should be when i set the slider to max. I believe that i need to compare the transform bounds to the items bounds and work it out from there. Unfortunately, i am not well versed in geometry and was hoping that someone could shed some light on how to do this based on the current rotation / scale of the transform item. Thanks very much, Dave
  10. Ok, got it now /* transformManagerSelectedItemChanged Description: When an item is selected via the transform manager */ public function transformManagerSelectedItemChanged($e:TransformEvent):void { trace("\n\nTransformManager Items selected: " + $e.items.length); // Loop through selected list, get original type and // process accordingly for(var i=0; i<$e.items.length; i++) { var d:DisplayObject = $e.items[i].targetObject; trace(d is AssetImage); // True if(d is AssetImage) { // dispatch AssetImage selected event. } } } Thanks for all your help, crunchie
  11. To elaborate a bit, i want to do something like:- if ($e.items[i].targetObject is AssetImage) { } if($e.items[i].targetObject is Textfield) { } if($e.items[i].targetObject is Movieclip) { }
  12. I have tried this, but it still returns an object of type TransformItem, but i want the original type (in this case AssetImage).
  13. Hi again. Maybe by posting this code i am over complicating the question? I simply want to loop through the Transform items on TransformEvent.SELECTION_CHANGE and get each TransformItem's original type, whether that be a Movieclip, Textfield or AssetImage. Is there anyway i can do this? The error is in the TransformEvent.SELECTION_CHANGE handler when i try and get the targetobject:- /* transformManagerSelectedItemChanged Description: When an item is selected via the transform manager */ public function transformManagerSelectedItemChanged($e:TransformEvent):void { trace("\n\nTransformManager Items selected: " + $e.items.length); // Loop through selected list, get original type and // process accordingly for(var i=0; i<$e.items.length; i++) { // The following line will throw an error // TypeError: Error #1034: Type Coercion failed: cannot convert gs.transform::TransformItem@1d17c0e9 to flash.display.DisplayObject. trace(_manager.getItem($e.items[i]).targetObject); } } I can add any type to the transform manager and it will throw that error. // Once asset is loaded and added to stage, add it to // the transform manager and initialise it. public function addAssetToTransformManager(a:AssetImage):void { // Init with transform manager _manager.addItem(a); }
  14. Thanks for the quick reply. Unfortunately i still get "TypeError: Error #1034: Type Coercion failed: cannot convert gs.transform::TransformItem@1cb050e9 to flash.display.DisplayObject." To explain what i am trying to achieve another way, i have added added my AssetImage to the transformmanager instance like so (where d is an AsssetImage or AssetText):- public function addAssetToTransformManager(d:DisplayObject):void { // Init with transform manager _manager.addItem(d); // Set min scale on Asset for transform manager var b:TransformItem = _manager.getItem(d); b.minScaleX = 0.1; b.minScaleY = 0.1; } Once any of these items is selected in the TransformManager, i wish to dispatch an event based on its original type:- i.e. if (g is AssetImage) { dispatchEvent(AssetEvent.ASSETIMAGE_SELECTED); } if (g is AssetText) { dispatchEvent(AssetEvent.ASSETTEXT_SELECTED); } So in essence, i want to know the original type of the TransformItem. Possibly i am going about this the wrong way? Thanks a lot, crunchie
  15. Hi there. I need to get the original class type from the selected transform item. I am doing something like this but it errors with:- TypeError: Error #1034: Type Coercion failed: cannot convert gs.transform::TransformItem@1cb050e9 to flash.display.DisplayObject. _manager.addEventListener(TransformEvent.SELECTION_CHANGE, transformManagerSelectedItemChanged); public function transformManagerSelectedItemChanged($e:TransformEvent):void { trace("\n\nTransformManager Items selected: " + $e.items.length); // Loop through selected list, get original type and // process accordingly for(var i=0; i<$e.items.length; i++) { var g:* = _manager.getItem($e.items[i]); if(g is AssetImage) { // Process AssetImage trace("Selected Item Type is: AssetImage"); } if(g is AssetText) { // Process AssetText trace("Selected Item Type is: AssetText"); } } } AssetImage and AssetText both inherit from MovieClip and simply have additional properties. Thanks in advance, crunchie