Skip to main content
Inspiring
December 27, 2015
Question

Urgent - Export movieclip as swf

  • December 27, 2015
  • 1 reply
  • 985 views

Hi All,

I need a help from you. Im creating a application in flash. That application will have some objects (Ex: box, circle etc..) in the right side of the stage and the user can drag and drop them on the dedicated place (Movieclip) and they can get the output as swf in their desktop by clicking a btn. Is this possible in flash actionscript 3.0 or AIR or any other plug-ins?

I tried this --> "AS3SWF" class from claus/as3swf · GitHub‌, but its gives the output of full stage. But I need only particular movieclip on the stage should become a swf (with animation if has).

Please suggest me.

(Sorry I don't know flex).

Thanks,

Rajaguru.V

This topic has been closed for replies.

1 reply

Inspiring
December 27, 2015

Can you show the functions you're using to read, write and export the stage contents?

RajaguruVAuthor
Inspiring
December 28, 2015

Hi Nezarov,

Thanks for your reply. The below code was I tried.

import com.codeazur.as3swf.SWF;

  
var swf:SWF = new SWF(mySwfMc.loaderInfo.bytes); (I placed my MC name here. I don't load any external swf. I tried without loader info also.)

  
var ba:ByteArray = new ByteArray();
  swf
.publish(ba);

  
var C:ByteArray = new ByteArray();
  C
.position = 0;
  C
.writeBytes(ba);
  
var f:FileReference = new FileReference  ;

  f
.save(C,"demo.swf");

Inspiring
December 28, 2015

I've tried to publish a single movieClip and that works but there's a problem that some value "const SHAPE_CHARACTER_ID:uint = 1;" I couldn't understand what it is or how it works! you've to write it manually like: 1, 3, 5.. to select the object that you want to publish it..

import com.codeazur.as3swf.SWF;

import com.codeazur.as3swf.SWFData;

import com.codeazur.as3swf.tags.TagDefineShape;

import com.codeazur.as3swf.tags.TagFileAttributes;

import com.codeazur.as3swf.tags.TagFrameLabel;

import com.codeazur.as3swf.tags.TagPlaceObject;

import com.codeazur.as3swf.data.SWFMatrix;

import com.codeazur.as3swf.tags.TagShowFrame;

import com.codeazur.as3swf.tags.TagEnd;

var my_mc1:MovieClip = new mc1();

addChild(my_mc1);

var my_mc2:MovieClip = new mc2();

my_mc2.x = 150;

addChild(my_mc2);

var my_mc3:MovieClip = new mc3();

my_mc3.x = 250;

addChild(my_mc3);

// to publish the first mc "my_mc1" use 1, "my_mc2" use 3, "my_mc3" use 5:

generateSWF(3, "demo.swf");

function generateSWF(SHAPE_CHARACTER_ID:uint, fileName:String)

{

     var swf: SWF = new SWF(loaderInfo.bytes);

     var shape: TagDefineShape = swf.getCharacter(SHAPE_CHARACTER_ID) as TagDefineShape;

     var swfTemp: SWF = new SWF();

     swfTemp.tags.push(shape);

// This tells the Flash Player to actually place the shape on the display list

     var placeObject: TagPlaceObject = new TagPlaceObject();

    placeObject.characterId = SHAPE_CHARACTER_ID;

    placeObject.depth = 1;

    placeObject.matrix = new SWFMatrix();

    placeObject.hasCharacter = true;

    placeObject.hasMatrix = true;

     swfTemp.tags.push(placeObject);

     swfTemp.tags.push(new TagShowFrame());

     swfTemp.tags.push(new TagEnd());

 

     var ba: ByteArray = new ByteArray();

    swfTemp.publish(ba);

     var f:FileReference = new FileReference;

    f.save(ba, fileName);

};

Source:

https://github.com/claus/as3swf/blob/master/examples/flexmania/CreateSWF.as

Take a look at this link:

http://wonderfl.net/c/6cGM