[Flashcoders] AS2 - problems calling a movieclip class
hi guys - really hope you can help with this one i've got the following class assigned to a movieclip (using linkage) [code] import com.receptacledesign.events.EventClip import mx.utils.Delegate; class com.avatar extends EventClip // adds events to the movieclip { var _nc:NetConnection; var _ns:NetStream; var _mp3:String; var player:MovieClip; var avatarStatic:MovieClip; // constructor public function avatar() { init(); } private function init():Void { trace(this + is here. v0.2); // outputs correctly player = this.attachMovie(mcVideo, player, this.getNextHighestDepth()); } public function mouthControl(mouthMode:String):Void { trace(mouthControl); // doesn't trace :( switch (mouthMode) { case start : trace(startMouth); startMouth(); break; case stop : trace(stopMouth); stopMouth(); break; default : trace(mouthMode not recognised); } } public function testavatar():Void // doesn't fire :( { trace(avatar is testing); } // private methods - private function startMouth():Void { trace(startMouth()); _nc = new NetConnection(); _nc.connect(null); _ns = new NetStream(_nc); player.attachVideo(_ns); _ns.play(mp3: + MP3); _ns.onStatus = Delegate.create(this, nsOnStatus); lexStatic.gotoAndPlay(on); } private function stopMouth():Void { trace(stopMouth()); } private function fireEvent(evt:String):Void { if (evt != outro) gotoAndStop(static); dispatchEvent({target:this, value:evt, type:EventClip.FINISHED}); } private function nsOnStatus(evt:Object):Void { trace(evt.code); if (evt.code == NetStream.Buffer.Flush) stopMouth(); } // getters and setters public function set MP3(s:String):Void { _mp3 = s; } public function get MP3():String { return _mp3; } } [/code] and i'm trying to do the following set the mp3 file path with the setter mp3 run the mouthControl() method so i've done this in my main class: private var avatar:MovieClip; // set on initialisation private function avatarSayWord():Void { avatar.MP3 = Questions[nCurrentQuestion].media; trace(Game.avatarSayWord: + avatar.MP3); // traces path to mp3 file correctly from avatar avatar.mouthControl(start); // does nothing avatar.testavatar(); // does nothing } the setter and the getter is working but the public methods aren't working at all what am i doing wrong please? please help - it's crunch time here thankyou alz ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] AS2 - problems calling a movieclip class
ah never mind again - i got it i was referencing the holding clip, not the clip with the class on sorry alz On 3 Oct 2008, at 12:07, Allandt Bik-Elliott (Receptacle) wrote: hi guys - really hope you can help with this one i've got the following class assigned to a movieclip (using linkage) [code] import com.receptacledesign.events.EventClip import mx.utils.Delegate; class com.avatar extends EventClip // adds events to the movieclip { var _nc:NetConnection; var _ns:NetStream; var _mp3:String; var player:MovieClip; var avatarStatic:MovieClip; // constructor public function avatar() { init(); } private function init():Void { trace(this + is here. v0.2); // outputs correctly player = this.attachMovie(mcVideo, player, this.getNextHighestDepth()); } public function mouthControl(mouthMode:String):Void { trace(mouthControl); // doesn't trace :( switch (mouthMode) { case start : trace(startMouth); startMouth(); break; case stop : trace(stopMouth); stopMouth(); break; default : trace(mouthMode not recognised); } } public function testavatar():Void // doesn't fire :( { trace(avatar is testing); } // private methods - private function startMouth():Void { trace(startMouth()); _nc = new NetConnection(); _nc.connect(null); _ns = new NetStream(_nc); player.attachVideo(_ns); _ns.play(mp3: + MP3); _ns.onStatus = Delegate.create(this, nsOnStatus); lexStatic.gotoAndPlay(on); } private function stopMouth():Void { trace(stopMouth()); } private function fireEvent(evt:String):Void { if (evt != outro) gotoAndStop(static); dispatchEvent({target:this, value:evt, type:EventClip.FINISHED}); } private function nsOnStatus(evt:Object):Void { trace(evt.code); if (evt.code == NetStream.Buffer.Flush) stopMouth(); } // getters and setters public function set MP3(s:String):Void { _mp3 = s; } public function get MP3():String { return _mp3; } } [/code] and i'm trying to do the following set the mp3 file path with the setter mp3 run the mouthControl() method so i've done this in my main class: private var avatar:MovieClip; // set on initialisation private function avatarSayWord():Void { avatar.MP3 = Questions[nCurrentQuestion].media; trace(Game.avatarSayWord: + avatar.MP3); // traces path to mp3 file correctly from avatar avatar.mouthControl(start); // does nothing avatar.testavatar(); // does nothing } the setter and the getter is working but the public methods aren't working at all what am i doing wrong please? please help - it's crunch time here thankyou alz ___ 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] how to uncompress a compressed bytearray with PHP
Thanks Juan Pablo Califano. I'm already sending the data in binary form so that's is probably not the problem. You are right about that the php decompression should be done with gzinflate (I did test with it before but that didn't work either so I thought I should try gzuncompress ;) When I compare the deflating results of the same string in PHP and Flash I noticed that flash started with two extra bytes while the rest of the output was the same. Next I added this code to the PHP test script to remove the two extra leading bytes: mb_internal_encoding(UTF-8); $encoded = mb_substr($_POST[XMLString], 2); Now when I compare the string in $encoded with the encoded string produced by PHP deflate() then both seem to be exactly the same. So I expected that $decoded = gzuncompress($encoded); would now return the original string but no, an empty string is returned!? If however I copy (i.e. hardcode) the compressed string into $encoded and then execute $decoded = gzuncompress($encoded); Then it Works; I get the original text!? Big question now why does it work with the hardcoded compressed string and not with runtime compressed string, they seem to be exactly the same?? Any ideas? BTW: thanks for your time :) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] how to uncompress a compressed bytearray with PHP
(please ignore previous reply - contained mistakes regarding gzuncompress while I meant gzinflate) Thanks Juan Pablo Califano. I'm already sending the data in binary form so that's is probably not the problem. You are right about that the php decompression should be done with gzinflate (I did test with it before but that didn't work either so I thought I should try gzuncompress ;) When I compare the deflating results of the same string in PHP and Flash I noticed that flash started with two extra bytes while the rest of the output was the same. Next I added this code to the PHP test script to remove the two extra leading bytes: mb_internal_encoding(UTF-8); $encoded = mb_substr($_POST[XMLString], 2); Now when I compare the string in $encoded with the encoded string produced by PHP deflate() then both seem to be exactly the same. So I expected that $decoded = gzinflate($encoded); would now return the original string but no, an empty string is returned!? If however I copy (i.e. hardcode) the compressed string into $encoded and then execute $decoded = gzinflate($encoded); Then it Works; I get the original text!? Big question now why does it work with the hardcoded compressed string and not with runtime compressed string, they seem to be exactly the same?? Any ideas? BTW: thanks for your time :) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] Advice on creating nodes on elastic
Hiya, I want to create something very similar to visualthesaurus.com, dyamically generating nodes with labels that are linked by elastic. I'm thinking of using the APE from cove.org If anyone can point me in the way of any tutorials/alternative approaches or existing source that would be amazing! Thanks, Ali ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Advice on creating nodes on elastic
IMO you dont need a third party engine for this. Elastic is an easy property to model programatically. var bindX : Number = 100; var bindY : Number = 100; var x : Number = bindX: var y : Number = bindY; var nodeVelX : Number = 3; var nodeVelY : Number = 2; function update() : void { nodeVelX += (bindX-x)/4; nodeVelY += (bindY-y)/4; x += nodeVelX; y += nodeVelY; nodeVelX *= 0.99; nodeVelY *= 0.99; } or something simmilar to that. 2008/10/3 Ali Drongo [EMAIL PROTECTED] Hiya, I want to create something very similar to visualthesaurus.com, dyamically generating nodes with labels that are linked by elastic. I'm thinking of using the APE from cove.org If anyone can point me in the way of any tutorials/alternative approaches or existing source that would be amazing! Thanks, Ali ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders -- Mike Cann http://www.artificial-studios.co.uk/ ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] sizing an arbitrary loaded swf
Thanks Juan. I have a question about the internal class SwfRect that's at the end of the SwfHeader class. I'm really new to AS3, so this will sound like a really dumb question: Where does the internal class SwfRect go? It's outside of the package. Can it be in the same file? Does it need to be inside of a package? Thanks! Juan Pablo Califano wrote: http://pastebin.be/14115 (SwfHeader class) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Advice on creating nodes on elastic
I started working on something similar, and converted some AS2 Code I found to AS3. It's not finished, or well commented - but should give you a good starting point: http://kurst.co.uk/transfer/GGear.rar . I was thinking of making this open source once I got further down the road, but want to contact the original AS2 authors. If you could send me source of any improvements you make it would be great. - karim Credits: /* * Flash Graph Visualization Toolkit * Goal: To provide a simple interactive toolkit for visualizing graph structure and end countless * fruitless goolge:actionscript graph -chart queries. * * Acknowledgements: * This toolkit owes a debt of gratitude to many people. Mostly the early paper on this topic: * Graph Drawing by Force-directed Placement by Fruchterman Reingold * [http://www.cs.ubc.ca/rr/proceedings/spe91-95/spe/vol21/issue11/spe060tf.pdf ] * * And also to Marcos Weskamp's beautiful FlickrGraph, which we've spent countless hour playing * with; he just got it -right-. This is pretty close, but not quite. * [http://www.marumushi.com/apps/flickrgraph/] * * And of course to the Macromedia/Adobe team that brings us flash. Rot in hell Ajax. * * Final Note: Don't like this? Rip out the render, attractForce, repelForce and do your own thing. */ -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Ali Drongo Sent: 03 October 2008 14:55 To: Flash Coders List Subject: [Flashcoders] Advice on creating nodes on elastic Hiya, I want to create something very similar to visualthesaurus.com, dyamically generating nodes with labels that are linked by elastic. I'm thinking of using the APE from cove.org If anyone can point me in the way of any tutorials/alternative approaches or existing source that would be amazing! Thanks, Ali ___ 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] Advice on creating nodes on elastic
You can consider using Birdeye. This should everything you want: http://code.google.com/p/birdeye/ Yours, Weyert ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] sizing an arbitrary loaded swf
Actionscript 3.0 allows only one public symbol (class, function, variable or constant) per .as file. I made that class internal so I could put both classes in just one file for this sample, but apart from that, it's not neccesary, really. Cheers Juan Pablo Califano 2008/10/3, Andrew Sinning [EMAIL PROTECTED]: Thanks Juan. I have a question about the internal class SwfRect that's at the end of the SwfHeader class. I'm really new to AS3, so this will sound like a really dumb question: Where does the internal class SwfRect go? It's outside of the package. Can it be in the same file? Does it need to be inside of a package? Thanks! Juan Pablo Califano wrote: http://pastebin.be/14115 (SwfHeader class) ___ 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] how to uncompress a compressed bytearray with PHP
Hi, I think you shouldn't use UTF-8 and mb_ functions. In this scenario, one useful property of the php strings API is that doesn't really understand anything about encodings. A byte is a char and that's all, so you can use that API as if it were acting on raw buffers. In this case, that's what you need, because if you parse the data as UTF-8 you are most likely going to get illegal sequences at some point. I've written a little test and it seems to be working (at least I receive the expected results back in the flash side). Cheers Juan Pablo Califano AS CODE (in the timeline, mind you): import flash.utils.ByteArray; var buffer:ByteArray = new ByteArray(); buffer[0] = 0x43; buffer[1] = 0x61; buffer[2] = 0x6c; buffer[3] = 0x69; buffer[4] = 0x66; buffer[5] = 0x61; buffer[6] = 0x00; buffer.compress(); buffer.position = 0; var dump:String = $data = ; while(buffer.bytesAvailable 0) { dump += chr(0x + buffer.readUnsignedByte().toString(16) + ); if(buffer.bytesAvailable 0) { dump += . ; } } dump += ;; trace(dump from flash: + dump); import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLRequestMethod; import flash.net.URLLoaderDataFormat; import flash.events.*; function completeHandler(event:Event):void { var loader:URLLoader = URLLoader(event.target); trace(data received from PHP: \n + loader.data); } var urlLoader:URLLoader = new URLLoader(); urlLoader.dataFormat = URLLoaderDataFormat.BINARY; urlLoader.addEventListener(Event.COMPLETE, completeHandler); var req:URLRequest = new URLRequest(http://localhost/compress/compress.php ); req.method = URLRequestMethod.POST; req.data = buffer; urlLoader.load(req); PHP FILE: ?php //$data = chr(0x78) . chr(0xda) . chr(0x73) . chr(0x4e) . chr(0xcc) . chr(0xc9) . chr(0x64) . chr(0x0) . chr(0x0) . chr(0x4) . chr(0xee) . chr(0x1) . chr(0x7a); $data = file_get_contents(php://input,rb); $trimmed_data = substr($data, 2); $decoded = gzinflate($trimmed_data); echo dumpToHexString($trimmed_data); echo dumpToHexString($decoded); function dumpToHexString($input) { $ret = ''; $len = strlen($input); $i = 0; while($i $len) { $ret .= [$i] : . dechex(ord($input[$i])) . \n; $i++; } return $ret; } ? 2008/10/3, Benny [EMAIL PROTECTED]: (please ignore previous reply - contained mistakes regarding gzuncompress while I meant gzinflate) Thanks Juan Pablo Califano. I'm already sending the data in binary form so that's is probably not the problem. You are right about that the php decompression should be done with gzinflate (I did test with it before but that didn't work either so I thought I should try gzuncompress ;) When I compare the deflating results of the same string in PHP and Flash I noticed that flash started with two extra bytes while the rest of the output was the same. Next I added this code to the PHP test script to remove the two extra leading bytes: mb_internal_encoding(UTF-8); $encoded = mb_substr($_POST[XMLString], 2); Now when I compare the string in $encoded with the encoded string produced by PHP deflate() then both seem to be exactly the same. So I expected that $decoded = gzinflate($encoded); would now return the original string but no, an empty string is returned!? If however I copy (i.e. hardcode) the compressed string into $encoded and then execute $decoded = gzinflate($encoded); Then it Works; I get the original text!? Big question now why does it work with the hardcoded compressed string and not with runtime compressed string, they seem to be exactly the same?? Any ideas? BTW: thanks for your time :) ___ 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] how to uncompress a compressed bytearray with PHP
On Fri, Oct 3, 2008 at 6:36 PM, Benny [EMAIL PROTECTED] wrote: The only problem now is that in the production code I have to send several ByteArray objects to the server in one go. And I have to process them separately in the PHP script. Hence I thought the obvious thing would be to assign the various vars to an URLVariables object and send that as the URLRequest data. On the PHP side I wanted then to access those vars again as members of the $_POST array and gzinflate the compressed vars there for further processing. Can't you just mash the ByteArrays into one long ByteArray; and at the beginning of that ByteArray store the number of arrays and the length of each one? Then send it as one array and break it apart again once the decoding is done? Ian ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] how to uncompress a compressed bytearray with PHP
We are getting closer ;-) The code you provided worked for me too. When I compare my code to yours I notice that I am using the $_POST array while you are using the PHP input stream. The other major difference is the fact that I am POSTing using via an URLVariables instance. When I change both in my code then everything indeed works fine. The only problem now is that in the production code I have to send several ByteArray objects to the server in one go. And I have to process them separately in the PHP script. Hence I thought the obvious thing would be to assign the various vars to an URLVariables object and send that as the URLRequest data. On the PHP side I wanted then to access those vars again as members of the $_POST array and gzinflate the compressed vars there for further processing. Can you think of any solution that would make this possible? The only thing which comes to my mind at the moment is parsing the php input string by hand but I still would expect that the $_POST array should just work too, after all it seems it contains the correct compressed string. But when I feed that string to the gzinflate function I get an empty string in return and when I feed it the exact same string hardcoded then it returns the correct uncompressed string... I must be missing something obvious ;-) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
[Flashcoders] flushing memory
hi folks is there any way i can completely flush the memory for the flash plugin? i have a spelling game that uses classes on symbols placed on the timeline and when i hit a replay button at the end of my game, the playhead is moved to the start of the timeline (so none of the symbols are present any more) and then the game is started up again the only problem is that when the game goes through it's second pass, all of the questions are duplicated. I've tried delete'ing all of the objects in the class itself at the end of the game before i move back to the start but it still happens the only way i can see around it is to reload the whole page but that's a hit on the server which seems a little over the top cheers alz ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] flushing memory
Handle it without using a timeline at all and use code straight instead? On Fri, Oct 3, 2008 at 2:11 PM, Allandt Bik-Elliott (Receptacle) [EMAIL PROTECTED] wrote: hi folks is there any way i can completely flush the memory for the flash plugin? i have a spelling game that uses classes on symbols placed on the timeline and when i hit a replay button at the end of my game, the playhead is moved to the start of the timeline (so none of the symbols are present any more) and then the game is started up again the only problem is that when the game goes through it's second pass, all of the questions are duplicated. I've tried delete'ing all of the objects in the class itself at the end of the game before i move back to the start but it still happens the only way i can see around it is to reload the whole page but that's a hit on the server which seems a little over the top cheers alz ___ 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] how to uncompress a compressed bytearray with PHP
There's one problem with using URLVariables: it works on NUL-terminated strings, so if you happen to have a 0 in the compressed data, it will be truncated Some time ago I wrote a class to post data in multipart format (basically, it does the same the browser does when you have a form with a file input). I used it to send image files, but since the data is binary, it shouldn't matter what kind of file you're sending. So, from the php side you handle it much like an oridnary html form. Text variables will be put in $_POST, and the files, i.e. the binary data, would be in $_FILES. I had uploaded that class to pastebin and it's still there: http://pastebin.com/f11a897cf I'm re-pasting a use example from another email: = An example of use (it's a copy paste from some worting code, just to give you an idea): import ar.com.califa010.utils.FormData; // getEncodedImg() is a method that returns a JPG as a byteArray var rawJpg:ByteArray = getEncodedImg(); var formData:FormData = new FormData(); var imageMimeType:String = FormData.JPG_FILE; var fileName:String = imageFile.jpg; // from the php side, you'll get this data with $_FILES['imageFile'] // rawJpg is the byteArray you want to send // fileName and imageMimeType don't really matter that much // it's supposed to send the name of the original file and the type to hint the server, but // I think you can leave it as is and will have no problems formData.addFile(imageFile, rawJpg, fileName, imageMimeType); formData.addField(sFormat,imgFormat); formData.addField(idImagen,_idImagen); var req:URLRequest = new URLRequest(url); req.method = POST; req.contentType = formData.contentType; req.data = formData.getPostData(); var loader:URLLoader = new URLLoader(); configureListeners(loader); loader.load(req); = Cheers Juan Pablo Califano 2008/10/3, Benny [EMAIL PROTECTED]: We are getting closer ;-) The code you provided worked for me too. When I compare my code to yours I notice that I am using the $_POST array while you are using the PHP input stream. The other major difference is the fact that I am POSTing using via an URLVariables instance. When I change both in my code then everything indeed works fine. The only problem now is that in the production code I have to send several ByteArray objects to the server in one go. And I have to process them separately in the PHP script. Hence I thought the obvious thing would be to assign the various vars to an URLVariables object and send that as the URLRequest data. On the PHP side I wanted then to access those vars again as members of the $_POST array and gzinflate the compressed vars there for further processing. Can you think of any solution that would make this possible? The only thing which comes to my mind at the moment is parsing the php input string by hand but I still would expect that the $_POST array should just work too, after all it seems it contains the correct compressed string. But when I feed that string to the gzinflate function I get an empty string in return and when I feed it the exact same string hardcoded then it returns the correct uncompressed string... I must be missing something obvious ;-) ___ 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] how to uncompress a compressed bytearray with PHP
There's one problem with using URLVariables: it works on NUL-terminated Strings You're right, so URLVariables is now out of the picture ;-) I think your class would indeed do the job but because I want to keep the client code as light as possible I think I'll just send one big compressed ByteArray to the server inflate it and decode the AMF data using the AMF capabilities the Zend Framework will bring in the near future. Thank you for your time and great input!! Cheers, Benny ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders