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 =
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
Thank you!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
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
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
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
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
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
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
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
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
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
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
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:
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
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
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
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);
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:
Bingo!
Try this instead:
var mySprite:Sprite = new Sprite();
function createBar(dfile:String):void {
...
function createGraph():void {
mySprite.graphics.
addChild(mySprite);
}
}
function clearBar():void {
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
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);
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
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),
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
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
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!
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
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
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
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
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);
{
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
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);
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
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:
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
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();
...
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
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++)
{
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:
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'
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...
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
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 :-)
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
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
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
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:
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
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
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
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
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.
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.
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
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();
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
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
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
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();
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];
}
___
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);
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
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
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
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,
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
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
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
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,
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
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
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
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
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
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.
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
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);
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
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){}
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
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
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
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
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
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
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
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
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
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
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:
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
93 matches
Mail list logo