[Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Hello, I have multiplayer game, which reads XML data from the server: _socket = new Socket(); _socket.addEventListener(ProgressEvent.SOCKET_DATA, handleTcpData); . private function handleTcpData(event:Event):void { while (_socket.bytesAvailable) { var str:String = _socket.readUTF(); updateGUI(str); } } In most cases it works ok, but sometimes users complain that the game hangs for them. They are able to send in commands to the server, but from their descriptions I suspect, that the function above doesn't work well for them and the updateGUI() stops being called. This issue is difficult to debug... I think my server (in Perl/C, non-forking, uses poll()) works well, I must be doing something wrong at the Flash side. Is it a good idea to call readUTF() here? It could well be that only part of the UTF string arrives and then the Flash movie would freeze in readUTF(), wouldn't it? (I've never seen that though) Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Flash app talking to iPhone app over wifi
I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] An event when a Sprite's visible changes?
Thank you! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Doing anything but copying the data from the event to your own bytearray buffer object is a disaster waiting to happen. TCP is a stream based protocol, you can get chunks of any length each time the event is reviced. Assume that the chunks are random length and piece them together in a buffer of your own. Then, once you know that you have a full logical unit, process the data. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Finding and Removing a Sprite
I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Lehr, Theodore wrote: How can I find it an remove it? You need to get a reference to it. I recommend simply storing the one you used with addChild. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
that does help - thanks... I traced the parent and get: [object MainTimeLine] How would I incorparate that into: removeChild(mySprite) ? TIA From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Hello, On Tue, Feb 23, 2010 at 2:25 PM, Henrik Andersson he...@henke37.cjb.net wrote: Doing anything but copying the data from the event to your own bytearray buffer object is a disaster waiting to happen. TCP is a stream based protocol, you can get chunks of any length each time the event is reviced. Assume that the chunks are random length and piece them together in a buffer of your own. Then, once you know that you have a full logical unit, process the data. I agree with you (from my Perl/C experience) and will switch to using ByteArray: _socket.readBytes(myByteArray, offset, _socket.bytesAvailable); Or maybe I'll start using XMLSocket (is that one safe?) The only thing I don't understand is why does ActionScript API offer a function like readUTF() if it can't be used at all? Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Event.COMPLETE Question
I presume my removeEventListener works. You should be sure. So check it: trace(e.currentTarget.hasEventListener(Event.COMPLETE)); //true e.currentTarget.removeEventListener(Event.COMPLETE, loaded); trace(e.currentTarget.hasEventListener(Event.COMPLETE)); //false So, how do I pass new values to fn loaded? Just increment the vars. // Cascade layout displayObject.x = myX + 31; displayObject.y = myY + 31; myX += 20; myY += 20; Have you considered putting your url strings into an array instead of using that awkward switch statement? I would also recommend writing a function that creates and returns BevelFilter. Set 'myBevel' once (rather than running through the code repeatedly) then apply it where appropriate. var myBevel:BevelFilter = createBevel(); function createBevel():BevelFilter{ var bf:BevelFilter = new BevelFilter(); bf.type = BitmapFilterType.OUTER; bf.distance = 10; bf.highlightColor = 0xFF; bf.shadowColor = 0x00; bf.blurX = 20; bf.blurY = 20; return bf; } // apply Bevel filter displayObject.filters = [myBevel]; Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] accessing event dispatchers in a loosely-coupled, modular design
Following the discussion about root yesterday, it got me thinking about a constant problem I face. Object-A needs to listen to events coming from objects B, C and D, but only if and when these objects actually exist. There's no guarantee that any of the objects B, C and D will be instantiated before or after A is instantiated. So, what's the proper way for A to add itself as a listener to B, C and D? What I'm currently do is this: The event dispatchers (B, C, D etc) implement a singleton interface. Within the target (A), I set up a Timer event to repeatedly check for instances of the dispatchers. Once a dispatcher is found, the target adds itself as a listener, and a pointer to the dispatcher is created so that the target can later remove itself. I'm not very happy with this design, but it's the best that I've been able to come up with. Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Hi Theodore, In your case try root.removeChild(mySprite); btw: the use of root is not recommended though. There was a discussion lately why. Maybe Jason is willing to illustrate in the case of this example? Willem On 23-feb-2010, at 15:31, Lehr, Theodore wrote: I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] accessing event dispatchers in a loosely-coupled, modular design
If an instance of those classes has been created, then it will eval to true, otherwise it will be null, so this should work for that part of the problem: if(_myinstance) _myInstance.addEventListener(myEvent, myHandler); However, if you're creating A after B, C, and D, then you'll want to call the code above from say, a Controller class whenever A is created. Once A is created, then that's a trigger to add the listeners to the other classes if they exist. Make sense? Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (inote: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Andrew Sinning Sent: Tuesday, February 23, 2010 10:04 AM To: Flash Coders List Subject: [Flashcoders] accessing event dispatchers in a loosely-coupled,modular design Following the discussion about root yesterday, it got me thinking about a constant problem I face. Object-A needs to listen to events coming from objects B, C and D, but only if and when these objects actually exist. There's no guarantee that any of the objects B, C and D will be instantiated before or after A is instantiated. So, what's the proper way for A to add itself as a listener to B, C and D? What I'm currently do is this: The event dispatchers (B, C, D etc) implement a singleton interface. Within the target (A), I set up a Timer event to repeatedly check for instances of the dispatchers. Once a dispatcher is found, the target adds itself as a listener, and a pointer to the dispatcher is created so that the target can later remove itself. I'm not very happy with this design, but it's the best that I've been able to come up with. Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
RE: [Flashcoders] Finding and Removing a Sprite
tried that... no dice - just not seem to be able to find it From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 10:10 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, In your case try root.removeChild(mySprite); btw: the use of root is not recommended though. There was a discussion lately why. Maybe Jason is willing to illustrate in the case of this example? Willem On 23-feb-2010, at 15:31, Lehr, Theodore wrote: I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Bingo! Try this instead: var mySprite:Sprite = new Sprite(); function createBar(dfile:String):void { ... function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:21:26 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our
Re: [Flashcoders] Finding and Removing a Sprite
I have no clue why you have a function inside a function. I am going to assume you have a good reason for it. Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:21:26 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] Event.COMPLETE Question
On Tue, Feb 23, 2010 at 11:04 AM, Keith Reinfeld keithreinf...@comcast.netwrote: I presume my removeEventListener works. You should be sure. So check it: trace(e.currentTarget.hasEventListener(Event.COMPLETE)); //true e.currentTarget.removeEventListener(Event.COMPLETE, loaded); trace(e.currentTarget.hasEventListener(Event.COMPLETE)); //false Thanks. Traced true. So, how do I pass new values to fn loaded? Just increment the vars. // Cascade layout displayObject.x = myX + 31; displayObject.y = myY + 31; myX += 20; myY += 20; How is that? I'm not iterating over that function, I call it as needed, so myX, myY would be reset every time. Have you considered putting your url strings into an array instead of using that awkward switch statement? This worked. Thanks: public function thePic(x:int, y:int) { var paths:Array = new Array(images/bracelet.jpg, images/brooch.jpg, images/chain.jpg, images/earring.jpg, images/necklace.jpg, images/ring.jpg); var path:String = new String(); path = paths[counter]; var req:URLRequest = new URLRequest(path); var loaderArray:Array = new Array(); loaderArray[counter] = new Loader(); loaderArray[counter].load(req); loaderArray[counter].contentLoaderInfo.addEventListener(Event.COMPLETE,loaded); } I would also recommend writing a function that creates and returns BevelFilter. Set 'myBevel' once (rather than running through the code repeatedly) then apply it where appropriate. var myBevel:BevelFilter = createBevel(); function createBevel():BevelFilter{ var bf:BevelFilter = new BevelFilter(); bf.type = BitmapFilterType.OUTER; bf.distance = 10; bf.highlightColor = 0xFF; bf.shadowColor = 0x00; bf.blurX = 20; bf.blurY = 20; return bf; } Thanks. // apply Bevel filter displayObject.filters = [myBevel]; No: displayObject.filters = [createBevel()]; TIA, Susan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Hi Theodore, var mySprite:Sprite; Do this: function createBar(dfile:String):void { ... mySprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } You declared mySprite inside the function, so it's not accessible outside that function. Declaring mySprite outside the function makes it accessible to other functions. HTH Willem On 23-feb-2010, at 16:21, Lehr, Theodore wrote: I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
private function handleTcpData(event:Event):void { while (_socket.bytesAvailable) { var str:String = _socket.readUTF(); updateGUI(str); } } maybe you shouldn't ignore thrown errors: AFAIK if the UTF8-data is not complete (ie.. the last UTF-8 byte sequence is truncated), readUTF() will throw an EOFError error. so if you handle this error correctly, you might be safe? cheers, valentin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
you could also make createBar return a reference to the sprite... function createBar(dfile:String):Sprite { ... mySprite = new Sprite(); // do stuff addChild(mySprite); return mySprite; } var mySprite:Sprite = createBar(string); then you can remove it using your stored reference to the sprite... function blah():void { removeChild(mySprite); } On 23 February 2010 16:35, Geografiek geograf...@geografiek.nl wrote: Hi Theodore, var mySprite:Sprite; Do this: function createBar(dfile:String):void { ... mySprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } You declared mySprite inside the function, so it's not accessible outside that function. Declaring mySprite outside the function makes it accessible to other functions. HTH Willem On 23-feb-2010, at 16:21, Lehr, Theodore wrote: I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders List flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [ nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [ geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at 14:23, Lehr, Theodore wrote: I am trying to remove a Sprite via: removeSchild(mySprite); but I get the error: 1120: Access of undefined property mySprite); The Sprite is created ina function and is not neccessarily the child of anything - although it is created via addChild(mySprite) so I guess it is the child of something... How can I find it an remove it? Thanks! ___ Flashcoders mailing list
[Flashcoders] Error 1009
Hi; I have a preloader that (obviously) calls another swf onload. This other swf loads by itself with no problem; however, it calls another script and apparently this is what's throwing the error. Curtis Morley says I should add that other script to the first frame of a timeline and set the alpha to 0. What's a purely AS3 solution to this? Thanks, Victor ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Error 1009
Victor Subervi wrote: Hi; I have a preloader that (obviously) calls another swf onload. This other swf loads by itself with no problem; however, it calls another script and apparently this is what's throwing the error. What error? Use the debugger and find out! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Error 1009
Are you listening for Event.INIT or Event.COMPLETE for your preloader? You should possibly use the former to make sure all your child clips are instanciated before you run AS3 code that accesses these child clips. Victor Subervi wrote: Hi; I have a preloader that (obviously) calls another swf onload. This other swf loads by itself with no problem; however, it calls another script and apparently this is what's throwing the error. Curtis Morley says I should add that other script to the first frame of a timeline and set the alpha to 0. What's a purely AS3 solution to this? Thanks, Victor ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Class Property vs. Static Property?
This feels like a really stupid question, but it's stuck in my head: http://gskinner.com/talks/quickNL/#44 On that slide (slide 44) he references access speed for Literal, Local, Instance, Static and Class properties. Apparently my OOP terminology is bleeding together here, but what's the difference between a Static and Class property -- I thought they were the same thing? Does the graph refer to using dynamic class properties such as with object? Anyone got a clue they want to loan me for a bit? Jer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Class Property vs. Static Property?
I'm just guessing here, but maybe he's referring to properties of the prototype Object? Because, I don't see it on the list. Then again, I would expect access to instance properties to be faster, based on the assumption that they take precedence. I guess somebody will have to recreate the test and find out. :) On Tue, Feb 23, 2010 at 5:14 PM, Jer Brand thejhe...@gmail.com wrote: This feels like a really stupid question, but it's stuck in my head: http://gskinner.com/talks/quickNL/#44 On that slide (slide 44) he references access speed for Literal, Local, Instance, Static and Class properties. Apparently my OOP terminology is bleeding together here, but what's the difference between a Static and Class property -- I thought they were the same thing? Does the graph refer to using dynamic class properties such as with object? Anyone got a clue they want to loan me for a bit? Jer ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
thanks for all of the help... I did resolve it by taking the functions out of the other functions... and creating the sprite at the root (outside of the functions) t From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes [tom.rho...@gmail.com] Sent: Tuesday, February 23, 2010 10:50 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite you could also make createBar return a reference to the sprite... function createBar(dfile:String):Sprite { ... mySprite = new Sprite(); // do stuff addChild(mySprite); return mySprite; } var mySprite:Sprite = createBar(string); then you can remove it using your stored reference to the sprite... function blah():void { removeChild(mySprite); } On 23 February 2010 16:35, Geografiek geograf...@geografiek.nl wrote: Hi Theodore, var mySprite:Sprite; Do this: function createBar(dfile:String):void { ... mySprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } You declared mySprite inside the function, so it's not accessible outside that function. Declaring mySprite outside the function makes it accessible to other functions. HTH Willem On 23-feb-2010, at 16:21, Lehr, Theodore wrote: I can not paste it but this should give you a general idea: function createBar(dfile:String):void { ... var mySprite:Sprite = new Sprite(); function createGraph():void { mySprite.graphics. addChild(mySprite); } } function clearBar():void { removeChild(mySprite); } From: Nathan Mynarcik [nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 10:17 AM To: Lehr, Theodore; Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Ok, I'm sure you are setting your variable inside the function that creates the sprite. This will in turn not allow you to target the sprite correctly. Can you paste the code you are using to create your sprite? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 10:12:41 To: nat...@mynarcik.comnat...@mynarcik.com; Flash Coders List flashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I am new to as3 so all of this is in the main .fla in functions... the Sprite is created in one function and I am trying to remove it in another... I tried the getChildByName and the movie loaded properly - then when the event that calls the removeChild gets fired, I am given: 2007: parameter child must be non-null Ted From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Nathan Mynarcik [ nat...@mynarcik.com] Sent: Tuesday, February 23, 2010 9:49 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite You could try root.removeChild(mysprite); Or you can try removeChild(getChildByName(mySprite)); Where is your code that is calling this method located? External Doc Class? On the main timeline? Inside or on a movieclip? Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 09:31:19 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite I tried: removeChild(root.mySprite); and I get another error: 1119: Access of possibly undefined property mySprite through a reference with static type flash.display:DisplayObject From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Geografiek [ geograf...@geografiek.nl] Sent: Tuesday, February 23, 2010 8:45 AM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Hi Theodore, When you say 'addChild(mySprite)' mySprite *is* the child of something: the instance you call addChild on (addChild(mySprite) is equal to this.addChild(mySprite)) To remove mySprite you have to call removeChild(mySprite) on the same instance. From the error it seems that myChild is not a child of the instance you call removeChild on. Did you trace mySprite.parent to see if mySprite is actually a child of an instance? (traces null if mySprite is not a child of anything, traces the parent if mySprite is added as a child) parentName.removeChild(mySprite) does the trick then. HTH Willem van den Goorbergh On 23-feb-2010, at
RE: [Flashcoders] Finding and Removing a Sprite: PART II
So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] accessing event dispatchers in a loosely-coupled, modular design
In other words: Create a Controller class before creating any other classes. Any instances that need to know when potential event dispatchers are created should listen to the Controller class. When dispatchers are created, the Controller class should dispatch an event. This way I won't need to use a Timer to repeatedly look for the dispatchers. Merrill, Jason wrote: If an instance of those classes has been created, then it will eval to true, otherwise it will be null, so this should work for that part of the problem: if(_myinstance) _myInstance.addEventListener(myEvent, myHandler); However, if you're creating A after B, C, and D, then you'll want to call the code above from say, a Controller class whenever A is created. Once A is created, then that's a trigger to add the listeners to the other classes if they exist. Make sense? Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (inote: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Andrew Sinning Sent: Tuesday, February 23, 2010 10:04 AM To: Flash Coders List Subject: [Flashcoders] accessing event dispatchers in a loosely-coupled,modular design Following the discussion about root yesterday, it got me thinking about a constant problem I face. Object-A needs to listen to events coming from objects B, C and D, but only if and when these objects actually exist. There's no guarantee that any of the objects B, C and D will be instantiated before or after A is instantiated. So, what's the proper way for A to add itself as a listener to B, C and D? What I'm currently do is this: The event dispatchers (B, C, D etc) implement a singleton interface. Within the target (A), I set up a Timer event to repeatedly check for instances of the dispatchers. Once a dispatcher is found, the target adds itself as a listener, and a pointer to the dispatcher is created so that the target can later remove itself. I'm not very happy with this design, but it's the best that I've been able to come up with. Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
bar.name = bar_ + i; function destroyBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = getChildByName(bar_ +i) as Sprite; if(bar) { ... removeChild(bar); } } } Lehr, Theodore wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
Thanks man - that did it From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
Lehr, Theodore wrote: Any ideas? Store a reference to each object in a vector like this: var bars:Vector.Bar=new Vector.Bar(); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Bar = new Bar(); ... addChild(bar); bars.push(bar); } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] accessing event dispatchers in a loosely-coupled, modular design
Sort of - but I wouldn't have the controller dispatch anything. I would only have it listen to the view(s) (your other classes with a visual presence). The controller first creates an instance of A (what determines when that happens, I don't know because I don't know what A or your app is all about). When it does, it also creates listeners for B, C, D if they are present in the view. Controller also of course has the handler that tells whatever else to do what it has to do (now I'm just guessing because I don't know what you're ultimately trying to accomplish). If something needs to happen when something changes data-wise in the model, then you would listen to the model which dispatches events and have the controller respond, perhaps by telling the view to change. IMO, the Controller is the most ambiguous part of the MVC pattern. View and Model are pretty straightforward (esp. the Model). Different people have different ways of using the controller, but this is how I use it. It listens to other parts of your app, and then tells other parts of your app to do something. It's the central nervous system to use a methaphor - at least how I use it. AS3 Frameworks get more broken down than that, using things like Command classes, Mediators, and Facades and junk for even better OOP development and control, but there can be a steep learning curve to most of those frameworks. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Andrew Sinning Sent: Tuesday, February 23, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] accessing event dispatchers in a loosely-coupled,modular design In other words: Create a Controller class before creating any other classes. Any instances that need to know when potential event dispatchers are created should listen to the Controller class. When dispatchers are created, the Controller class should dispatch an event. This way I won't need to use a Timer to repeatedly look for the dispatchers. Merrill, Jason wrote: If an instance of those classes has been created, then it will eval to true, otherwise it will be null, so this should work for that part of the problem: if(_myinstance) _myInstance.addEventListener(myEvent, myHandler); However, if you're creating A after B, C, and D, then you'll want to call the code above from say, a Controller class whenever A is created. Once A is created, then that's a trigger to add the listeners to the other classes if they exist. Make sense? Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (inote: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Andrew Sinning Sent: Tuesday, February 23, 2010 10:04 AM To: Flash Coders List Subject: [Flashcoders] accessing event dispatchers in a loosely-coupled,modular design Following the discussion about root yesterday, it got me thinking about a constant problem I face. Object-A needs to listen to events coming from objects B, C and D, but only if and when these objects actually exist. There's no guarantee that any of the objects B, C and D will be instantiated before or after A is instantiated. So, what's the proper way for A to add itself as a listener to B, C and D? What I'm currently do is this: The event dispatchers (B, C, D etc) implement a singleton interface. Within the target (A), I set up a Timer event to repeatedly check for instances of the dispatchers. Once a dispatcher is found, the target adds itself as a listener, and a pointer to the dispatcher is created so that the target can later remove itself. I'm not very happy with this design, but it's the best that I've been able to come up with. Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
You could create an empty array (outside the functions) And add each newly created bar to the array. Afterwards, say in another function, you can reference the array indexes. Something like: myBarsArray = new Array(); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); myBarsArray.push(bar); { } function removeBars(i:uint):void { removeChild(myBarsArray[i]); //don't remove the bar from the array } HTH, Willem On 23-feb-2010, at 17:55, Lehr, Theodore wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= Geografiek is a Dutch, Utrecht-based map and chart design company. Willem van den Goorbergh can be contacted by telephone: (+31) 30-2719512 or cell phone: (+31)6-26372378 or by fax: (+31)302719687 snail mail: Hooghiemstraplein 89 3514 AX UTRECHT Visit our website at: http://www.geografiek.nl =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+= ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
Inside your loop, you can add the sprite to a movieclip and give each movieclip a name using the variable in your loop like: mcName.name = mc+i; //or whatever your for loop var is And then remove it by getChildByName(mc#); --Original Message-- From: Lehr, Theodore Sender: flashcoders-boun...@chattyfig.figleaf.com To: Flash Coders List ReplyTo: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II Sent: Feb 23, 2010 10:55 AM So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Event.COMPLETE Question
How is that? I'm not iterating over that function, I call it as needed, so myX, myY would be reset every time. Uses the addition assignment (+=) operator. No: displayObject.filters = [createBevel()]; You are missing the point. Why run this function repeatedly when you can set 'myBevel' once and just use that? displayObject.filters = [myBevel]; Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
A peculair twist now is that these bar sprites are being sent to the back (meaning I have other sprites - lines) showing on top when they were and should showing in the back... imagine if you will a bar chart - that has horizontal lines in the back... these lines now show on top of the bars... anyway to force them to be on the bottom layer? From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
I agree with Mr. Tom Rhodes. Storing references to your buttons in an array is far better than trying to create and use dynamic instance names like bar+i. You can tack on data properties to the buttons as well, so they have information about themselves that travels with them. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes Sent: Tuesday, February 23, 2010 12:18 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite
Theodore Lehr wrote: thanks for all of the help... I did resolve it by taking the functions out of the other functions... and creating the sprite at the root (outside of the functions) Glad you got it fixed. I'm late to the discussion, so didn't contribute anything yet--but I will now :-) Do yourself a favor now. One of the real advantages of AS3 is eliminating timeline code--you have to do that eventually to take advantage of AS3's OOP capabilities. Make a backup of your .fla before you do this, in case something goes wrong. In the same folder where your .fla file is, create an ActionScript file called Main.as. Inside it, use this: package { public class Main extends Sprite { //functions go here } } Now cut and paste all your code from the timeline and put it after the line //functions go here. You can overwrite that line--just keep your functions in between the inner set of curly brackets. In the .fla file, in the Properties window, set your document class to Main. Remember, ActionScript is case sensitive. It should compile and run the same as before, but you will have taken a good first step towards utilizing AS3's power. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
I think it depends on the circumstances: If you are not manipulating the child sprites in any way, just adding them at the start, removing at the end and possibly listening for events on them, why would you want to use more memory by storing the sprite instances in an array or a vector when you already have a storage medium for them - the parent container? If I was needing to move things around, or juggle the display order, or manipulate sprites in the container, I may want to store a reference to them, but if they are just display elements, it's even simpler just to add them to a container sprite then iterate through the container when you are done with them if you need to remove listeners. Obviously this is purely down to coding preferences, but why waste arrays, when your DisplayObjectContainer does it for you... Glen Merrill, Jason wrote: I agree with Mr. Tom Rhodes. Storing references to your buttons in an array is far better than trying to create and use dynamic instance names like bar+i. You can tack on data properties to the buttons as well, so they have information about themselves that travels with them. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes Sent: Tuesday, February 23, 2010 12:18 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
addChildAt(child:DisplayObject, index:int) So: this.addChildAt(barMom, 0); Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 11:29 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II A peculair twist now is that these bar sprites are being sent to the back (meaning I have other sprites - lines) showing on top when they were and should showing in the back... imagine if you will a bar chart - that has horizontal lines in the back... these lines now show on top of the bars... anyway to force them to be on the bottom layer? From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
You can use the addChildAt method and tell it where to add the object in the displaylist. addChildAt(objectName, 0); will add the objectName to the bottom of the display list. Nathan Mynarcik Interactive Web Developer nat...@mynarcik.com 254.749.2525 www.mynarcik.com -Original Message- From: Lehr, Theodore ted_l...@federal.dell.com Date: Tue, 23 Feb 2010 12:28:39 To: Flash Coders Listflashcoders@chattyfig.figleaf.com Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II A peculair twist now is that these bar sprites are being sent to the back (meaning I have other sprites - lines) showing on top when they were and should showing in the back... imagine if you will a bar chart - that has horizontal lines in the back... these lines now show on top of the bars... anyway to force them to be on the bottom layer? From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Keith Reinfeld [keithreinf...@comcast.net] Sent: Tuesday, February 23, 2010 12:10 PM To: 'Flash Coders List' Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II You could parent them. Var barMom:Sprite = new Sprite(); addChild(barMom); function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat+i; ... barMom.addChild(bar); { } This way at least you know where they live. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Lehr, Theodore Sent: Tuesday, February 23, 2010 10:55 AM To: Flash Coders List Subject: RE: [Flashcoders] Finding and Removing a Sprite: PART II So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite
awesome - thanks From: flashcoders-boun...@chattyfig.figleaf.com [flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Kerry Thompson [al...@cyberiantiger.biz] Sent: Tuesday, February 23, 2010 12:36 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite Theodore Lehr wrote: thanks for all of the help... I did resolve it by taking the functions out of the other functions... and creating the sprite at the root (outside of the functions) Glad you got it fixed. I'm late to the discussion, so didn't contribute anything yet--but I will now :-) Do yourself a favor now. One of the real advantages of AS3 is eliminating timeline code--you have to do that eventually to take advantage of AS3's OOP capabilities. Make a backup of your .fla before you do this, in case something goes wrong. In the same folder where your .fla file is, create an ActionScript file called Main.as. Inside it, use this: package { public class Main extends Sprite { //functions go here } } Now cut and paste all your code from the timeline and put it after the line //functions go here. You can overwrite that line--just keep your functions in between the inner set of curly brackets. In the .fla file, in the Properties window, set your document class to Main. Remember, ActionScript is case sensitive. It should compile and run the same as before, but you will have taken a good first step towards utilizing AS3's power. Cordially, Kerry Thompson ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
IMO, an array is hardly a waste of space, and allows for expanding your app easier if need be, but you're right, could come down to coding preferences in that case. More often though I think, the benefits of storing them in an array outweigh the benefits of dynamic naming. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Glen Pike Sent: Tuesday, February 23, 2010 12:43 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II I think it depends on the circumstances: If you are not manipulating the child sprites in any way, just adding them at the start, removing at the end and possibly listening for events on them, why would you want to use more memory by storing the sprite instances in an array or a vector when you already have a storage medium for them - the parent container? If I was needing to move things around, or juggle the display order, or manipulate sprites in the container, I may want to store a reference to them, but if they are just display elements, it's even simpler just to add them to a container sprite then iterate through the container when you are done with them if you need to remove listeners. Obviously this is purely down to coding preferences, but why waste arrays, when your DisplayObjectContainer does it for you... Glen Merrill, Jason wrote: I agree with Mr. Tom Rhodes. Storing references to your buttons in an array is far better than trying to create and use dynamic instance names like bar+i. You can tack on data properties to the buttons as well, so they have information about themselves that travels with them. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of tom rhodes Sent: Tuesday, February 23, 2010 12:18 PM To: Flash Coders List Subject: Re: [Flashcoders] Finding and Removing a Sprite: PART II ok, bar isn't the name of the sprite, it's a variable with name bar which contains a reference to your sprite... if you want to use names then do something like bar.name = String(bar_ + i); but personally i'd use an array like so... var bars:Array = []; function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); bars.push(bar); { } then you can get at the bars later to do stuff with them or remove them... On 23 February 2010 17:55, Lehr, Theodore ted_l...@federal.dell.com wrote: So here is my next issue... One of the functions creates a dynamic amount sprites based on an xml feed, like so function createBars():void { for (var i:int=0; itotalbars; i++) { var bar:Sprite = new Sprite(); ... addChild(bar); { } And see this this is where my ears start to bleed... this is seemingly creating, say, 9 Sprites ALL with the same name bar I need to keep the new Sprite() line in the loop for them to be created... but then I need some way to access them to delete them Any ideas? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Event.COMPLETE Question
On Tue, Feb 23, 2010 at 1:27 PM, Keith Reinfeld keithreinf...@comcast.netwrote: How is that? I'm not iterating over that function, I call it as needed, so myX, myY would be reset every time. Uses the addition assignment (+=) operator. My bad. It is not iteration. It is called onMouseOver, hence the value of myX, myY cannot be predetermined nor iterated. No: displayObject.filters = [createBevel()]; You are missing the point. Why run this function repeatedly when you can set 'myBevel' once and just use that? displayObject.filters = [myBevel]; function createBevel():BevelFilter { var bf:BevelFilter = new BevelFilter(); bf.type = BitmapFilterType.OUTER; bf.distance = 10; bf.highlightColor = 0xFF; bf.shadowColor = 0x00; bf.blurX = 20; bf.blurY = 20; return bf; } myBevel no longer exists! TIA, Susan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] removeChild Question
Hi; How do I determine what the parent object is of a child I have added and want to remove? TIA, Susan ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
On Tue, Feb 23, 2010 at 6:43 PM, Glen Pike g...@engineeredarts.co.uk wrote: why would you want to use more memory by storing the sprite instances in an array or a vector when you already have a storage medium for them - the parent container? We're talking about only nine instances here. It would be a different matter if it were tens or hundreds of thousands, but even then the additional memory required to store another reference to them would be insignificant compared to the memory the Sprites themselves would use, and performance would be the far bigger issue. So, a descriptively named collection has a higher benefit, for readability alone. Preferably a Vector, so casting isn't necessary even when the Sprites for the bars become a proper Bar class, as they probably should. I'd still put them in their own container, though. Then the container goes on top of another with the lines. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] removeChild Question
Susan Day wrote: Hi; How do I determine what the parent object is of a child I have added and want to remove? Usually, there is only one possible candidate and you know what that one is ahead of time. But there is an embarrassingly simple way: the parent property. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Error 1009
On Tue, Feb 23, 2010 at 12:04 PM, Glen Pike g...@engineeredarts.co.ukwrote: Are you listening for Event.INIT or Event.COMPLETE for your preloader? You should possibly use the former to make sure all your child clips are instanciated before you run AS3 code that accesses these child clips. Yes. I changed COMPLETE to INIT and got the same error: package { import flash.events.Event; import flash.events.MouseEvent; import flash.display.MovieClip; import com.greensock.*; import com.greensock.easing.*; import flash.display.Loader; import flash.events.ProgressEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldAutoSize; import flash.net.URLRequest; public class Preloader extends MovieClip { private var l:Loader = new Loader(); private var myTextField:TextField = new TextField(); function Preloader() { init(); } function init() { l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop); l.contentLoaderInfo.addEventListener(Event.COMPLETE, done); l.load(new URLRequest(Splash.swf)); addChild(myTextField); myTextField.width = 250; myTextField.x = stage.stageWidth/2 - 50; myTextField.y = stage.stageHeight/2; myTextField.selectable = false; myTextField.border = false; myTextField.borderColor = 0xAA; myTextField.autoSize = TextFieldAutoSize.LEFT; var myFormat:TextFormat = new TextFormat(); myFormat.color = 0xAA; myFormat.size = 24; myFormat.italic = true; //myTextField.setTextFormat(myFormat); myTextField.defaultTextFormat = myFormat; } function loop(e:ProgressEvent):void { var perc:Number = e.bytesLoaded/e.bytesTotal; myTextField.text = Math.ceil(perc*100).toString() + %; } function done(e:Event):void { removeChildAt(0); myTextField = null; addChild(l); } } } For Hendrik, I am currently downloading the debugger. It's big! TIA, Victor ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Error 1009
Victor Subervi wrote: For Hendrik, I am currently downloading the debugger. It's big! Eh? The content debugging player is only marginally bigger than the normal player. It is smaller than some movies. Then again, you need a debugger for the player to connect to. It is integrated in all serious IDEs. That is most likely what you are saying is big. Btw, you got my name wrong. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
More than one way to get things done. Depends on your needs. Check out DisplayObjectContainer in the docs. var barMom:Sprite = new Sprite(); this.addChildAt(barMom, 0); function createBars():void { for (var i:int=0; i 9; i++) { var bar:Sprite = new Sprite(); bar.name = barBrat + i; barMom.addChild(bar); } } function spankABrat(container:Sprite, childName:String):void{ container.removeChild(container.getChildByName(childName)); } function eightySixBrats(container:Sprite):void { var len:uint = container.numChildren; for (var i:uint = 0; i len; i++) { container.removeChildAt(0); } } trace(barMom.numChildren =,barMom.numChildren);// 0 createBars(); trace(barMom.numChildren =,barMom.numChildren);// 9 spankABrat(barMom, barBrat3); trace(barMom.numChildren =,barMom.numChildren);// 8 eightySixBrats(barMom); trace(barMom.numChildren =,barMom.numChildren);// 0 Jason: Doesn't storing them in an array create a set of references that will need to be cleaned up? Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Line graph tutorial
Anyone know of any goods examples of how to do a line graph using xml data? I am looking through google now... ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Finding and Removing a Sprite: PART II
Doesn't storing them in an array create a set of references that will need to be cleaned up? Absolutely (if the app performance even needs cleaning up and/or the items are even removed). But that's easily taken care of with a cleanup function. So for small uses, as I mentioned, may not be worthwhile, but I am thinking long term scalability. I just hate to see people default to dynamic naming all the time when architecturally, using arrays as storage is better in the long run. For this, the dynamic naming would be fine. I'd just be careful to make it a habit for everything. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Is Object.registerClass still needed with attachMovie?
I was using Flash CS3 and it seemed like I needed to use Object.registerClass to get a movie clip that I attached wrapped in my class. Seemed like the class identifier in the library did not work. Now I'm using CS4 and it looks like the class identifier in the library does work. Was I just mistaken when I used CS3 or has this been fixed? Thanks, Jim ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Event.COMPLETE Question
When loading bitmaps, your loader will NEVER be eligible for cleanup by the Garbage Collector unless you do ALL of the following in this order: var bitmap:Bitmap = new Bitmap(Bitmap(loader.content).bitmapData.clone(), auto, true); Bitmap(loader.content).bitmapData.dispose(); loader.unloadAndStop(true); try { loader.close(); } catch (e:Error) {} // remove all event listeners from loader This means that if you want the Bitmap from the loader, you should extract it using bitmapData.clone(), or your Bitmap will be gone when the loader goes away or the loader will not go away because there's still a reference to its BitmapData. If you're pulling a Bitmap out of an anonymous loader by saying addChild(loader.content) you will never have another opportunity to get rid of the loader. That may be ok for your purposes, but this is a very good reason to addChild(loader) so you maintain a reference to the loader itself. Unless you have a specific reason for not using addChild(loader) you should use the code block above. It's important to note that you won't see your memory go down unless you force the GC to run after you null out all references to the loader. In AIR you can say System.gc(). In Flash, you have to use the unsupported LocalConnection hack. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Event.COMPLETE Question
You should only create the bevel filter ONCE. Filters are _expensive_ and can/should be shared. Make your bevel an instance variable private var myBevel:BevelFilter = new BevelFilter(); public function foo() { myClip.filters = [myBevel]; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Using parent Sprites coordinates
Is there a way to have a child sprite reference the parent sprite when seeting it's x and y say I have a Sprite: var bgDad:Sprite = new Sprite(); then I add a child: var bgSon:Sprite = new Sprite(); bgSon.graphics.lineStyle(1,0x00); bgSon.graphics.moveTo(0,0); bgSon.graphics.lineTo(100,100); bgdad.addChild(bgSon); I would like those coordinates [0,0 and 100,100] to be in relations to bgDad - not the stage... is this possible? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Finding and Removing a Sprite: PART II
yeah, horses for courses... if you want to better encapsulate stuff, i find it easier to work with arrays (in fp10 vectors) and pass them around if needs be. tying your code to specific timelines gives you more work to do if you want to reuse that code imho. for something quick and dirty in timeline code though that you know you don't want to reuse then whatever's clever. Mr. Jason Merrill is right though about having cleanup functions for whatever you create being a great way to not getting into trouble later i reckon... On 23 February 2010 20:47, Merrill, Jason jason.merr...@bankofamerica.comwrote: Doesn't storing them in an array create a set of references that will need to be cleaned up? Absolutely (if the app performance even needs cleaning up and/or the items are even removed). But that's easily taken care of with a cleanup function. So for small uses, as I mentioned, may not be worthwhile, but I am thinking long term scalability. I just hate to see people default to dynamic naming all the time when architecturally, using arrays as storage is better in the long run. For this, the dynamic naming would be fine. I'd just be careful to make it a habit for everything. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Using parent Sprites coordinates
Lehr, Theodore wrote: Is there a way to have a child sprite reference the parent sprite when seeting it's x and y say I have a Sprite: You must have missed localToGlobal and globalToLocal. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
I've come up with this, but still have a flaw there: private function handleTcpData(event:Event):void { var len:uint; if (0 == _socket.bytesAvailable) return; try { _socket.readBytes(_ba, _ba.bytesAvailable, _socket.bytesAvailable); // read the length of the UTF string to follow while (_ba.bytesAvailable = 2) { len = _ba.readUnsignedShort(); // invalid length - reset if (0 == len) { trace('XXX invalid len = ' + len); _ba.position = 0; _ba.length = 0; return; } if (_ba.bytesAvailable = len) { var str:String = _ba.readUTFBytes(len); updateGUI(str); // copy the remaining bytes // (does it work? can it be improved?) var newBA:ByteArray = new ByteArray(); newBA.readBytes(_ba); _ba = newBA; } } } catch(e:Error) { trace('XXX ' + e); _ba.position = 0; _ba.length = 0; return; } } - when there are too many bytes available, for example 800 and my messages are only 400 bytes long, then it stucks. Also I wonder, if copying remaining bytes could be improved (i.e. without allocating a new ByteArray each time)? Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.comwrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
I've added some traces there and see that this doesn't work: if (_ba.bytesAvailable = len) { var str:String = _ba.readUTFBytes(len); updateGUI(str); // copy the remaining bytes // (does it work? can it be improved?) var newBA:ByteArray = new ByteArray(); newBA.readBytes(_ba); _ba = newBA; } - the newBA.length stays zero. Please help me with this little bit. My problem is that when I read many bytes into my _ba (i.e. if I read several messages at once) and then process one message (with the updateGUI() above), how do I get rid of those processed bytes? I suppose I must somehow cut those processed bytes away from the beginning of the _ba, that is why I introduced copying into a newBA above, but this doesn't work. Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
If I was In your position, I would go buy the quickaccess app and deconstruct it. Might give you tips. Plus you may need a jailbroken iPhone as well to fish for the app files. I did something similar with the katra weather lock screen. But I talked one on one with the developer to get tips and he was cool with it. Karl Sent from losPhone On Feb 23, 2010, at 3:38 PM, Eric E. Dolecki edole...@gmail.com wrote: That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Event.COMPLETE Question
Steven, Thanks for the backup. Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders- boun...@chattyfig.figleaf.com] On Behalf Of Steven Sacks Sent: Tuesday, February 23, 2010 2:52 PM To: Flash Coders List Subject: Re: [Flashcoders] Event.COMPLETE Question You should only create the bevel filter ONCE. Filters are _expensive_ and can/should be shared. Make your bevel an instance variable private var myBevel:BevelFilter = new BevelFilter(); public function foo() { myClip.filters = [myBevel]; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2705 - Release Date: 02/23/10 01:34:00 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
Btw. I am not suggesting to steal anyones code. Just figure out the idea and then create your own. Karl Sent from losPhone On Feb 23, 2010, at 3:38 PM, Eric E. Dolecki edole...@gmail.com wrote: That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
I think I need an iphone app that connects to a socket server running on the mac. Then a mac app. ugh. On Tue, Feb 23, 2010 at 4:53 PM, Karl DeSaulniers k...@designdrumm.comwrote: If I was In your position, I would go buy the quickaccess app and deconstruct it. Might give you tips. Plus you may need a jailbroken iPhone as well to fish for the app files. I did something similar with the katra weather lock screen. But I talked one on one with the developer to get tips and he was cool with it. Karl Sent from losPhone On Feb 23, 2010, at 3:38 PM, Eric E. Dolecki edole...@gmail.com wrote: That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Event.COMPLETE Question
var bitmap:Bitmap = new Bitmap(Bitmap(loader.content).bitmapData.clone(),auto, true); Bitmap(loader.content).bitmapData.dispose(); loader.unloadAndStop(true); try { loader.close(); } catch (e:Error) {} // remove all event listeners from loader Steven, I'm curious about the try-catch block. It seems unnecessary since, presumably, this code would be called within an onLoadComplete function and the URLStream would no longer be open. Is there a scenario where this would not be the case? Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
Eric E. Dolecki wrote: I think I need an iphone app that connects to a socket server running on the mac. Then a mac app. ugh. Surely any socket server on any machine would do? On Tue, Feb 23, 2010 at 4:53 PM, Karl DeSaulniers k...@designdrumm.comwrote: If I was In your position, I would go buy the quickaccess app and deconstruct it. Might give you tips. Plus you may need a jailbroken iPhone as well to fish for the app files. I did something similar with the katra weather lock screen. But I talked one on one with the developer to get tips and he was cool with it. Karl Sent from losPhone On Feb 23, 2010, at 3:38 PM, Eric E. Dolecki edole...@gmail.com wrote: That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Alexander Farber wrote: I've come up with this, but still have a flaw there: private function handleTcpData(event:Event):void { var len:uint; what about this simple alternative: private function handleTcpData(event:Event):void { if(_socket.bytesAvailable) { try{ var str:String = _socket.readUTF(); updateGUI(str); }catch(e:Error){} } } I havn't tested, but if the socket class is well designed, the buffer should only be flushed if readUTF() was sucessful, and therefor the above code should work fine. cheers, valentin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
Yeah you will have to build both I believe. Look at http://www.hackint0sh.org/f9/ You might wiggle your way into some information. Karl On Feb 23, 2010, at 4:00 PM, Eric E. Dolecki wrote: I think I need an iphone app that connects to a socket server running on the mac. Then a mac app. ugh. On Tue, Feb 23, 2010 at 4:53 PM, Karl DeSaulniers k...@designdrumm.comwrote: If I was In your position, I would go buy the quickaccess app and deconstruct it. Might give you tips. Plus you may need a jailbroken iPhone as well to fish for the app files. I did something similar with the katra weather lock screen. But I talked one on one with the developer to get tips and he was cool with it. Karl Sent from losPhone On Feb 23, 2010, at 3:38 PM, Eric E. Dolecki edole...@gmail.com wrote: That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Flash app talking to iPhone app over wifi
Here is the link for Quickaccess. http://www.quickaccess.net/downloads/ Karl On Feb 23, 2010, at 4:00 PM, Eric E. Dolecki wrote: I think I need an iphone app that connects to a socket server running on the mac. Then a mac app. ugh. On Tue, Feb 23, 2010 at 4:53 PM, Karl DeSaulniers k...@designdrumm.comwrote: If I was In your position, I would go buy the quickaccess app and deconstruct it. Might give you tips. Plus you may need a jailbroken iPhone as well to fish for the app files. I did something similar with the katra weather lock screen. But I talked one on one with the developer to get tips and he was cool with it. Karl Sent from losPhone On Feb 23, 2010, at 3:38 PM, Eric E. Dolecki edole...@gmail.com wrote: That's what I am after - no clear idea (yet) On Tue, Feb 23, 2010 at 4:13 PM, Karl DeSaulniers k...@designdrumm.com wrote: There is Quickoffice and QuickAccess. I helped them with some product demos in the past. I believe their iphone app can access their system app via wifi. So I am sure you could find some how to do the same. Karl On Feb 23, 2010, at 7:11 AM, Eric E. Dolecki wrote: I'm curious - has anyone seen a tutorial online or seen source for allowing a Flash app to talk back and forth with an iPhone app running on wifi? Sending simple strings. Eric -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- http://ericd.net Interactive design and development ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Yes, that's with what I had started and what doesn't work :-) On Tue, Feb 23, 2010 at 11:17 PM, Valentin Schmidt v...@dasdeck.com wrote: private function handleTcpData(event:Event):void { if(_socket.bytesAvailable) { try{ var str:String = _socket.readUTF(); updateGUI(str); }catch(e:Error){} } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Alexander Farber wrote: Yes, that's with what I had started and what doesn't work :-) so then why did you start with posting code here (pasted below) that didn't contain any exception catching? that's the crucial point: you have to catch the exception, otherwise you would either get corrupted UTF strings or and be caught in an infinite loop (because you used while instead of if!). here the code you had posted (that is quite different to mine): _socket = new Socket(); _socket.addEventListener(ProgressEvent.SOCKET_DATA, handleTcpData); . private function handleTcpData(event:Event):void { while (_socket.bytesAvailable) { var str:String = _socket.readUTF(); updateGUI(str); } } cheers, valentin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
some comments added to make it easier for you to spot the differences :-) private function handleTcpData(event:Event):void { if(_socket.bytesAvailable) { // USE IF, NOT WHILE! try{ // CATCH THE EXCEPTION var str:String = _socket.readUTF(); updateGUI(str); }catch(e:Error){} } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] accessing event dispatchers in a loosely-coupled, modular design
aside from the advice that i got on this message list, i found this article from adobe really useful http://www.adobe.com/devnet/flex/articles/blueprint.html might help here too best a On 23 Feb 2010, at 17:19, Merrill, Jason wrote: Sort of - but I wouldn't have the controller dispatch anything. I would only have it listen to the view(s) (your other classes with a visual presence). The controller first creates an instance of A (what determines when that happens, I don't know because I don't know what A or your app is all about). When it does, it also creates listeners for B, C, D if they are present in the view. Controller also of course has the handler that tells whatever else to do what it has to do (now I'm just guessing because I don't know what you're ultimately trying to accomplish). If something needs to happen when something changes data-wise in the model, then you would listen to the model which dispatches events and have the controller respond, perhaps by telling the view to change. IMO, the Controller is the most ambiguous part of the MVC pattern. View and Model are pretty straightforward (esp. the Model). Different people have different ways of using the controller, but this is how I use it. It listens to other parts of your app, and then tells other parts of your app to do something. It's the central nervous system to use a methaphor - at least how I use it. AS3 Frameworks get more broken down than that, using things like Command classes, Mediators, and Facades and junk for even better OOP development and control, but there can be a steep learning curve to most of those frameworks. Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (note: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Andrew Sinning Sent: Tuesday, February 23, 2010 12:05 PM To: Flash Coders List Subject: Re: [Flashcoders] accessing event dispatchers in a loosely-coupled,modular design In other words: Create a Controller class before creating any other classes. Any instances that need to know when potential event dispatchers are created should listen to the Controller class. When dispatchers are created, the Controller class should dispatch an event. This way I won't need to use a Timer to repeatedly look for the dispatchers. Merrill, Jason wrote: If an instance of those classes has been created, then it will eval to true, otherwise it will be null, so this should work for that part of the problem: if(_myinstance) _myInstance.addEventListener(myEvent, myHandler); However, if you're creating A after B, C, and D, then you'll want to call the code above from say, a Controller class whenever A is created. Once A is created, then that's a trigger to add the listeners to the other classes if they exist. Make sense? Jason Merrill Bank of America Global Learning Learning Performance Solutions Join the Bank of America Flash Platform Community and visit our Instructional Technology Design Blog (inote: these are for Bank of America employees only) -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Andrew Sinning Sent: Tuesday, February 23, 2010 10:04 AM To: Flash Coders List Subject: [Flashcoders] accessing event dispatchers in a loosely-coupled,modular design Following the discussion about root yesterday, it got me thinking about a constant problem I face. Object-A needs to listen to events coming from objects B, C and D, but only if and when these objects actually exist. There's no guarantee that any of the objects B, C and D will be instantiated before or after A is instantiated. So, what's the proper way for A to add itself as a listener to B, C and D? What I'm currently do is this: The event dispatchers (B, C, D etc) implement a singleton interface. Within the target (A), I set up a Timer event to repeatedly check for instances of the dispatchers. Once a dispatcher is found, the target adds itself as a listener, and a pointer to the dispatcher is created so that the target can later remove itself. I'm not very happy with this design, but it's the best that I've been able to come up with. Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Hello Valentin, On Wed, Feb 24, 2010 at 12:06 AM, Valentin Schmidt v...@dasdeck.com wrote: so then why did you start with posting code here (pasted below) that didn't contain any exception catching? that's the crucial point: you have to catch the exception, otherwise you would either get corrupted UTF strings or and be caught in an infinite loop (because you used while instead of if!). yes, I did try catching the exceptions. In fact that is the code running at my site ( http://apps.facebook.com/video-preferans/ ) right now and it still doesn't work. The try/catch won't help here. And if you use an if instead of while, then you lose even more incoming data. Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
And if you use an if instead of while, then you lose even more incoming data. how come? ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] How to remove bytes from the beginning of a ByteArray?
Hello, sorry, but I'll try to start another thread to explain my problem. I read data from a socket into a ByteArray _ba and keep inspecting it. When there is enough data, I'd like to extract and process it and remove the processed bytes from the _ba. Here is how I try to do the removal, but it doesn't work (newBA is empty) var newBA:ByteArray = new ByteArray(); newBA.readBytes(_ba); _ba = newBA; My complete code is at: http://pastebin.com/esz4As6D Thank you Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
On Wed, Feb 24, 2010 at 12:36 AM, Valentin Schmidt v...@dasdeck.com wrote: And if you use an if instead of while, then you lose even more incoming data. how come? Ok, here your suggestion again: private function handleTcpData(event:Event):void { if(_socket.bytesAvailable) { // USE IF, NOT WHILE! try{ // CATCH THE EXCEPTION var str:String = _socket.readUTF(); updateGUI(str); }catch(e:Error){} } } The problem is that you read an UTF string with prefixed length just once. But since it's TCP sockets, data can arrive in different amounts. And in fact I see that sometimes not just one, but several UTF strings with prefix will arrive. But your if-code will process just the 1st one. And another problem with that code: if a half of a string arrives, then it will throw an EOFError, then go into the empty catch branch and just lose that data. Regards Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
After some thought... the 2nd case (not enough data arrived) is not a problem for your code, because the handleTcpData() will get called again - once the rest of the data arrived. But for the 1st case (several UTF strings arrived at once)... Maybe I should try the following (and don't need a ByteArray): private function handleTcpData(event:Event):void { // KEEP EXTRACTING UTF-STRINGS while(_socket.bytesAvailable) { try{ var str:String = _socket.readUTF(); updateGUI(str); }catch(e:Error){ // INCOMPLETE STRING, WILL BE READ LATER return; } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] bytesAvailable, readUTF() and ProgressEvent.SOCKET_DATA
Alexander Farber wrote: After some thought... the 2nd case (not enough data arrived) is not a problem for your code, because the handleTcpData() will get called again - once the rest of the data arrived. But for the 1st case (several UTF strings arrived at once)... Maybe I should try the following (and don't need a ByteArray): private function handleTcpData(event:Event):void { // KEEP EXTRACTING UTF-STRINGS while(_socket.bytesAvailable) { try{ var str:String = _socket.readUTF(); updateGUI(str); }catch(e:Error){ // INCOMPLETE STRING, WILL BE READ LATER return; } } } yes, I think that might be a good idea: the problem I saw peviously was that if bytesAvailable0, but for some reason the try-statement fails (and therefor bytesAvailable isn't set to 0), you would be caught in an infinite loop, because I don't think the socket data will be updated from outside while you are inside such an endless repeat-loop. but by adding this return statement that leaves the loop this can't happen anymore. good luck :-) cheers, valentin ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Error 1009
Hey, I have not seen your debugger error. but I feel its the stage that is getting null value. Please trace stage to find out. Let me know. Cheers Deepanjan Das On Tue, Feb 23, 2010 at 11:45 PM, Victor Subervi victorsube...@gmail.comwrote: On Tue, Feb 23, 2010 at 12:04 PM, Glen Pike g...@engineeredarts.co.uk wrote: Are you listening for Event.INIT or Event.COMPLETE for your preloader? You should possibly use the former to make sure all your child clips are instanciated before you run AS3 code that accesses these child clips. Yes. I changed COMPLETE to INIT and got the same error: package { import flash.events.Event; import flash.events.MouseEvent; import flash.display.MovieClip; import com.greensock.*; import com.greensock.easing.*; import flash.display.Loader; import flash.events.ProgressEvent; import flash.text.TextField; import flash.text.TextFormat; import flash.text.TextFieldAutoSize; import flash.net.URLRequest; public class Preloader extends MovieClip { private var l:Loader = new Loader(); private var myTextField:TextField = new TextField(); function Preloader() { init(); } function init() { l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop); l.contentLoaderInfo.addEventListener(Event.COMPLETE, done); l.load(new URLRequest(Splash.swf)); addChild(myTextField); myTextField.width = 250; myTextField.x = stage.stageWidth/2 - 50; myTextField.y = stage.stageHeight/2; myTextField.selectable = false; myTextField.border = false; myTextField.borderColor = 0xAA; myTextField.autoSize = TextFieldAutoSize.LEFT; var myFormat:TextFormat = new TextFormat(); myFormat.color = 0xAA; myFormat.size = 24; myFormat.italic = true; //myTextField.setTextFormat(myFormat); myTextField.defaultTextFormat = myFormat; } function loop(e:ProgressEvent):void { var perc:Number = e.bytesLoaded/e.bytesTotal; myTextField.text = Math.ceil(perc*100).toString() + %; } function done(e:Event):void { removeChildAt(0); myTextField = null; addChild(l); } } } For Hendrik, I am currently downloading the debugger. It's big! TIA, Victor ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Warm Regards Deepanjan Das M: +91 9836582808 Think of the environment before printing this email ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?
Hi, You've got the source / destination backwards. readBytes reads *from* the object on which the method is called. And it writes *to* the ByteArray you pass in the first parameter. So this: var newBA:ByteArray = new ByteArray(); newBA.readBytes(_ba); _ba = newBA; Is copying data *from* newBA *to* _ba. You want the opposite, so it should read: var newBA:ByteArray = new ByteArray(); _ba.readBytes(newBA); _ba = newBA; You can also do the read / write in place. It's a just bit more contrived but I'm not sure if it's worth it (it's less readable, I think). Here's how you'd do it, anyway: // let's assume for brevity that you've read 6 bytes from your original buffer and you still have data left (i.e., len 6) var offset:int = 6; // how much to read? All of the remaining data, which is the current length, minus your current position (we said it was 6) var newLen:int = _ba.length - offset; // Read the data starting at current position and write it to the same buffer, starting to write at the first byte. // 0 is the offset in the *destination*. We want to copy the 6th byte into the 0th position, that's why we pass 0. // the third parameter tells the method how much to read from the *source* // for what you want you don't actually need to pass these two last parameters, since by default readBytes will write to *dest* at offset 0 // and will read from *source* all available data (i.e. from current position to length -1) _ba.readBytes(_ba,0,newLen); // you do need to set this since this read/wirte is in place and you want to shrink the buffer. Othewise, you'll end up with garbage after at the end of the byte array. _ba.length = newLen; And that's it. Hope it helps. Cheers Juan Pablo Califano 2010/2/23 Alexander Farber alexander.far...@gmail.com Hello, sorry, but I'll try to start another thread to explain my problem. I read data from a socket into a ByteArray _ba and keep inspecting it. When there is enough data, I'd like to extract and process it and remove the processed bytes from the _ba. Here is how I try to do the removal, but it doesn't work (newBA is empty) var newBA:ByteArray = new ByteArray(); newBA.readBytes(_ba); _ba = newBA; My complete code is at: http://pastebin.com/esz4As6D Thank you Alex ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Event.COMPLETE Question
If you call close() on a Loader and it fails for any reason, it will throw a runtime error that you can do nothing about. To avoid this, you should wrap it in a try catch. The code block comes straight from Flex and it works. If you test it a bunch and close() never fires an error, then you can remove it. It's really not that much overhead to keep it in unless you're doing hundreds of iterations per second. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?
FWIW, flush() does nothing in AS3. Bytes written to the Socket are sent immediately. Anyone who tells you otherwise has never tested it and you can safely ignore them! :) Adobe has acknowledged this as a documentation bug (whatever that means). For more info: http://www.stevensacks.net/2009/12/08/flash-socket-class-does-not-wait-for-flush/ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] How to remove bytes from the beginning of a ByteArray?
private var buffer:ByteArray; private function onData(event:ProgressEvent):void { socket.readBytes(buffer, buffer.length); var bytes:ByteArray = new ByteArray(); buffer.readBytes(bytes, 0, messageLength); buffer.position = bytes.length; trim(); // deserialize the message in bytes now } private function trim():void { var bytes:ByteArray = new ByteArray(); bytes.writeBytes(buffer, buffer.position); buffer = bytes; buffer.position = 0; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders