Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
577 views
in Technique[技术] by (71.8m points)

actionscript 3 - When a SWF is loaded into another. Can the main SWF read the loaded one to retrieve its contents and modify them?

Give this scenario:

  • I have a cool graphic in Illustrator or Flash.
  • The graphic represents a figure, with various elements inside, shapes, lines, gradients, etc.
  • I export it to a swf file and I can view my nice graphic if I open it.
  • I have a (pure) as3 application, which loads swfs.

Then...

  • Can I manipulate the contents of the loaded swf. For example: Moving its contents, changing some elements inside, duplicating them. Deforming them with the transform matrix and things like that?
  • Can I, at least, read the contents and replicate them (the graphic data) inside the main application.

As far as I've been researching, I can only import the swf and use it as a whole display object, without any children, and I cannot modify it.

I want to, somehow, use the graphic information of the external swf to allow the main application deform it or use it to make new versions of the graphic.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No, sadly you can't retrieve or change compiled Graphics elements in detail, you can only use them as DisplayObjects and transform them through their public properties (scale, rotation, transform, etc...). There is way of programmaticaly retrieve a single path coordinates by setting it as the "guide" of an object in the Flash IDE and within an onEnterFrame retrieve the object's position, but as you can imagine, its quite dirty.

You can replicate the clips by either setting them as classes within the loaded SWF (In Flash IDE: library>symbol>properties>export for AS) or using BitmapData to draw them as you please from the main movie.

Another solution would be to use a more open format, like SVG or FXG, but it can get quite complicated...


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...