Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-19 Thread Gregory N
Thanks, Jan and Glen :-)
Even embedding each symbol separately is great.

Yesterday I've just (mistakenly) supposed to access internal clips by
their names, as we did in AS2...
Obviously it's not possible.
Just out of curiosity:
if we access them via getChildAt() , do you think there's some relation
between clip's position/layer/name/etc in container mc (in Flash 8 IDE)
and the position in child list (idx variable in Glen's code below)?

Glen Pike wrote:

I have managed to access movie clips inside an embedded symbol, but
 purely to manipulate them as movieclips.

To avoid confusion - I have no code inside the SWF file I am
 embedding, I am merely using Flash 8 IDE to author graphical symbols 
 animations which I embed individually.  Some of these clips have nested
 clips too.

Here is an example:

//Embed the symbol Block, which has a number of clips inside it.
[Embed (source = ../resources/graphics.swf, symbol=Block)]
private var Block:Class;

//...

//Create an instance of a Block
_block:MovieClip = new Block() as MovieClip;
//Loop through and stop all the child clips using the child access
 methods of AS3
var children:int = _block.numChildren;
for (var idx:int = 0; idx  children;idx++ ) {
  var child:MovieClip = _block.getChildAt(idx) as MovieClip;
  child.stop();
}



//Later in the code, do collision detection on each child clip in
 the Block and manipulate it as a movieclip.
function hitTestBlock(block:MovieClip, ball:Sprite) {
var children:int = block.numChildren;
for (var idx:int = 0; idx  children;idx++ ) {
  var child:MovieClip = block.getChildAt(idx) as MovieClip;
  if(child.hitTestObject(ball)) {
  child.nextFrame();
  //optimise for speed by removing clips that are dead.
  if(child.totalFrames == child.currentFrame) {
  block.removeChild(child);
  }
  return true;
  }
   }
   return false;
}



HTH

Glen


 Ian Thomas wrote:
  I can just embed one container mc symbol ?


  In short, I don't know - never tried using the container mc idea.
 
  Thinking about it, though, I suspect that you won't be able to access
 the
  subclips via new MySubClipSymbolID(); however, if you instantiate the
  containing clip (new MyTopLevelSymbolID() or whatever) you may be able
 to
  access the children via getChildAt() etc.
 
  That's probably not a hugely useful thing to be able to do, though.
 
  I'm guessing it's most useful to embed each symbol.
 




-- 
-- 
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-18 Thread Ian Thomas
Gregory,
  The trouble with importing/using/loading Flash 8 SWFs into an AS3-powered
app is that Flash 8 uses the old flash runtime engine (AVM1) and your AS3
app uses the new engine (AVM2) and the two don't talk to each other well.

If you directly embed a Flash 8 SWF like so:
  [Embed(source=flash8.swf]
  private var assetClass:Class;

When you create an instance of assetClass using new assetClass(), you are
actually creating an instance of a 'wrapper' class called AVM1Movie, which
isn't a lot of use to you. It's okay if you're just showing a graphic and
don't want to interact with it, but that's about it. Clumsy.

However, you _can_ use symbols from the library of a Flash 8 SWF directly in
an AS3 app and have them translated at compile time.

You embed the symbols (instead of the whole SWF) like so:
  [Embed(source=flash8.swf, symbol=SymbolALinkageID]
  private var symbolAClass:Class;

  [Embed(source=flash8.swf, symbol=SymbolBLinkageID]
  private var symbolBClass:Class;

Now when you create an instance of symbolAClass using new symbolAClass(),
you are actually getting a MovieClip that's completely compatible with Flash
9. If the symbol had any Flash 8 code on it, this will have been stripped by
the compile process and ignored - but if all you're trying to do is load a
bunch of frames of graphics produced with Flash 8 and using them in a Flash
9 movie, it works perfectly.

In short - embed/compile the whole Flash 8 movie, your app thinks it's an
old SWF file and treats it as an AVM1 MovieClip. Embed/compile each symbol
seperately, Flash 9 treats each one as an AVM2 MovieClip.

Hope that's helpful,
   Ian

On Jan 18, 2008 9:55 AM, Gregory N [EMAIL PROTECTED] wrote:

 Thanks again, Glen, your addition is very interesting.


___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-18 Thread Gregory N
Thanks again, Glen, your addition is very interesting.

-- 
-- 
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-18 Thread Merrill, Jason
can this symbol contain enclosed (child) movieclips?

Yes

And can I then access these child clips?

Flash 8?  Flash 8 is AVM1, so no (unless you hack with something like
ExternalInterface, which requires modifying the code in your Flash 8 swf
to call it)



Jason Merrill
Bank of America  
GTO LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community



 
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-18 Thread Glen Pike

Hi,

   I have managed to access movie clips inside an embedded symbol, but 
purely to manipulate them as movieclips. 

   To avoid confusion - I have no code inside the SWF file I am 
embedding, I am merely using Flash 8 IDE to author graphical symbols  
animations which I embed individually.  Some of these clips have nested 
clips too.


   Here is an example:

   //Embed the symbol Block, which has a number of clips inside it.
   [Embed (source = ../resources/graphics.swf, symbol=Block)]
   private var Block:Class;
  
   //...


   //Create an instance of a Block
   _block:MovieClip = new Block() as MovieClip;
   //Loop through and stop all the child clips using the child access 
methods of AS3

   var children:int = _block.numChildren;
   for (var idx:int = 0; idx  children;idx++ ) {
 var child:MovieClip = _block.getChildAt(idx) as MovieClip;
 child.stop();
   }
  

  
   //Later in the code, do collision detection on each child clip in 
the Block and manipulate it as a movieclip.

   function hitTestBlock(block:MovieClip, ball:Sprite) {
   var children:int = block.numChildren;
   for (var idx:int = 0; idx  children;idx++ ) {
 var child:MovieClip = block.getChildAt(idx) as MovieClip;
 if(child.hitTestObject(ball)) {
 child.nextFrame();
 //optimise for speed by removing clips that are dead.
 if(child.totalFrames == child.currentFrame) {
 block.removeChild(child);
 }
 return true;
 }
  }
  return false;
   }
  



   HTH

   Glen
  


Ian Thomas wrote:

On Jan 18, 2008 7:37 PM, Gregory N [EMAIL PROTECTED] wrote:

  

Thanks, Jan.

This leads me to another question. I think I'd try it myself before
asking,
but just have no dev machine at hand right now.
So,
when I embed *symbols* from flash 8 library like this:
   [Embed(source=flash8.swf, symbol=SymbolALinkageID]
   private var symbolAClass:Class;

can this symbol contain enclosed (child) movieclips?
And can I then access these child clips?

In other words, should I create a special class file(s) only to list the
embed-var statements like the one above
OR
I can just embed one container mc symbol ?




In short, I don't know - never tried using the container mc idea.

Thinking about it, though, I suspect that you won't be able to access the
subclips via new MySubClipSymbolID(); however, if you instantiate the
containing clip (new MyTopLevelSymbolID() or whatever) you may be able to
access the children via getChildAt() etc.

That's probably not a hugely useful thing to be able to do, though.

I'm guessing it's most useful to embed each symbol.

HTH,
   Ian


  
___

Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  


--

Glen Pike
01736 759321
www.glenpike.co.uk http://www.glenpike.co.uk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-18 Thread Gregory N
Thanks, Jan.

This leads me to another question. I think I'd try it myself before asking,
but just have no dev machine at hand right now.
So,
when I embed *symbols* from flash 8 library like this:
[Embed(source=flash8.swf, symbol=SymbolALinkageID]
private var symbolAClass:Class;

can this symbol contain enclosed (child) movieclips?
And can I then access these child clips?

In other words, should I create a special class file(s) only to list the
embed-var statements like the one above
OR
I can just embed one container mc symbol ?

Yes, I need only the graphics from these symbols (this is FLA used for prev.
version of the app.


On Jan 18, 2008 1:12 PM, Ian Thomas [EMAIL PROTECTED] wrote:

 However, you _can_ use symbols from the library of a Flash 8 SWF directly
 in
 an AS3 app and have them translated at compile time.

 You embed the symbols (instead of the whole SWF) like so:
  [Embed(source=flash8.swf, symbol=SymbolALinkageID]
  private var symbolAClass:Class;

  [Embed(source=flash8.swf, symbol=SymbolBLinkageID]
  private var symbolBClass:Class;

 Now when you create an instance of symbolAClass using new symbolAClass(),
 you are actually getting a MovieClip that's completely compatible with
 Flash
 9. If the symbol had any Flash 8 code on it, this will have been stripped
 by
 the compile process and ignored - but if all you're trying to do is load a
 bunch of frames of graphics produced with Flash 8 and using them in a
 Flash
 9 movie, it works perfectly.

 In short - embed/compile the whole Flash 8 movie, your app thinks it's an
 old SWF file and treats it as an AVM1 MovieClip. Embed/compile each symbol
 seperately, Flash 9 treats each one as an AVM2 MovieClip.

 Hope that's helpful,
   Ian




-- 
-- 
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-18 Thread Ian Thomas
On Jan 18, 2008 7:54 PM, Merrill, Jason [EMAIL PROTECTED]
wrote:

 can this symbol contain enclosed (child) movieclips?

 Yes

 And can I then access these child clips?

 Flash 8?  Flash 8 is AVM1, so no (unless you hack with something like
 ExternalInterface, which requires modifying the code in your Flash 8 swf
 to call it)


Hi Jason,
   What I was basically saying (earlier in the conversation) is that if you
use:

[Embed(source=clips.swf, symbol=someSymbol)]

instead of

[Embed(source=clips.swf)]

on a Flash 8 SWF, then actually the symbol is _translated_ into AVM2 by the
compiler, but all the code is stripped out.
So it is no longer AVM1.

If you just embed the Flash 8 SWF itself (without using 'symbol=') then the
Flash 8 SWF is created as AVM1Movie, and has the problems you mention.

Cheers,
   Ian
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-16 Thread Gregory N
Thanks a lot to all who replied, and especially to Glen.
This article at bit-101.com is great!

Among other things, I'm trying to find new way to collaborate with
designers who create graphics in Flash IDE (8 or 9).
And so far it seems I've found it.


-- 
-- 
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-16 Thread Glen Pike

It's really nice once you get to grips with stuff.

Things to remember:

When you create an instance of an asset, you should cast it when you 
create it - I had all sorts of problems and was having to create my 
assets as children of Sprites until I discovered this:


var myMC:MovieClip = new ImportedMCAsset() as MovieClip;

You can import sounds, but I have not managed to embed sounds in a 
MovieClip and get it working, there was something somewhere which 
mentioned trying to cast the MC as a SoundAsset, but this is how I got 
it working:


[Embed (source = ../resources/sounds/bomb.mp3)]
private var SndBomb:Class;

var bomb:SoundAsset = new SndBomb() as SoundAsset;

You can also embed fonts from the system:

[Embed(systemFont=Tahoma, fontName='TextFont',  fontWeight='bold', 
unicodeRange='U+002C-U+005A', mimeType='application/x-font') ]

private var AnotherClass:Class;

Or from a library:

[Embed(source=../library/tahomabd.ttf, fontName='myFont', 
fontWeight='bold', unicodeRange='U+002A-U+002A', 
mimeType='application/x-font') ]

private var AssetClass:Class;

And use it like this - even if you embed the font in the main class and 
access it in a child clip (not sure if this works for other clips):


var label:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = TextFont;
format.bold = true;
format.color = 0xFF;
label.htmlText = Embedded fonts;
label.embedFonts = true;
label.setTextFormat(format);
addChild(label);

HTH

Glen


Gregory N wrote:

Thanks a lot to all who replied, and especially to Glen.
This article at bit-101.com is great!

Among other things, I'm trying to find new way to collaborate with
designers who create graphics in Flash IDE (8 or 9).
And so far it seems I've found it.


  


--

Glen Pike
01736 759321
www.glenpike.co.uk http://www.glenpike.co.uk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


[Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-15 Thread Gregory N
Hi all,

I have an application made a while ago in as1 (flash 6).

Now I need to make new version of it in AS3.
Fortunately, there's no code in clips, only in frame 1 on _root :-).
But all graphics currently is in FLA.
And I haven't upgraded to Flash CS3 yet (hope not to do it at all).

I've seen this article:
http://www.adobe.com/devnet/flash/articles/flex2_flash.html

But it mentions Flex Builder 2, not SDK.

Question:
Can I (if yes, how) use graphics from flash 8 with flex 2 sdk?

I can think of loading graphics-only swfs (as2) into final (AS3) swf...
But doubt that I'll be able to access their assets (not code, just mc's).


-- 
-- 
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-15 Thread Leandro Ferreira
I don't get it: why don't you use flash CS3?


   Leandro Ferreira

On Jan 15, 2008 12:15 PM, Gregory N [EMAIL PROTECTED] wrote:

 Hi all,

 I have an application made a while ago in as1 (flash 6).

 Now I need to make new version of it in AS3.
 Fortunately, there's no code in clips, only in frame 1 on _root :-).
 But all graphics currently is in FLA.
 And I haven't upgraded to Flash CS3 yet (hope not to do it at all).

 I've seen this article:
 http://www.adobe.com/devnet/flash/articles/flex2_flash.html

 But it mentions Flex Builder 2, not SDK.

 Question:
 Can I (if yes, how) use graphics from flash 8 with flex 2 sdk?

 I can think of loading graphics-only swfs (as2) into final (AS3) swf...
 But doubt that I'll be able to access their assets (not code, just mc's).


 --
 --
 Best regards,
 GregoryN
 
 http://GOusable.com
 Flash components development.
 Usability services.
 ___
 Flashcoders mailing list
 Flashcoders@chattyfig.figleaf.com
 http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-15 Thread Glen Pike
Possibly because CS3 is expensive  a memory hog and maybe unnecessary 
if you are heavily into coding - FL8 is just as handy  Flex has a 
different set of components :)


Leandro Ferreira wrote:

I don't get it: why don't you use flash CS3?


   Leandro Ferreira

On Jan 15, 2008 12:15 PM, Gregory N [EMAIL PROTECTED] wrote:

  

Hi all,

I have an application made a while ago in as1 (flash 6).

Now I need to make new version of it in AS3.
Fortunately, there's no code in clips, only in frame 1 on _root :-).
But all graphics currently is in FLA.
And I haven't upgraded to Flash CS3 yet (hope not to do it at all).

I've seen this article:
http://www.adobe.com/devnet/flash/articles/flex2_flash.html

But it mentions Flex Builder 2, not SDK.

Question:
Can I (if yes, how) use graphics from flash 8 with flex 2 sdk?

I can think of loading graphics-only swfs (as2) into final (AS3) swf...
But doubt that I'll be able to access their assets (not code, just mc's).


--
--
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders



___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


  


--

Glen Pike
01736 759321
www.glenpike.co.uk http://www.glenpike.co.uk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


Re: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-15 Thread Glen Pike

Hi,

   You can embed assets from Flash into Flex using the [Embed] meta 
directive.
  
   In Flash all the MovieClips in your library need to have a LinkageID 
- not sure if they need to be on the timeline, but probably a good idea.


   In Flex you can [Embed] individual MC's or an entire SWF at compile 
time (assets will expand the SWF file).


   You need to put the [Embed

   Keith Peters has a good example of the code needed here:

   http://www.bit-101.com/blog/?p=853

   Not 100% how this translates to MXML or if that is possible.

   Also not sure about runtime shared libraries, but try googling with 
flex too.
  
   HTH


   Glen

  


Gregory N wrote:

Hi all,

I have an application made a while ago in as1 (flash 6).

Now I need to make new version of it in AS3.
Fortunately, there's no code in clips, only in frame 1 on _root :-).
But all graphics currently is in FLA.
And I haven't upgraded to Flash CS3 yet (hope not to do it at all).

I've seen this article:
http://www.adobe.com/devnet/flash/articles/flex2_flash.html

But it mentions Flex Builder 2, not SDK.

Question:
Can I (if yes, how) use graphics from flash 8 with flex 2 sdk?

I can think of loading graphics-only swfs (as2) into final (AS3) swf...
But doubt that I'll be able to access their assets (not code, just mc's).


  


--

Glen Pike
01736 759321
www.glenpike.co.uk http://www.glenpike.co.uk
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


RE: [Flashcoders] using graphics from flash 8 with flex 2 sdk

2008-01-15 Thread Merrill, Jason
Yes, you can load Flash 8 made .swfs into Flex, you just can't directly
interact with any code inside of them except by using External Interface
or perhaps local connection.

Jason Merrill
Bank of America  
GTO LLD Solutions Design  Development 
eTools  Multimedia 

Bank of America Flash Platform Developer Community



 

-Original Message-
From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf 
Of Gregory N
Sent: Tuesday, January 15, 2008 9:15 AM
To: flashcoders@chattyfig.figleaf.com
Subject: [Flashcoders] using graphics from flash 8 with flex 2 sdk

Hi all,

I have an application made a while ago in as1 (flash 6).

Now I need to make new version of it in AS3.
Fortunately, there's no code in clips, only in frame 1 on _root :-).
But all graphics currently is in FLA.
And I haven't upgraded to Flash CS3 yet (hope not to do it at all).

I've seen this article:
http://www.adobe.com/devnet/flash/articles/flex2_flash.html

But it mentions Flex Builder 2, not SDK.

Question:
Can I (if yes, how) use graphics from flash 8 with flex 2 sdk?

I can think of loading graphics-only swfs (as2) into final 
(AS3) swf...
But doubt that I'll be able to access their assets (not code, 
just mc's).


--
--
Best regards,
GregoryN

http://GOusable.com
Flash components development.
Usability services.
___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

___
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders