Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Urgent - Export movieclip as swf

Participant ,
Dec 26, 2015 Dec 26, 2015

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

TOPICS
ActionScript
902
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 27, 2015 Dec 27, 2015

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 27, 2015 Dec 27, 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");

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 28, 2015 Dec 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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 28, 2015 Dec 28, 2015

Hi Nezarov,


Thanks a lot for your help.


I tried the code you given. As you said Its gives me a particular movieclip as swf. But, it generate only one shape inside that particular mc as static(have multiple shapes in that mc). It ignores the animation inside that mc.


Actual app will work like this.

1. User will select a image from his sys by click on the browse btn and that image will be displayed in a container and will select the fadeIn checkbox

2. User will select a audio from his sys by click on the browse btn and will click add btn to add that audio

3. User will type the text on the container

4. User will click on the generate button and the generated swf should save in his local system

5. The generated swf should contain the image with fadein effect, audio and the text


Is this possible in flash using as3swf or any other code? Please help me.


Thanks,

Rajaguru.V


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 29, 2015 Dec 29, 2015

Hi, Unfortunately you cannot, because the items you're loading cannot be embedded in the main file, and the class you're using to publish .swf file, doesn't work with loaded or external items, it only reads the stage data and the embedded data (library data) + the code.

I've tried to create a preloader to load the ".swf maker" and send variables from the main preloader to the swfMaker.swf, that doesn't work also! the variables works in runtime but when I publish the demo file I get the origin values.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Dec 29, 2015 Dec 29, 2015
LATEST

Oh! thank you very much Nezarov. You helped me lot. I appreciate your effort. If you get any other solution please let me know. Thanks again.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Dec 28, 2015 Dec 28, 2015
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines