problem with addLazy() call and URL format
Home › Forums › AssetLoader › General Discussion › problem with addLazy() call and URL format
Tagged: css loading
This topic has 2 voices, contains 15 replies, and was last updated by Stephen Adams 249 days ago.
| Author | Posts |
|---|---|
| Author | Posts |
| September 8, 2011 at 1:03 pm #737 Quote | |
|
Stephen Adams |
<p>Hi,</p>
<p>I’ve been following the AssetLoader example on the doesFlash site (http://doesflash.com/2011/07/global-css-robotlegs-trick/). </p> <p>I’m using this to load a css file stored on a local folder, but the issue I’m getting is in my TextFieldMediator, the stylesheet is not being injected so I get a:</p> <p> Quote:
Error:Injector is missing a rule to handle injection into target [object TextFieldMediator]. Target dependency: flash.text.stylesheet
</p> Code:
[Inject]<br />
public var assetLoader:IAssetLoader</p> <p> override public function execute():void<br /> {<br /> var styleSheetURL:String = this.contextView.loaderInfo.parameters.stylesheetURL;<br /> trace( styleSheetURL );<br /> assetLoader.addLazy(IDs.CONFIG_FILE, styleSheetURL);</p> <p> dispatch(new LoadCompleteEvent(LoadCompleteEvent.LOAD_COMPLETED));<br /> assetLoader.start();</p> <p> } </p> Code:
<br />
[Inject]<br /> public var assetLoader:IAssetLoader;</p> <p> override public function execute():void<br /> {<br /> injector.mapValue(StyleSheet, assetLoader.getAsset(IDs.GLOBAL_CSS));</p> <p> dispatch(new ContextEvent(ContextEvent.STARTUP_COMPLETE));<br /> } </p> Code:
[Inject]<br />
public var style:StyleSheet;</p> <p> override public function onRegister():void<br /> {<br /> this.view.styleSheet = style;<br /> this.view.antiAliasType = AntiAliasType.ADVANCED;<br /> } </p> |
| September 8, 2011 at 1:20 pm #852 | |
|
Matan Uberstein |
Hi Stephen, It would seem that the 1 isn’t firing. Why are you firing 1 directly after adding the asset to your 1, which is directly before calling 1. There is no what the style sheet can be loaded if you reacting on 1 event as your sequence is out. You need wait until the css is loaded. As you know AssetLoader works with Signals so add the following: This will cause the 1 to fire once all the assets of the 1 are loaded. You can break it down further and only map the 1 to fire once certain assets have been complete (which should be the case it most scenarios). So try adding in a trace statement into your PreloadCompleteCommand and see if it fires. Thanks for posting and let me know if managed to get it right. |
| September 8, 2011 at 1:27 pm #853 | |
|
Matan Uberstein |
A bonus pointer: When accessing FlashVars you need reference the Stage object, in your case it will work as in most Robotlegs projects the 1 is the stage as well, but this might not always be the case. So for good practice in mind and to avoid future error/head scratching always refer to 1. Also check out: Strongly Typed FlashVars and Robotlegs[/url] Hope that helps! |
| September 9, 2011 at 10:45 am #854 | |
|
Stephen Adams |
Hi, Thanks for the two replys, I will check out that post on FlashVars. I’ve found out what the problem was. I wasn’t extending SignalsCommand for the startup command, so the call to the PreLoadCompleteCommand wasn’t called when the assetLoader.onComplete was called. Also my mediator mapping in the context for the TextField Mediator I did not set injectAsView as null and set autoCreate as false. Which I have done now. This works now, the problem I do have now when I run the app I get a: ‘injector is not defined’ for my Context which does extend SignalContext, i think the injector is where the AssetLoader is being injected: injector.mapSingletonOf(IAssetLoader, AssetLoader); I might trying using just the base Context instead of extending SignalsContext. Tried that and it didn’t work as ISignalCommandMap is not being injected into my StartupCommand. So do need SignalsContext. Any ideas? Stephen |
| September 9, 2011 at 11:35 am #855 | |
|
Matan Uberstein |
Hi, It’s weird that your injector is not defined… :-/ Maybe you should zip your project source files and attach it here on the thread. It will be easier for me to help you. If you don’t want to attach your source, try downloading the sample app again and look at both your code and mine side by side. It sounds like something is missing. Thanks! |
| September 9, 2011 at 1:32 pm #856 | |
|
Stephen Adams |
OK, I’ve zipped it up, and attached it. Let me know what you see, I’ve looked and can’t see what the difference is. Thanks Stephen |
| September 9, 2011 at 1:38 pm #857 | |
|
Matan Uberstein |
I can’t see the attachment, did you click upload? |
| September 9, 2011 at 1:58 pm #858 | |
|
Stephen Adams |
Lets try again |
| September 9, 2011 at 2:00 pm #859 | |
|
Stephen Adams |
Ah get a ‘denied extension’ error. |
| September 9, 2011 at 3:21 pm #860 | |
|
Stephen Adams |
Hi, Looking through the code, I’ve noticed that in the example code I’m using AssetLoader-v2.5.0.swc, while in the example you’re using AssetLoader-v2.4.1.swc, and you’re not including signals-extension-SignalsCommandMap.swc, which I am in order to get the signals to work in the StartupCommand. I was wondering if there is a difference between AssetLoader v2.5.0 and v2.4.1 which could be causing the problem? Stephen |
| September 9, 2011 at 3:25 pm #861 | |
|
Matan Uberstein |
It should not make a difference which AssetLoader you use. I would recommend using the latest one though. Also, try doing the upload again. I think I fixed it. Thanks! |
| September 9, 2011 at 3:43 pm #862 | |
|
Stephen Adams |
OK, here we go |
| September 9, 2011 at 3:45 pm #863 | |
|
Stephen Adams |
Nope, got a [denied mime] error now. |
| September 9, 2011 at 3:47 pm #864 | |
|
Matan Uberstein |
LAME, ok, mail me the file, then I’ll attach it. Don’t really want try and fix this problem on the forum now. |
| September 9, 2011 at 4:35 pm #865 | |
|
Matan Uberstein |
Ok, I can see a few things that are incorrect. The first few things are general/Robotlegs “best practices”. 1. Follow the standard packaging structures and class placements. src [Root source path] 2. Don’t use the “this” statement unless you have to. You code will me much cleaner. 3. Your html template uses an absolute path to your CSS file. I think this is a good time to implement this[/url]. Implement a default relative path using unix style pathing. Ok getting to your code. 2. StartupComplete.as line 19: 1 – You are mapping to the wrong ID, it should be 1. I think that’s it for now, try running through the above and let me know how it works out for you. PS: I’m attaching your zip and my global css example zip for reference. |
You must be logged in to reply to this topic.







