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