[Flashcoders] AS2 EventDispatcher problem

2008-10-02 Thread Allandt Bik-Elliott (Receptacle)

hi guys - i could really use some help here

I have a swf, 'swf', that has a movieclip called 'clip' placed on  
stage that uses the following class in it's linkage


all of this is loaded into another swf with moviecliploader

[code]
import com.receptacledesign.events.EventClip

class com.Clip extends EventClip
{
public function Lex()
{
super();

trace(Lex is here);
trace(_root._currentframe);
}

public function fireEvent(evt:String):Void
{
trace(evt);
dispatchEvent({target:this, type:EventClip.FINISHED});
}
}
[/code]

The fireEvent method of Clip is called from the timeline of the clip

once the onLoadInit event fires, i'm trying to listen to it within the  
main class using the following line:


[code]
swf.clip.addEventListener(EventClip.FINISHED, Delegate.create(this,  
animationFinished));

[/code]

but the event never gets picked up (i have a trace in the  
animationFinished method to see if it's working) even tho the  
fireEvent method traces correctly (with the trace(evt));


is it possible to do what i'm trying to do or have i done something  
stupid?


thanks
allandt

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] AS2 EventDispatcher problem

2008-10-02 Thread Ian Thomas
Where's the code for EventClip? Without that, we can't be much help. :-)

Also - does trace(swf.clip) return something sensible on the timeline?
(Just so you know you're targeting the right object when using
addEventListener)

HTH,
   Ian

On Thu, Oct 2, 2008 at 11:55 AM, Allandt Bik-Elliott (Receptacle)
[EMAIL PROTECTED] wrote:
 hi guys - i could really use some help here

 I have a swf, 'swf', that has a movieclip called 'clip' placed on stage that
 uses the following class in it's linkage

 all of this is loaded into another swf with moviecliploader

 [code]
 import com.receptacledesign.events.EventClip

 class com.Clip extends EventClip
 {
public function Lex()
{
super();

trace(Lex is here);
trace(_root._currentframe);
}

public function fireEvent(evt:String):Void
{
trace(evt);
dispatchEvent({target:this, type:EventClip.FINISHED});
}
 }
 [/code]

 The fireEvent method of Clip is called from the timeline of the clip

 once the onLoadInit event fires, i'm trying to listen to it within the main
 class using the following line:

 [code]
 swf.clip.addEventListener(EventClip.FINISHED, Delegate.create(this,
 animationFinished));
 [/code]

 but the event never gets picked up (i have a trace in the animationFinished
 method to see if it's working) even tho the fireEvent method traces
 correctly (with the trace(evt));

 is it possible to do what i'm trying to do or have i done something stupid?

 thanks
 allandt

 ___
 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] sizing an arbitrary loaded swf

2008-10-02 Thread Andrew Sinning
I'm using AS3.  After loading in an arbitrary swf using the Loader 
class, getRect and getBounds don't necessarily reveal the internally 
defined boundaries of the loaded swf, rather they seem to return the 
boundaries of the stuff inside the loaded swf which can be either 
smaller or larger than the internally defined boundaries.  Am I missing 
something?


I want to load in a swf, create a mask around it so that only the stuff 
that is supposed to show is shown, and then scale it to fit a target 
area.  This should be easy, right?


Thanks!
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Steve Mathews
No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning [EMAIL PROTECTED]wrote:

 I'm using AS3.  After loading in an arbitrary swf using the Loader class,
 getRect and getBounds don't necessarily reveal the internally defined
 boundaries of the loaded swf, rather they seem to return the boundaries of
 the stuff inside the loaded swf which can be either smaller or larger than
 the internally defined boundaries.  Am I missing something?

 I want to load in a swf, create a mask around it so that only the stuff
 that is supposed to show is shown, and then scale it to fit a target area.
  This should be easy, right?

 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] sizing an arbitrary loaded swf

2008-10-02 Thread Steve Abaffy
Just brainstorming here, not sure if this will work. Can you not put a box
or something on the stage that is the same size as the stage. If you can
access individual components on the stage then get the size of this box and
you will know the size of the stage. Just my $0.02 worth

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve
Mathews
Sent: Thursday, October 02, 2008 10:39 AM
To: Flash Coders List
Subject: Re: [Flashcoders] sizing an arbitrary loaded swf

No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning
[EMAIL PROTECTED]wrote:

 I'm using AS3.  After loading in an arbitrary swf using the Loader class,
 getRect and getBounds don't necessarily reveal the internally defined
 boundaries of the loaded swf, rather they seem to return the boundaries of
 the stuff inside the loaded swf which can be either smaller or larger than
 the internally defined boundaries.  Am I missing something?

 I want to load in a swf, create a mask around it so that only the stuff
 that is supposed to show is shown, and then scale it to fit a target area.
  This should be easy, right?

 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] sizing an arbitrary loaded swf

2008-10-02 Thread kris range
or if you are loading the swf files from external data source like
xml, put an attribute in your xml of the size needed.

component url=/someswf.swf width=500 height=400 /

On Thu, Oct 2, 2008 at 9:05 AM, Steve Abaffy [EMAIL PROTECTED] wrote:
 Just brainstorming here, not sure if this will work. Can you not put a box
 or something on the stage that is the same size as the stage. If you can
 access individual components on the stage then get the size of this box and
 you will know the size of the stage. Just my $0.02 worth

 -Original Message-
 From: [EMAIL PROTECTED]
 [mailto:[EMAIL PROTECTED] On Behalf Of Steve
 Mathews
 Sent: Thursday, October 02, 2008 10:39 AM
 To: Flash Coders List
 Subject: Re: [Flashcoders] sizing an arbitrary loaded swf

 No, this is not easy. Unfortunately the data that defines the stage size is
 not directly available in AS code. I believe it is only in the swf
 file's header, so you would actually have to do a lot of work to figure out
 what size the swf should be masked at.
 Steve

 On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning
 [EMAIL PROTECTED]wrote:

 I'm using AS3.  After loading in an arbitrary swf using the Loader class,
 getRect and getBounds don't necessarily reveal the internally defined
 boundaries of the loaded swf, rather they seem to return the boundaries of
 the stuff inside the loaded swf which can be either smaller or larger than
 the internally defined boundaries.  Am I missing something?

 I want to load in a swf, create a mask around it so that only the stuff
 that is supposed to show is shown, and then scale it to fit a target area.
  This should be easy, right?

 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] sizing an arbitrary loaded swf

2008-10-02 Thread Andrew Sinning
Thanks Steve.  I thought maybe I was onto something with the LoaderInfo 
classes width and height props that return the nominal w and h, but 
this information doesn't seem to jive with what I'm observing.


I'm considering using BitmapData class to physically find the visible 
boarders of loaded swf, but I guess this assumes that there aren't any 
stray bits outside of the main image.


Steve Mathews wrote:

No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning [EMAIL PROTECTED]wrote:

  

I'm using AS3.  After loading in an arbitrary swf using the Loader class,
getRect and getBounds don't necessarily reveal the internally defined
boundaries of the loaded swf, rather they seem to return the boundaries of
the stuff inside the loaded swf which can be either smaller or larger than
the internally defined boundaries.  Am I missing something?

I want to load in a swf, create a mask around it so that only the stuff
that is supposed to show is shown, and then scale it to fit a target area.
 This should be easy, right?

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] sizing an arbitrary loaded swf

2008-10-02 Thread Andrew Sinning
If I understand the concept, I think this would require cross-domain 
policy to be turned on for my domain.  What we're trying to do here is 
load in an arbitrary swf hosted on an arbitrary domain.


You're talking about creating a new sprite in the scope of the loaded 
swf, right? 


Steve Abaffy wrote:

Just brainstorming here, not sure if this will work. Can you not put a box
or something on the stage that is the same size as the stage. If you can
access individual components on the stage then get the size of this box and
you will know the size of the stage. Just my $0.02 worth

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Steve
Mathews
Sent: Thursday, October 02, 2008 10:39 AM
To: Flash Coders List
Subject: Re: [Flashcoders] sizing an arbitrary loaded swf

No, this is not easy. Unfortunately the data that defines the stage size is
not directly available in AS code. I believe it is only in the swf
file's header, so you would actually have to do a lot of work to figure out
what size the swf should be masked at.
Steve

On Thu, Oct 2, 2008 at 7:36 AM, Andrew Sinning
[EMAIL PROTECTED]wrote:

  

I'm using AS3.  After loading in an arbitrary swf using the Loader class,
getRect and getBounds don't necessarily reveal the internally defined
boundaries of the loaded swf, rather they seem to return the boundaries of
the stuff inside the loaded swf which can be either smaller or larger than
the internally defined boundaries.  Am I missing something?

I want to load in a swf, create a mask around it so that only the stuff
that is supposed to show is shown, and then scale it to fit a target area.
 This should be easy, right?

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] sizing an arbitrary loaded swf

2008-10-02 Thread Kerry Thompson
Andrew Sinning wrote:



Andrew, it looks like you sized it a bit too small. Try posting your
question in a larger font, and we'll see what we can do to help.

Cordially,

Kerry Thompson

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] how to uncompress a compressed bytearray with PHP

2008-10-02 Thread Benny
I am sending a compressed bytearray to PHP:

 

var XMLOut:ByteArray = new ByteArray();

XMLOut.writeUTFBytes(rootitem1just an example/item1/root);

XMLOut.compress();

. cut .

 

The data is POSTed (with URLLoader in var XMLString) to
mydomain.com/save.php:

 

?php   

  $XMLString = gzuncompress($_POST[XMLString ]); 

  $handle = fopen(content/test.xml, w+b);

  fwrite($handle, $ XMLString);

  fclose($handle);

?

 

The result of this is that test.xml is being created but without any
content.

(BTW: If I leave out the compression/decompression part then the file is
created with the expected content)

 

Should this actually work with gzuncompress and if so why might it be
failing here?

Or should the uncompressioning be handled differently?

 

 

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] sizing an arbitrary loaded swf

2008-10-02 Thread Juan Pablo Califano
As someone already said, you can grab that data from the swf header.

I've done this in C# / .NET and I've just wrote a quick and dirty port of
the header parsing part to AS 3.0. Probably there's room for optimization
but as a proof of concept I think it's ok. Also, the code could use some
clean-up and the SwfRect part is based on an API different from ByteArray,
so basically I was not using readByte() and such but calculating offsets by
hand, which could be avoided.

So, the flow would be:

1) Load the swf as binary
2) Parse the headers to get the info you're looking for
3) Use the loadBytes method from the Loader class to load the swf from the
bytearray you already have loaded.

I'm pasting the sample code in this email, but you could see it more nicely
formatted here:

http://pastebin.be/14115   (SwfHeader class)
http://pastebin.be/14116   (Mainclass)

Cheers
Juan Pablo Califano

package {
 import flash.display.Sprite;
 import flash.net.URLLoader;
 import flash.net.URLLoaderDataFormat;
 import flash.events.*;
 import flash.net.URLRequest;

 public class Main extends Sprite {

  private var urlLoader:URLLoader;
  private var swfHeader:SwfHeader;

  public function Main() {
   init();
   loadSwf(test_data.swf);
  // loadSwf(test_data_comp.swf);
  }

  private function init() {
   urlLoader = new URLLoader();
   urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener(Event.COMPLETE, handleComplete);
urlLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
handleSecurityError);
urlLoader.addEventListener(IOErrorEvent.IO_ERROR,
handleIoError);
  }

private function handleComplete(event:Event):void {
var loader:URLLoader = URLLoader(event.target);
trace(completeHandler:  + loader.data);
   swfHeader = new SwfHeader();
   swfHeader.parse(loader.data);

}

private function handleSecurityError(event:SecurityErrorEvent):void
{
trace(securityErrorHandler:  + event);
}

private function handleIoError(event:IOErrorEvent):void {
trace(ioErrorHandler:  + event);
}

  public function loadSwf(file:String):void {
   var req:URLRequest = new URLRequest(file);
   urlLoader.load(req);
  }
 }
}
///
//


package {
 import flash.utils.ByteArray;
 import flash.utils.Endian;

 public class SwfHeader {


  public function SwfHeader() {

  }

  public function parse(rawData:ByteArray):void {
   var signature:String = rawData.readUTFBytes(3);
   var isCompressed:Boolean;

   // this is used to uncompress swf (if necesary). It can't be uncompressed
in place
   // since the first 8 bytes are not compressed...
   var buffer:ByteArray = new ByteArray();

   if (signature == FWS) {
isCompressed  = false;
rawData.position = 8;
rawData.readBytes(buffer, 0, rawData.length - 8);
   } else if (signature == CWS) {
isCompressed = true;
rawData.position = 8;
rawData.readBytes(buffer, 0, rawData.length - 8);
buffer.uncompress();
   } else {
trace(not a valid SWF);
   }

   rawData.position = 4;
   rawData.endian  = Endian.LITTLE_ENDIAN;
   var fileSize:uint  = rawData.readUnsignedInt();

   buffer.position  = 0;
   var rect:SwfRect = new SwfRect();
   rect.parse(buffer);

   trace(width:+rect.xMax);
   trace(height:+rect.yMax);

  }
 }
}


import flash.utils.ByteArray;


internal class SwfRect {

 public var xMin:uint;
 public var xMax:uint;
 public var yMin:uint;
 public var yMax:uint;

 public function SwfRect() {

 }

 /*
 RECT:

 5 parts:
 Nbits  UB[5]  (the number of bits for storing each field)
 Xmin SB[Nbits] x
 Xmax SB[Nbits] width
 Ymin SB[Nbits] y
 Ymax SB[Nbits] height
 */
 public function parse(buffer:ByteArray):void {
  // get the first 5 bits to know the size of each field
  var fieldBitSize:int = buffer[0]  3;
  // total data bits (w/o padding): the 5 bits read plus the fieldBitSize
of each field
  var rectBitSize:int  = 5 + (fieldBitSize * 4);
  // the rect struct is padded with 0'z for byte aligning...
  rectBitSize= rectBitSize + (8 - rectBitSize % 8);
  // divide by 8 to get the size of the rect in bytes
  var size:int   = rectBitSize / 8;

  var curOffset:uint = 0;

  var i:int  = 0;
  var bitPos:int = 5;  // the first bit to read:  0123 4xxx xxx xxx, etc
  var mask:int = 0;

 // int[] tmp = new int[4];
  var tmp:Array = new Array();

  while(i4) {


   var curField:int = 0;

   var bitsRead:int = 0;
   var bit:int   = 0;

   while(bitsReadfieldBitSize) {

// if we've hit the byte boundary, add 1 to the current offset in the
stream
if(bitPos % 8 == 0) {
 curOffset++;
}
// set the mask according to the position of the bit in its byte
mask = 1  (7 - (bitPos % 8));
// get the bit value applying the mask
bit = (buffer[curOffset]  mask);
// if the bit is on, shift it to its position in curField and 

Re: [Flashcoders] how to uncompress a compressed bytearray with PHP

2008-10-02 Thread Juan Pablo Califano
I see a couple of spots for problems in what you are doing.

When you're compressing the data, you are basically transforming text
strings to binary. I mean, text is binary data, but generally strings cannot
contain NUL characters (that is a 0 value), because that's traditionally
reserved to mark the end of the string. On the other hand, 0 is a perfectly
legal value in a binary context (so to speak) and I think you'll probably
get some 0's in the compressed data (or at least, I'm not sure if you could
be sure you won't, under any circumstance). So, when you're posting data
(except you post as binary), NULs will be a problem, because the data (the
string) will be truncated.

From the php side, I think you should use the gzinflate function, as the
ByteArray class uses inflate / deflate (from zlib). I haven't used it in
php, just found it in the manual:
http://ar.php.net/manual/en/function.gzinflate.php

The signature of the function says it takes a string, so should probably
check what happens if you have embbeded NULs here too... (my guess is that
php will also truncate the data).

You could try to post the data as binary and see if it works, but I'd first
check that the uncompressing is working on the php side. A quick and dirty
idea: you could check this by dumping the compressed ByteArray in the Flash
IDE, for instance, to the trace output, in the form of a php assignment.
I.e, printing something like $data = chr(someNumber) . chr(someOtherNumber)
. chr(someOtherNumber); Then paste that in your php file and try to get the
uncompressed data hardcoding the generated php assignment. If you get that
right, then you know the only remaining problem is passing the data itself
to php in a safe way. Or you could even encode it as base64 (which is used
precisely to avoid the embedded NULs problem); decoding from the php side is
just a matter of calling base64_decode(); from the AS side, you don't have
anything builtin, but there are classes for encoding base64 around (I wrote
one some time ago). Of course, using base64 would add more overhead and will
add to the size of the data you're posting (1/3 of the unencoded size), but
maybe it turns out to be simpler than grabbing the binary data from php.

Cheers
Juan Pablo Califano


2008/10/2, Benny [EMAIL PROTECTED]:

 I am sending a compressed bytearray to PHP:



 var XMLOut:ByteArray = new ByteArray();

 XMLOut.writeUTFBytes(rootitem1just an example/item1/root);

 XMLOut.compress();

 . cut .



 The data is POSTed (with URLLoader in var XMLString) to
 mydomain.com/save.php:



 ?php

 $XMLString = gzuncompress($_POST[XMLString ]);

 $handle = fopen(content/test.xml, w+b);

 fwrite($handle, $ XMLString);

 fclose($handle);

 ?



 The result of this is that test.xml is being created but without any
 content.

 (BTW: If I leave out the compression/decompression part then the file is
 created with the expected content)



 Should this actually work with gzuncompress and if so why might it be
 failing here?

 Or should the uncompressioning be handled differently?





 ___
 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