Loading and changing the alpha of an image via a static class

Hi !

I’m trying to make a URL-Loader Class to speed up my workflow, but I can’t manage to make the images I am loading visible, turning their alpha to 1. The reason may be that I am using static function, but I am not so good at OOP so any help would be greatly appreciated.

I use the following line to invoke my custom loader:

import com.ab.utils.Load

Load.Image(menuitem.holder_mc, menuitem.image, this)


the code of the class Load is as follows:



package com.ab.utils
{
    /**
    * 
    * @author ABº
    * 
    */
    
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLRequest;
    import com.ab.utils.DebugTF
    import com.ab.utils.Make
    import com.ab.utils.Make2
    import caurina.transitions.Tweener
    import flash.display.MovieClip;
    
    public class Load
    {
        static private var url:String;
        static private var request:URLRequest;
        static private var loader:Loader;
        static private var _ITEM:Object;
        
        static private var _TARGET_ROOT:MovieClip
        
        public static function Image(mc:Object, given_url:String, root:MovieClip):void
        {
            url = given_url
            
            loader = new Loader();
            request = new URLRequest(url);
            
            configureListeners(loader.contentLoaderInfo);
            
            loader.load(request);
            
            mc.alpha = 0
            
            mc.addChild(loader);
            
            _ITEM = mc
            
            _TARGET_ROOT = root
        }
        
        public static function configureListeners(dispatcher:IEventDispatcher):void 
        {
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
            dispatcher.addEventListener(Event.INIT, initHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
        }
        
        public static function completeHandler(event:Event):void
        {
            trace("completeHandler: " + event);
        }
        
        public static function httpStatusHandler(event:HTTPStatusEvent):void
        {
            trace("httpStatusHandler: " + event);
        }
        
        public static function initHandler(event:Event):void
        {
            trace("initHandler: " + event);
            
            Tweener.addTween(_ITEM, { alpha:1, time:0.5, transition:"EaseOutSine" } )
        }
        
        public static function ioErrorHandler(event:IOErrorEvent):void 
        {
            trace("ioErrorHandler: " + event);
        }
        
        public static function progressHandler(event:ProgressEvent):void 
        {
            trace("progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }
    }    
}


Notice where I call a Tweener, trying to make my mc (_ITEM)'s alpha turn 1.

I tried thing like loader.content and loader.content.holder_mc, but to no avail.

If anyone has a clew… :slight_smile:

Season’s greetings :angel:

ABº