Yeah, I just replicated your setup, and I get the same error. I actually
didn't know about the _root limitation of attachMovie, so cheers Martin, I
learned something today.

As he pointed out, your code works nicely when you do

root.uiResources.attachMovie....

but you've said that you don't want to do that. May I ask; is it really so
ugly? I mean, you have a movieclip that sits on the root, and everything is
built within that. It doesn't really add too much to your filesize, and it
makes the whole thing skinnable, doesn't it?

I'm honestly not too sure about doing it with links. I prefer to have the
linkage ids, usually.

On 1/22/07, Andy Herrman <[EMAIL PROTECTED]> wrote:

There is code in the first frame of main.swf:

stop();
Stage.scaleMode = "noScale";
BrandTest.main(this);

So "root" in the BrandTest movie is the same as "_root".  I just don't
like using the "_root" variable.  Global vars make me feel dirty
(unless they're singletons accessed with getInstance() methods). :)

I had other test stuff in place to verify that brand.swf actually
loaded (I added a couple vars and test functions to brand.swf and
tried calling them), but I took them out when posting my code to
shorten it.

   -Andy

On 1/22/07, Francis Chary <[EMAIL PROTECTED]> wrote:
> Ok, that code all looks good, but I have a couple of questions. In
initUI()
> function, what do you get if you also put in:
>
> trace(root);
>
> I only ask, because it looks like the brand.swf is loading in correctly.
> What I'm curious about is, what's going on with the 'root' mc? I notice
that
> in your main method, you're sending in the rootMC movieclip. Can I see
what
> the call to that looks like?
>
> I don't think you need to concern yourself with runtime sharing at this
> stage, really.
>
> Ok, try what Martin said ;-)
>
> Francis
>
> On 1/22/07, Andy Herrman < [EMAIL PROTECTED]> wrote:
> >
> > That's actually exactly what I'm trying, yet it doesn't seem to be
> > working.  Here's my code:
> >
> > ------
> >
> > import mx.utils.Delegate;
> >
> > class BrandTest {
> >
> >   private var root:MovieClip;
> >   private var uiResources:MovieClip = null;;
> >
> >   public static function main(rootMC:MovieClip):Void {
> >     new BrandTest(rootMC);
> >   }
> >
> >   function BrandTest(rootMC:MovieClip) {
> >     this.root = rootMC;
> >     loadUIResources("brand.swf");
> >   }
> >
> >   private function loadUIResources(path:String):Void {
> >     trace("Loading " + path);
> >     if(uiResources != null) {
> >       uiResources.removeMovieClip();
> >     }
> >     root.createEmptyMovieClip("uiResources", root.getNextHighestDepth
());
> >     uiResources = root['uiResources'];
> >
> >     var uiLoader:MovieClipLoader = new MovieClipLoader();
> >
> >     var loadListener:Object = new Object();
> >     loadListener.onLoadInit = Delegate.create(this, function
> > (oEvent:Object) { this.initUI(); });
> >     loadListener.onLoadProgress = Delegate.create(this, function
> > (target:Object, loaded:Number, total:Number):Void { trace(loaded + "/"
> > + total); });
> >
> >     uiLoader.addListener(loadListener);
> >     uiLoader.loadClip (path, uiResources);
> >   }
> >
> >   private function initUI():Void {
> >     trace("Initing UI");
> >     var img:MovieClip = root.attachMovie("asImage", "asImageMC",
> > root.getNextHighestDepth ());
> >     trace(img);
> >   }
> > }
> >
> > ------
> >
> > I get the following output when I run:
> >
> > Loading brand.swf
> > 8860/8860
> > Initing UI
> > undefined
> >
> > attachMovie doesn't seem to be working.  I have the movie clip in
> > Brand.swf exported as 'asImage' with 'Export for ActionScript" and
> > "Export in first frame" selected.  Is there anything else I might be
> > missing?
> >
> > There's an "Export for runtime sharing" option that's unchecked, but
> > if I select it it wants a URL and I don't know what to put there.
> >
> >    -Andy
> >
> > On 1/22/07, Francis Chary <[EMAIL PROTECTED]> wrote:
> > > Let me have a crack at this one, Andy.. ;)
> > >
> > > Basically, linkages are just a way of telling the code how to
identify a
> > > particular item in the library. When you right-click one of your
buttons
> > in
> > > the Brand.fla library and click 'Linkage...', you'll see the Linkage
> > dialog
> > > box. Now, click on the checkbox marked: 'Export for Actionscript'.
> > >
> > > Flash will automatically fill in the linkage Id for you, it usually
just
> > > takes the name of your swf. (eg. "fancy_button"). You can change
this to
> >
> > > whatever you want, just try and make sure that each movie clip has a
> > > different id from the others. Otherwise you could create problems.
Now,
> > go
> > > ahead and publish that movie to create Brand.swf.
> > >
> > > So now you have a movieclip with a linkage id inside your Brand.swf.
So
> > how
> > > do you get it to appear in the Main.swf? Firstly, you'll have to
load
> > the
> > > Brand.swf into the Main.swf. This is most easily done with the
loadMovie
> >
> > > function. If you want to be fancy, you can use MovieClipLoader
instead,
> > but
> > > that's another topic.
> > >
> > > Once you've loaded Brand.swf into Main.swf, you want to get at the
> > button,
> > > or whatever mc you created a linkage id for. Happily, by creating a
> > linkage
> > > id, you gave the flash player a name by which to identify the
button.
> > Now,
> > > the code to attach this to the stage is:
> > >
> > > _root.attachMovie("linkageId", "newButtonMCName", 0);
> > >
> > > as you may have guessed, the arguments there are as follows:
> > > "linkageId" == the linkage id that was generated in the Brand.flafile
> > > "newButtonMCName" == the name you want for your button on the stage
> > > 0 == the depth of the new button.
> > >
> > > This will drop the movieclip onto the stage at coordinates 0, 0.
> > >
> > > So that's how you use linkage id. The neat thing is that if you have
> > say,
> > > five Brand.fla files, with different art assets, you can give the
> > elements
> > > in each one the same linkage id, then compile Main.fla once for each
> > > Brand.swf you've got. That way, you can 'skin' your Main.swf.
> > >
> > > I hope this helps, and I hope someone will correct me if I've made
any
> > silly
> > > mistakes!
> > >
> > > - Francis
> > >
> > > On 1/22/07, Andy Herrman < [EMAIL PROTECTED]> wrote:
> > > >
> > > > Unfortunately I'm stuck using the Flash IDE only (no MTASC). :(
> > > >
> > > > I don't really understand how linkages work.  Is there a way to do
> > > > something similar using just the Flash IDE?  I have a feeling
that's
> > > > the way I'm going to have to do it.
> > > >
> > > >    -Andy
> > > >
> > > > On 1/22/07, Trevor Burton < [EMAIL PROTECTED]> wrote:
> > > > > ok, i work on a setup that sounds like it's what you're aiming
> > for...
> > > > i've
> > > > > recently started working with MTASC and swfmill in order to get
file
> >
> > > > sizes
> > > > > down to a minimum and streamline the build process - what i do
at
> > the
> > > > moment
> > > > > is this (simplified)
> > > > >
> > > > > 1 - all code is compiled into a library using mtasc
> > > > > 2 - all assets are compiled into 'skin' swf using the flash ide
> > > > >
> > > > > 3 - for each skin swf i use swfmill to create a linkage between
an
> > empty
> > > > > movieclip in the skin's library and a base class for the UI
> > component
> > > > i'll
> > > > > want to use. This means that when the skin is compiled in the
flash
> > ide
> > > > it
> > > > > doesn't automatically drag in all the other classes that are
> > referenced
> > > > and
> > > > > i don't have to create exclude.xml files.
> > > > >
> > > > > 4 - i have a 'core' class which loads all the necessary library
and
> > skin
> > > > > files and instantiates things where necessary to get the app
going.
> > > > >
> > > > > This is probably a little bit over the top for what you're
> > describing
> > > > above
> > > > > but for a large-scale application such as this it works very
well
> > and
> > > > > prevents unnecessary duplicate importing of classes.
> > > > >
> > > > > I went down the same path trying to get attachMovie to work
using
> > all
> > > > sorts
> > > > > of approaches and had no luck - this seems to me to be the
cleanest
> > > > approach
> > > > > for what i need.
> > > > >
> > > > > t
> > > > >
> > > > > On 1/22/07, Andy Herrman <[EMAIL PROTECTED]> wrote:
> > > > > >
> > > > > > I'm beginning work on a new project that will need to have a
> > brandable
> > > > > > UI and I'm looking for suggestions on how to proceed.  I'm
pretty
> > new
> > > > > > to Flash development, so I don't really know if there's a
standard
> > way
> > > > > > of doing this.
> > > > > >
> > > > > > What I would like to do is have the main application's SWF
load a
> > > > > > second SWF which contains all of the UI components (images,
> > > > > > animations, buttons, etc).  This way I could allow branding by
> > just
> > > > > > providing an SWF with different UI components.  However, I
can't
> > > > > > figure out if there's a way to access the library of one SWF
in
> > > > > > another SWF.
> > > > > >
> > > > > > For example, I have my main.swf and brand.swf.   Main.swf has
> > nothing
> > > > > > except some AS code.  Brand.swf has a button in its library
called
> > > > > > "testButton", which is exported for AS use.
> > > > > >
> > > > > > What I want to do is create an instance of "testButton" within
> > > > > > Main.swf, but attachMovie doesn't work (I'm guessing it can't
see
> > > > > > library items from the other SWF).  Is there a way to do
> > attachMovie
> > > > > > on clips in another SWF's library?
> > > > > >
> > > > > > The other option I've heard about is to have the default
> > "branding"
> > > > > > stuff defined in the main.swf, and then you can somehow have
an
> > > > > > external SWF override the ones you want to override.  I'm not
sure
> > I
> > > > > > like doing this as it require things to be defined in the main
> > SWF's
> > > > > > FLA, which I like to keep to a minimum (since the FLA is
binary
> > it's
> > > > > > hard to manage it in source control for things like merging,
so
> > I'd
> > > > > > like to have as little in the FLA as possible).
> > > > > >
> > > > > > Is there any way to do what I'm trying (use clips in another
SWF's
> > > > > > library), or any other ways to do branding like this?  Thanks!
> > > > > >
> > > > > >    -Andy
> > > > > > _______________________________________________
> > > > > > Flashcoders@chattyfig.figleaf.com
> > > > > > To change your subscription options or search the archive:
> > > > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > > > >
> > > > > > Brought to you by Fig Leaf Software
> > > > > > Premier Authorized Adobe Consulting and Training
> > > > > > http://www.figleaf.com
> > > > > > http://training.figleaf.com
> > > > > >
> > > > > _______________________________________________
> > > > > Flashcoders@chattyfig.figleaf.com
> > > > > To change your subscription options or search the archive:
> > > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > > >
> > > > > Brought to you by Fig Leaf Software
> > > > > Premier Authorized Adobe Consulting and Training
> > > > > http://www.figleaf.com
> > > > > http://training.figleaf.com
> > > > >
> > > > _______________________________________________
> > > > Flashcoders@chattyfig.figleaf.com
> > > > To change your subscription options or search the archive:
> > > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > > >
> > > > Brought to you by Fig Leaf Software
> > > > Premier Authorized Adobe Consulting and Training
> > > > http://www.figleaf.com
> > > > http://training.figleaf.com
> > > >
> > > _______________________________________________
> > > Flashcoders@chattyfig.figleaf.com
> > > To change your subscription options or search the archive:
> > > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> > >
> > > Brought to you by Fig Leaf Software
> > > Premier Authorized Adobe Consulting and Training
> > > http://www.figleaf.com
> > > http://training.figleaf.com
> > >
> > _______________________________________________
> > Flashcoders@chattyfig.figleaf.com
> > To change your subscription options or search the archive:
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
> > Brought to you by Fig Leaf Software
> > Premier Authorized Adobe Consulting and Training
> > http://www.figleaf.com
> > http://training.figleaf.com
> >
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to