Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symbol question #14

Closed
cy-zhang-yekai opened this issue Jun 3, 2013 · 10 comments
Closed

symbol question #14

cy-zhang-yekai opened this issue Jun 3, 2013 · 10 comments

Comments

@cy-zhang-yekai
Copy link

"I assume that you want to create new instance of symbol in library by specifying symbol's name in runtime. Is this correct understanding?"

yes.would you tell me how to do that.If possible,I need a simple example...
thank you so much...

@HiroyukiHaga
Copy link
Contributor

Yes.
LWF allows you to instantiate symbols in library during runtime with Movie.AttachMovie() method.

Overview

// instantiate symbol named "symbol_linkage_name".
// New instance's name is "name_of_new_instance", and the instance is attached to rootMovie.

lwf.rootMovie.AttachMovie("symbol_linkage_name", "name_of_new_instance");

Steps

  1. Open your.fla file.
  2. In Library tab, make sure that your symbol's "AS Linkage" has proper name like "symbol_linkage_name".
  3. Publish it to swf file.
  4. Convert from swf to lwf file.
  5. Open "your_swf_file_name.linkages" text file in .lwfdata folder. The *.linkage text file will contains linkage name that specified in step 2 like "symbol_linkage_name : 0".
    1. If not, the linkage name is not published properly. Go to step 2
  6. It's ready to instantiate it call following after lwf's initialization. The "symbol_linkage_name" would be added to the stage.
lwf.rootMovie.AttachMovie("symbol_linkage_name", "name_of_new_instance");

@cy-zhang-yekai
Copy link
Author

thank you very much..i'll try it.

@cy-zhang-yekai
Copy link
Author

tried four times,and not success。
i want to do it in unity.so...can you tell me in details of process.

@HiroyukiHaga
Copy link
Contributor

O.K. I've uploaded full-set example to demonstrate create symbol from library.

Source

Build

This example will solve your issue.
If you have any questions on this example, please let me know,

@cy-zhang-yekai
Copy link
Author

thank you ,the example is worked but in my case ,png is been texture atlas,it not display.....What shall i do?

@HiroyukiHaga
Copy link
Contributor

O.K. I'd like to take a look it. Please wait a moment.

@cy-zhang-yekai
Copy link
Author

ok.thx!

@HiroyukiHaga
Copy link
Contributor

Here we go:)

Source

Build

Step to publish

  1. Open sprite_atlas.fla.
  2. Publish with Commands/LWF_Publish. bitmaps are expoerted to sprite_atlas.bitmap folder.
  3. Create texture sheet with Texture Packer like /Applications/TexturePacker.app/Contents/MacOS/TexturePacker --opt RGBA4444 --scale 1.0 --format json --data sprite_atlas.json --sheet "sprite_atlas_texture.png" sprite_atlas.bitmap/*
  4. Convert swf to lwf with texture sheet information like : swf2lwf sprite_atlas.swf sprite_atlas.json
  5. Open Unity project, and import these
  6. Call lwf.rootMovie.AttachMovie("lightening").

@cy-zhang-yekai
Copy link
Author

thank you so much!it worked...and more question. Is there anyway to change the lwf animation by symbol name?
For example,i need symbol name "wait" work 3 seconds for loop,More than 3 seconds change to symbol "attack" and not want loop, just one time.

@HiroyukiHaga
Copy link
Contributor

I'm happy to hear that this issue has been resolved.
Can you please create another issue for symbol question?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants