[Flashcoders] AS3.0 - add separate objects to stage
Hi, Whenever I issue a command addChild(bitmap) the new image is being merged with the existing one. How do I make sure the new image is added as a separate display object? This is true for both, bitmap shape data. I think this has something to do with the BitmapData class. Thanks, Petro ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS3.0 - add separate objects to stage
Are you sure about this? I have been using bitmaps extensively in the project im working on and have had no issues like this. What is the structure of children like? Sprite - - Bitmap - Bitmap I would have to see some code to help out. Jim -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Petro Bochan Sent: 20 December 2006 08:24 To: Flashcoders mailing list Subject: [Flashcoders] AS3.0 - add separate objects to stage Hi, Whenever I issue a command addChild(bitmap) the new image is being merged with the existing one. How do I make sure the new image is added as a separate display object? This is true for both, bitmap shape data. I think this has something to do with the BitmapData class. Thanks, Petro ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com -- No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.432 / Virus Database: 268.15.24/592 - Release Date: 18/12/2006 13:45 ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS3.0 - add separate objects to stage
James Tann Are you sure about this? I have been using bitmaps extensively in the project im working on and have had no issues like this. What is the structure of children like? Sprite - - Bitmap - Bitmap I would have to see some code to help out. Jim Hi James, This is not the pure example code from the project but this kind of resembles the idea. package { import flash.display.Sprite; import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.events.IOErrorEvent; import flash.display.Bitmap; import flash.events.MouseEvent; import flash.utils.Timer; import flash.events.TimerEvent; import flash.display.BitmapData; public class addChildIssue extends Sprite { public function addChildIssue() { var timer:Timer = new Timer(5000); timer.addEventListener(TimerEvent.TIMER, onTimer); timer.start(); var uploader:Loader = new Loader(); var url:URLRequest = new URLRequest(); url.url = http://www.venturaes.com/macromedia/images/studio8_box.jpg;; uploader.contentLoaderInfo.addEventListener(Event.COMPLETE, onResult); uploader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onFault); uploader.load(url); } private function onResult(anEvent:Event):void { var bitmap:Bitmap = Bitmap(anEvent.target.content); bitmap.addEventListener(MouseEvent.MOUSE_DOWN, onDrag); bitmap.addEventListener(MouseEvent.MOUSE_UP, onDrop); addChild(bitmap); } private function onFault(anEvent:Event):void { } private function onDrag(anEvent:MouseEvent):void { anEvent.target.startDrag(); } private function onDrop(anEvent:MouseEvent):void { anEvent.target.stopDrag(); } private function onTimer(anEvent:TimerEvent):void { var uploader:Loader = new Loader(); var url:URLRequest = new URLRequest(); url.url = http://wwwimages.adobe.com/www.adobe.com/products/audition/images/audit ion_flash.jpg; uploader.contentLoaderInfo.addEventListener(Event.COMPLETE, onResult); uploader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onFault); uploader.load(url); } } } -- Copy and past it into Flex, should work. I even now face the problem of not being able to move any image at all. This works fine with shapes, but bitmaps fail. Thanks, Petro ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS3.0 - add separate objects to stage
Is this even possible, bitmap not being an interactiveObject and all? In your first post you said: Whenever I issue a command addChild(bitmap) the new image is being merged with the existing one. I guess the images are just stacked on top of eachother here where the last bitmap loaded loads on top of the older one. In your script below you add 2 bitmaps to a Sprite and want to use mouse stuff on the bitmap, I guess that that won't work because they are not of type interactiveObject I guess that creating a sprite, add the bitmap to the sprite, add the listeners to the sprite, and add the sprite to the displaylist of your class(sprite)should work. -Oorspronkelijk bericht- Van: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Namens Petro Bochan Verzonden: woensdag 20 december 2006 12:52 Aan: Flashcoders mailing list Onderwerp: RE: [Flashcoders] AS3.0 - add separate objects to stage James Tann Are you sure about this? I have been using bitmaps extensively in the project im working on and have had no issues like this. What is the structure of children like? Sprite - - Bitmap - Bitmap I would have to see some code to help out. Jim Hi James, This is not the pure example code from the project but this kind of resembles the idea. package { import flash.display.Sprite; import flash.display.Loader; import flash.net.URLRequest; import flash.events.Event; import flash.events.IOErrorEvent; import flash.display.Bitmap; import flash.events.MouseEvent; import flash.utils.Timer; import flash.events.TimerEvent; import flash.display.BitmapData; public class addChildIssue extends Sprite { public function addChildIssue() { var timer:Timer = new Timer(5000); timer.addEventListener(TimerEvent.TIMER, onTimer); timer.start(); var uploader:Loader = new Loader(); var url:URLRequest = new URLRequest(); url.url = http://www.venturaes.com/macromedia/images/studio8_box.jpg;; uploader.contentLoaderInfo.addEventListener(Event.COMPLETE, onResult); uploader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onFault); uploader.load(url); } private function onResult(anEvent:Event):void { var bitmap:Bitmap = Bitmap(anEvent.target.content); bitmap.addEventListener(MouseEvent.MOUSE_DOWN, onDrag); bitmap.addEventListener(MouseEvent.MOUSE_UP, onDrop); addChild(bitmap); } private function onFault(anEvent:Event):void { } private function onDrag(anEvent:MouseEvent):void { anEvent.target.startDrag(); } private function onDrop(anEvent:MouseEvent):void { anEvent.target.stopDrag(); } private function onTimer(anEvent:TimerEvent):void { var uploader:Loader = new Loader(); var url:URLRequest = new URLRequest(); url.url = http://wwwimages.adobe.com/www.adobe.com/products/audition/images/audit ion_flash.jpg; uploader.contentLoaderInfo.addEventListener(Event.COMPLETE, onResult); uploader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onFault); uploader.load(url); } } } -- Copy and past it into Flex, should work. I even now face the problem of not being able to move any image at all. This works fine with shapes, but bitmaps fail. Thanks, Petro ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
RE: [Flashcoders] AS3.0 - add separate objects to stage
Simon In your script below you add 2 bitmaps to a Sprite and want to use mouse stuff on the bitmap, I guess that that won't work because they are not of type interactiveObject I guess that creating a sprite, add the bitmap to the sprite, add the listeners to the sprite, and add the sprite to the displaylist of your class(sprite)should work. Hi Simon, Worked out seamlessly, thanks a lot! Cheers, Petro ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com