Re: [Flashcoders] External libraries
there's a -mx switch specifically for that, in fact I think it just ignores the mx.* classes so they dont even get compiled. you can also patch your mx.* classes using a patch from osflash.org which is what I do, then I dont need the -mx switch. n.b. I patched a copy of the mx classes, not the originals. My IDE install points to the originals. :) martin Andy Herrman wrote: Hmm...I just tried building using MTASC and I'm getting an error in one of the mx classes. It's choking on mx.utils.Delegate (variables aren't typed). Is there a way to keep MTASC from being too strict on the built in mx classes? -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
Re: [Flashcoders] External libraries
like i said in the other mail, -mx prevents mtasc compiling the mx.* classes so you will want to generate the swf in MMC and then inject the new code when you compile (or patch the mx classes) also, you might like this delegate implementation : http://dynamicflash.com/2005/02/delegate-class-refined/ Andy Herrman wrote: If I add the -mx parameter to MTASC (I'm working through FlashDevelop) it removes the error, but the Delegate class doesn't work anymore (Delegate.create returns undefined). -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
Re: [Flashcoders] External libraries
I tried the -mx flag, but then Delegate just didn't work (Delegate.create() returned undefined). My guess is it didn't compile the mx.* stuff, and for some reason it wasn't included in the SWF. But I can work around that. It's the other 2 problems I need to figure out. -Andy On 1/23/07, Martin Wood-Mitrovski [EMAIL PROTECTED] wrote: like i said in the other mail, -mx prevents mtasc compiling the mx.* classes so you will want to generate the swf in MMC and then inject the new code when you compile (or patch the mx classes) also, you might like this delegate implementation : http://dynamicflash.com/2005/02/delegate-class-refined/ Andy Herrman wrote: If I add the -mx parameter to MTASC (I'm working through FlashDevelop) it removes the error, but the Delegate class doesn't work anymore (Delegate.create returns undefined). -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
Re: [Flashcoders] External libraries
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
Re: [Flashcoders] External libraries
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
Re: [Flashcoders] External libraries
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.fla file 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
Re: [Flashcoders] External libraries
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.fla file 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.
Re: [Flashcoders] External libraries
you cant attach symbols from a loaded swf to a different parent, you *must* attach them somewhere in the tree where their library exists. you have to do uiResources.attachMovie instead of _root.attachMovie its a nasty limitation of flash (pre v9, in v9 you can manipulate the display heirarchy pretty much as you like) Andy Herrman wrote: var img:MovieClip = root.attachMovie(asImage, asImageMC, root.getNextHighestDepth()); ___ 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
Re: [Flashcoders] External libraries
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.fla file 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
Re: [Flashcoders] External libraries
That's what I was afraid of. I want to avoid doing that, as the brand.swf it meant just to be an external library which can be swapped around, though I guess I could have my main.swf build the UI inside the uiResources MC. Kind of ugly though. I'm guessing I could do it with links, but from what I've seen online the link depends on a URL to the brand.swf, which doesn't really work since I want to be able to use different brand.swfs and pick them at runtime (probably as a parameter to the movie). Is there a way to use links without having a fixed URL for the linked SWF? -Andy On 1/22/07, Martin Wood-Mitrovski [EMAIL PROTECTED] wrote: you cant attach symbols from a loaded swf to a different parent, you *must* attach them somewhere in the tree where their library exists. you have to do uiResources.attachMovie instead of _root.attachMovie its a nasty limitation of flash (pre v9, in v9 you can manipulate the display heirarchy pretty much as you like) Andy Herrman wrote: var img:MovieClip = root.attachMovie(asImage, asImageMC, root.getNextHighestDepth()); ___ 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
Re: [Flashcoders] External libraries
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.fla file 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
Re: [Flashcoders] External libraries
Martin, you are my hero. uiResources.attachMovie(...) worked like a charm, and it'll let me dynamically change which brand.swf I use (as opposed to Links which wouldn't). Thanks! -Andy On 1/22/07, Andy Herrman [EMAIL PROTECTED] wrote: That's what I was afraid of. I want to avoid doing that, as the brand.swf it meant just to be an external library which can be swapped around, though I guess I could have my main.swf build the UI inside the uiResources MC. Kind of ugly though. I'm guessing I could do it with links, but from what I've seen online the link depends on a URL to the brand.swf, which doesn't really work since I want to be able to use different brand.swfs and pick them at runtime (probably as a parameter to the movie). Is there a way to use links without having a fixed URL for the linked SWF? -Andy On 1/22/07, Martin Wood-Mitrovski [EMAIL PROTECTED] wrote: you cant attach symbols from a loaded swf to a different parent, you *must* attach them somewhere in the tree where their library exists. you have to do uiResources.attachMovie instead of _root.attachMovie its a nasty limitation of flash (pre v9, in v9 you can manipulate the display heirarchy pretty much as you like) Andy Herrman wrote: var img:MovieClip = root.attachMovie(asImage, asImageMC, root.getNextHighestDepth()); ___ 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
Re: [Flashcoders] External libraries
The main reason I don't want to do that is that I won't have control of the 'brand.swf' versions. I just worry someone might put something on the canvas in brand.swf by mistake. If I was able to put my stuff on root or another MC then I could just hide the uiResources MC, so it wouldn't matter if someone put something on it, but this way I'll have to leave it visible. Then again, I can just document how they're supposed to make the brand.swf and if they screw it up they can deal with fixing it. :) -Andy On 1/22/07, Francis Chary [EMAIL PROTECTED] wrote: 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
RE: [Flashcoders] External libraries
Unfortunately I'm stuck using the Flash IDE only (no MTASC). :( Why can't you use MTASC? Has somebody got a gun to your head and will pull the trigger if you use it? If that's the case, might I suggest bringing a kevlar helmet to work? ;) I highly recommend FLASC http://www.osflash.org/flasc as a great easy way to use MTASC. ___ 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
RE: [Flashcoders] External libraries
Trouble I have with MTASC is I just can't seem to get it to find all my classes properly, and it just silently fails to compile whole chunks of things. I tried to use it in Eclipse with Flashout as ASDT and it seemed like I had to paste in a page and a half of switches to the compiler to tell it where every single class was. I drove myself nuts. I also find the FLASC UI really confusing. Sorry. I tried using MTASC and it basically just drove me nuts. CHUCK HOFFMAN PROGRAMMER T8DESIGN.COM | P 319.266.7574 - x150 | 877.T8IDEAS | F 888.290.4675 This e-mail, including attachments, is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential, and may be legally privileged. If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited. Please reply to the sender that you have received the message in error, and then please delete it. Thank you. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks | BLITZ Sent: Monday, January 22, 2007 12:23 PM To: Flashcoders mailing list Subject: RE: [Flashcoders] External libraries Unfortunately I'm stuck using the Flash IDE only (no MTASC). :( Why can't you use MTASC? Has somebody got a gun to your head and will pull the trigger if you use it? If that's the case, might I suggest bringing a kevlar helmet to work? ;) I highly recommend FLASC http://www.osflash.org/flasc as a great easy way to use MTASC. ___ 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