Sorry cant help u much... the code looks fine. However my guess is
that your module is not getting loaded for some reason.
Why dont u debug the code and see if ur onHeaderModuleReady function
is getting called or not. The most likely expanation is that it isnt
and because of that ur variable jpl_head never gets initialized.
Another thing that u can see before debugging is when the application
loads is the default image (jpl_head.png) getting displayed on the
screen. If it is then there is something else wrong in the code and u
wont find out without debugging.

Sorry if I am stating the obvious.

On Feb 3, 8:57 pm, Flex Hatter <[email protected]> wrote:
> Hi all,
>
> Im still stuck with this... anybody know solution for this?
>
> On Thu, Jan 27, 2011 at 5:26 PM, Flex Hatter <[email protected]> wrote:
> > Hi all,
>
> > I'm trying to use module in flex. I tried create a header module which is
> > loaded by the main
> > application and should update the image component in the header. I have
> > posted my code
> > below. I cannot update the image component in header, please help me in
> > fixing the code and
> > suggest me if any better way.
>
> > *index.mxml*
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> >     backgroundColor="#f2f2f2" backgroundAlpha="1"
> >     layout="absolute" width="1000" height="800"
> >     creationComplete="init()">
> >     <mx:Script>
> >         <![CDATA[
> >             import mx.controls.Alert;
> >             import com.jpl.modules.*;
> >             import mx.events.ModuleEvent;
> >             import mx.modules.ModuleManager;
> >             import mx.modules.IModuleInfo;
>
> >             private var moduleInfo:IModuleInfo;
> >             private function init():void{
> >                 loadHeader();
> >             }
>
> >             private var jpl_head:Object;
> >             //loading header into application
> >             private function loadHeader():void{
> >                 mod_progress.visible = true;
> >                 moduleInfo = ModuleManager.getModule(
> > "com/jpl/modules/headerMod.swf" );
> >                    moduleInfo.addEventListener( ModuleEvent.READY,
> > onHeaderModuleReady);
> >                    moduleInfo.addEventListener(ModuleEvent.ERROR,
> > handleHeaderModuleError);
> >                    moduleInfo.addEventListener(ModuleEvent.PROGRESS,
> > onHeaderModuleProgress);
> >                    moduleInfo.load();
> >             }
> >                protected function onHeaderModuleReady(
> > moduleEvent:ModuleEvent ):void{
> >                    jpl_head = moduleInfo.factory.create() as headerMod;
> >                 mod_holder.addChild(moduleInfo.factory.create() as
> > DisplayObject);
> >                 mod_progress.label = ""
> >                 mod_progress.visible = false;
> >             }
> >                protected function handleHeaderModuleError(
> > moduleEvent:ModuleEvent ):void{
> >                 throw new Error( "Module error loading : " +
> > moduleEvent.module.url );
> >                }
> >             protected function onHeaderModuleProgress(
> > moduleEvent:ModuleEvent ):void{
> >                 mod_progress.label = 'Loading Header';
> >                 mod_progress.setProgress( moduleEvent.bytesLoaded,
> > moduleEvent.bytesTotal );
> >             }
> >         ]]>
> >     </mx:Script>
>
> >     <mx:Canvas id="mod_holder">
> >     </mx:Canvas>
>
> >     <mx:ProgressBar id="mod_progress"
> >         width="300" indeterminate="true"
> >         trackHeight="5" labelPlacement="top"
> >         label="Loading .."/>
> >     <mx:Button x="143" y="154" label="Button"
> > click="jpl_head.changeUserPic('video_icon.png');"/>
>
> > </mx:Application>
>
> > *headerMod.mxml*
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute">
> >     <mx:Script>
> >         <![CDATA[
> >             [Embed(source="assets/images/jpl_head.png")]
> >             [Bindable]
> >             public var headerImgCls:Class;
>
> >             public function changeUserPic(picUrl:String):void{
> >                 userPics.source = picUrl;
> >             }
> >         ]]>
> >     </mx:Script>
> >     <mx:Canvas>
> >         <mx:Image id="hdImg" width="1000" height="75"
> > source="{headerImgCls}"/>
> >         <mx:Image id="userPics" x="924" y="9"
> >             width="54" height="54"/>
> >     </mx:Canvas>
> > </mx:Module>
>
> > *Error on clicking button in index.mxml*
> > TypeError: Error #1009: Cannot access a property or method of a null object
> > reference.
> >     at
> > com.jpl.modules::headerMod/changeUserPic()[E:\FlexTraining\jlp\src\com\jpl\modules\headerMod.mxml:10]
> >     at
> > index/___index_Button1_click()[E:\FlexTraining\jlp\src\index.mxml:56]

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to