1 Reply Latest reply on May 21, 2009 1:14 PM by run,ryan!

    cant load image to stage with loader

    rcanulla Level 1

      thoughts?

      <?xml version="1.0" encoding="utf-8"?>
      <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" borderColor="#FFFFFF" creationComplete="init()"
           width="100%" height="100%">
      
      <mx:Script>
           <![CDATA[
           
               import flash.media.Sound;
               import flash.media.SoundChannel;
               import flash.net.URLRequest;
               import flash.display.Loader;
               
               private var song:SoundChannel;
               private var request:URLRequest = new URLRequest("Gun_44magnum.wav");
              private var soundFactory:Sound = new Sound();
              
              private var img:Loader = new Loader();
             
              
      
      
      
      
          
                private function init():void{
                     addEventListener(MouseEvent.CLICK, shootScreen);
                    soundFactory.load(request);
                    img.load(new URLRequest("bulletHole.jpg"));
                    img.contentLoaderInfo.addEventListener(Event.COMPLETE, shootScreen);
                     
      
                     
      
                }
                
                
                private function shootScreen(e:Event):void{
               
                // song = soundFactory.play();
                     trace("loaded");
                     addChild(img);
                }
           ]]>
      </mx:Script>
           
      </mx:WindowedApplication>
      
      

      error

      TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Loader@157ea281 to mx.core.IUIComponent.
           at mx.core::Container/http://www.adobe.com/2006/flex/mx/internal::addingChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:3259]
           at mx.core::Container/addChildAt()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2207]
           at mx.core::Container/addChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2140]
           at bangBang/shootScreen()[/Volumes/Files/Canulla/Brodeur/prof_dev/bangBang/src/bangBang.mxml:41]