Esempio n. 1
0
/*
 * Write the EXPORTASSET tag with informations gathered by calls to
 * SWFMovie_addExport.
 *
 * Call this function to control insertion of the EXPORTASSET tag, which
 * is otherwise written at the END of the SWF.
 */
void
SWFMovie_writeExports(SWFMovie movie)
{
	int n;
	SWFBlock exports;

	if ( movie->nExports == 0 )
		return;

	for ( n=0; n<movie->nExports; ++n )
	{
		SWFBlock b = movie->exports[n].block;
		b->swfVersion = movie->version;

		if ( SWFBlock_isCharacter(b) && !SWFBlock_isDefined(b) )
		{
			SWFMovie_addCharacterDependencies(movie, (SWFCharacter)b);
			completeSWFBlock(b);
			SWFMovie_addBlock(movie, b);
			/* Workaround for movieclip exports:
			 * initAction and scalingGrid are only written when 
			 * placing the movieclip. These extra blocks should
			 * not get lost if a MC is eported only 
			 */
			if(SWFBlock_getType(b) == SWF_DEFINESPRITE)
			{
				SWFSprite sprite = (SWFSprite)b;
				if(sprite->grid)
					SWFMovie_addBlock(movie, (SWFBlock)sprite->grid);
				if(sprite->initAction)
					SWFMovie_addBlock(movie, (SWFBlock)sprite->initAction);
			}
		}
	}

	exports = (SWFBlock)newSWFExportBlock(movie->exports, movie->nExports);

	SWFMovie_addBlock(movie, exports);

	destroySWFExports(movie);
}
Esempio n. 2
0
File: block.c Progetto: cran/R2SWF
int
writeSWFBlockToMethod(SWFBlock block, SWFByteOutputMethod method, void *data)
{
	SWFBlocktype type = block->type;
	unsigned int length;

	switch(block->type)
	{
	case SWF_UNUSEDBLOCK:
	case SWF_MINGFONT:
		return 0;
	default:
		break;
	}

	if ( !block->completed )
		completeSWFBlock(block);

	length = block->length;

	/* write header */

	if(type == SWF_PREBUILTCLIP)
		type = SWF_DEFINESPRITE;
	if ( type == SWF_PREBUILT )
		;
	else if ( length > 62 ||
			 type == SWF_DEFINELOSSLESS ||
			 type == SWF_DEFINELOSSLESS2 )
	{
		/* yep, a definebitslossless block has to be long form, even if it's
			 under 63 bytes.. */
		method((unsigned char)(((type&0x03)<<6) + 0x3f), data);
		method((unsigned char)((type>>2) & 0xff), data);
		methodWriteUInt32(length, method, data);
		length += 6;
	}