Jump to content
Search Community

Handycam

Members
  • Posts

    46
  • Joined

  • Last visited

Everything posted by Handycam

  1. Figured it out. It did not like me adding certain items between the mxml tags.
  2. I just added a transform mgr I had used in a previous Flex 4 project to a new Flex 4 project, but now when I run the app I get the errror: TypeError: Error #1009: Cannot access a property or method of a null object reference. at com.greensock.transform::TransformManager/updateSelection()[/users/stevelombardi/Documents/WORK/Game Development/Tests/src/com/greensock/transform/TransformManager.as] at com.greensock.transform::TransformManager/set lineColor()[/users/stevelombardi/Documents/WORK/Game Development/Tests/src/com/greensock/transform/TransformManager.as] at com.greensock.transform::FlexTransformManager/set lineColor()[/users/stevelombardi/Documents/WORK/Game Development/Tests/src/com/greensock/transform/FlexTransformManager.as] at TransformTests/init()[/users/stevelombardi/Documents/WORK/Game Development/Tests/src/TransformTests.mxml] at TransformTests/___TransformTests_Application1_creationComplete()[/users/stevelombardi/Documents/WORK/Game Development/Tests/src/TransformTests.mxml] at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[E] at mx.core::UIComponent/set initialized()[E] at mx.managers::LayoutManager/doPhasedInstantiation()[E] at mx.managers::LayoutManager/doPhasedInstantiationCallback()[E] Although if I dismiss the error, the transform mgr seems to work fine...
  3. I am trying to create a looping sequence of several images in Flash that fade from one to the next every 3 seconds. So far, I have the images on the stage, one atop the previous each in its own layer, as in: pic3 pic2 pic1 I set the all to alpha 0 on the properties panel then did this: var slideDelay:int = 3; var timeline:TimelineMax = new TimelineMax({repeat:-1}); timeline.append( TweenMax.fromTo(p1, 2, {alpha:0}, {alpha:1})); timeline.append( TweenMax.fromTo(p2, 2, {alpha:0}, {alpha:1}),slideDelay); timeline.append( TweenMax.fromTo(p3, 2, {alpha:0}, {alpha:1}),slideDelay); The problem is in trying to loop back to the beginning smoothly. Any suggestions?
  4. I wound up adding a function call whenever I add or remove an item to update the boolean. I think all I'd need, though, is to make the "items" variable bindable. I can try it out; where is this variable set in your code?
  5. I have a button I was trying to enable only if there are items in the transform manager: But it is not enabling when I add items to the transform manager. Am I missing something?
  6. Well, if I leave lockScale false (default), can I instead intercept the onScale command and prevent it from continuing?
  7. I have an application wherein the user must do something first before they can scale items. I know how to lockScale, which might suffice, but I might want to show the resize cursor, yet display a message (and/or play a sound, or something else) when the user actually tries to do the resize. Is this possible? How might I implement this?
  8. Yes, that was it. I had no idea. Thanks! myManager.ignoredObjects = [downBtn,upBtn];
  9. I see there are two methods: moveSelectionDepthDown():void Moves the selection down one level. moveSelectionDepthUp():void Moves the selection up one level. Are there any examples on how to apply these methods to a selection? I'd like to make "move forward" and "move backward" buttons, but not sure how. I have created a button with a function: protected function button1_clickHandler(event:MouseEvent):void { myManager.moveSelectionDepthDown(); } but nothing happens.
  10. Interesting, I need to do this very thing. But what's not clear to me is this line: var atm:TransformManager = fooClip._tm; // my active TransformManager Which is your active transform manager? atm or fooClip._tm? My TM is called "myManager", so I tried var atm:TransformManager = myManager; But this gives an error: 1067: Implicit coercion of a value of type com.greensock.transform:FlexTransformManager to an unrelated type com.greensock.transform:TransformManager. So I tried modifying the code as below. Also I didn't see any variable declarations for depthID or depthCounter, so I added two ints below as well. This throws an error when I assign it to a button and run it, same error. private var depthID:int; private var depthCounter:int; //method to move up depth private function swapDepthsGO($e:MouseEvent) : void { var objectsLen:int = myManager.targetObjects.length; // length of all items which are registered with the TransformManager depthCounter = 0; // inits my depth counter depthID = setInterval(moveSelectionDepth,5,myManager,objectsLen,1); // starts changing the depth 1 = up || -1 = down } //method to move down depth private function swapDepthsGU($e:MouseEvent) : void { var objectsLen:int = myManager.targetObjects.length; // length of all items which are registered with the TransformManager depthCounter = 0; // inits my depth counter depthID = setInterval(moveSelectionDepth,5,myManager,objectsLen,1); // starts changing the depth 1 = up || -1 = down } private function moveSelectionDepth($atm:TransformManager,$len:int,$direction:int=1):void{ if(++depthCounter>$len){ clearInterval(depthID); }else { if($direction==-1){ $atm.moveSelectionDepthDown(); }else{ $atm.moveSelectionDepthUp(); } } }
  11. I am using it like this: And it seems to work fine, FWIW.
  12. I tried that. But, it should be noted that this works: var item:TransformItem = myManager.addItem(e.target as DisplayObject); myManager.selectItem(item); So it is getting the object that should be selected. It just doesn't appear on the stage unless added in the first function. Sure, here's the project.
  13. I see. This seems to work: protected function addNewItem(e:MouseEvent):void { var newImage:Image = new Image(); newImage.source = "Spiked.gif"; newImage.addEventListener(Event.COMPLETE, selectMe); newImage.x = 100; newImage.y = 200; myManager.addItem(newImage); } private function selectMe(e:Event):void { var item:TransformItem = myManager.addItem(e.target as DisplayObject); myManager.selectItem(item); e.target.removeEventListener(Event.COMPLETE, selectMe); } This adds the item and correctly selects it. But only when I have the "addItem" in the first function. If it's only in the second, nothing gets added (although the handler is called). Seems odd that I have "addItem" twice, although there seems to be (correctly) only one image.
  14. I am using the wrong event I think. So I am abandoning that methodology. I would rather just specify the width and height of the image, so that the transform item will be the right size. So why does this not work? protected function addNewItem(e:MouseEvent):void { var newImage:Image = new Image(); newImage.source = "Spiked.gif"; newImage.x = 100; newImage.y = 200; newImage.width = 48; newImage.height = 48; myManager.addItem(newImage); myManager.selectItem(newImage); } I can also embed the image, which also works but is less than practical. [Embed(source="Sunflower.gif")] public static const flower:Class; protected function addNewItem(e:MouseEvent):void { var newImage:Image = new Image(); newImage.source = flower; newImage.x = 100; newImage.y = 200; myManager.addItem(newImage); myManager.selectItem(newImage); }
  15. No, doesn't work. Complains with the line var item:TransformItem = myManager.addItem(e.target); cannot coerce item object to item display object. I give up. Let's say in most cases I know the size of the image I am adding. Then, why wouldn't this work: protected function addNewItem(src:String):void { var newImage:Image = new Image(); newImage.source = src; myManager.addItem(newImage); newImage.width = 48; newImage.height = 48; newImage.x = 100; newImage.y = 200; myManager.selectItem(newImage); }
  16. I get the concept, if not the methodology. I tried this, but I'm not sure how to then get the TransformItem I want highlighted from the first function to the second: protected function addNewItem(src:String):void { var newImage:Image = new Image(); newImage.source = src; newImage.addEventListener(FlexEvent.UPDATE_COMPLETE, selectMe); myManager.addItem(newImage); newImage.x = 100; newImage.y = 200; } private function selectMe(e:FlexEvent):void { trace("update complete"); }
  17. This is all I am doing: <?xml version="1.0" encoding="utf-8"?> xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minWidth="955" minHeight="600" xmlns:transform="com.greensock.transform.*" creationComplete="init()">
  18. I tried that, but it didn't seem to work. I notice now that it is, in fact, selected, except there is no bounding box (or, there is an incorrect one): If I de-select it and then click again, I get the correct transform frame:
  19. I was wondering how I could access/manage the IDs of individual transform items, especially those I add dynamically. I was thinking two things: 1. get what was clicked on. So if the user clicks on an image of a dog, I display dog items (as in "if e.currentTarget.id =='collie' then showDogs()") Your sample code is working with the array of all selected items, how to wok with individual items in the selection? private function onSelectionChange($e:TransformEvent):void { trace("Changed selection. Items just selected/deselected (changed): " + $e.items.length + ", total items now selected: " + myManager.selectedItems.length);} 2. select all the items with some specified ID(s), such as "select all dogs"
  20. Actually, I am assuming you mean that to use a swf in FB4 you would do this. To use the class itself directly in FB4, I just used the sample Flex code in a new FB4 (s:Application) and it just worked.
  21. I am beginning to make a Flex 4 game with my newly-purchased Transform Manager. What I will need to do is present a user with a tile list of images, and when the user clicks one, add it to the transform manager for positioning etc. Kind of like colorforms or dress-up paper dolls. So in my initial testing, I have created a basic add an item function like: protected function button1_clickHandler(event:MouseEvent):void { var newImage:Image = new Image(); newImage.source = "Sunflower.gif"; newImage.id = "image2"; myManager.addItem(newImage); newImage.x = 100; newImage.y = 200; } This seems to work. A new sunflower is added on each click, and I can then transform it. Very sweet! Is this the proper way to go about this sort of process? And how would I make the new object appear as "selected" immediately upon adding it?
×
×
  • Create New...