A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: SWC with embedded assets... having a very BAD time!

  1. #1
    flashguy
    Join Date
    May 2005
    Location
    In the mountains
    Posts
    341

    Unhappy SWC with embedded assets... having a very BAD time!

    I am very puzzled!

    I used to be able to create distributable components in AS2 (swc files) containing class code and assets (movieclips). And it used to be really easy.

    Now I am struggling with Flash CS4 and AS3 and all my attempts were frustrating, as no matter what I try it simply doesn't work. I am starting to suspect that it is not possible anymore to do in AS3? Maybe this kind of thing is deprecated in Flash now???

    Let's see what I have tried:

    1) I started with a new FLA and named it 'MyComponent.FLA'. Then I drawed a green square, converted it to a mc and named it as 'MySquare'. Then I tagged 'Export for ActionScript' and 'Export in Frame 1'. Then I named the class as 'MySquare' and set the base class to 'flash.display.MovieClip'. This is my asset (a green square movieclip).

    2) Created an empty movieclip and dragged the asset within it. Then I named it as 'MyComponent'. Then I tagged 'Export for ActionScript' and 'Export in Frame 1'. Then I named the class as 'MyComponent' and set the base class to 'flash.display.MovieClip'.

    3) Right-clicked it in the library and chose 'Component Definition'. Then in class field I typed 'MyComponent' and tagged 'Display in Components Panel'.

    4) Crated a new AS file, called it 'MyComponent.AS' and typed the following code:

    Code:
    package { 
    
    	import flash.display.MovieClip;
    	public class MyComponent extends MovieClip
    	{ 
    
    		private var _square:MovieClip; 
    
    		public function MyComponent()
    		{
    			_square = new MySquare();
    			addChild(_square);
    		} 
    	}
    }
    5) Back to 'MyComponent.FLA', right-clicked the 'MyComponent' object in the library and chose 'Export SWC file'. That was ok, no warnings, no errors. Then I just copied this new SWC to my components folder.

    6) Created a new FLA and named it 'test.FLA'.

    7) Reloaded the components panel, and my new component showed up. Then I dragged it into library.

    8) Then I type the following code:

    Code:
    	var test:MyComponent = new MyComponent();
    	trace (test.visible)
    9) I ran the new app and it was ok, no errors and no warnings. The trace statement spit out 'true' what means that the new class is really there, but... I cannot see the green square. But when I click onto the 'MyComponent' in the library, the preview shows up the green square, what means that it IS THERE in the component. So, why it doesn't show up in the stage after the class be intantiated?

    What I am doing wrong? Or this kind of thing is not possible to be done with AS3?
    Visit my business at http://www.ballooncreator.com - Software Tool For Party Balloons Online Design!

  2. #2
    Mod cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You did not see my answer to your other thread? You don't export swcs but work with the mxi file.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    flashguy
    Join Date
    May 2005
    Location
    In the mountains
    Posts
    341
    I did (and dropped you an answer there).

    But the problem mentioned in this thread have nothing to do with the problem of the other thread. They are distinct issues.
    Visit my business at http://www.ballooncreator.com - Software Tool For Party Balloons Online Design!

  4. #4
    flashguy
    Join Date
    May 2005
    Location
    In the mountains
    Posts
    341
    So... by the silence in the forum and by the fact that I didn't find any functional example in Google, I am assuming that there is not possible to do that in AS3...

    Bummer! That's a shame that Flash IDE developers have removed such nice feature.

    Anyway, it's time to move to a different approach. Since Flash doesn't accept assets embedded within SWC anymore, I will generate my assets programatically direct from the class! A bit more time comsuming, but that's life.

    Visit my business at http://www.ballooncreator.com - Software Tool For Party Balloons Online Design!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center