Hi;
I have this code:

        function InitRotateGears()
        {
            for (var i = 0; i < gearsPaths.length; i++)
            {
                RotateGears();
                displayGearsCounter += 1;
            }

        function RotateGears()
        {
            var path:String = new String();
            path = gearsPaths[displayGearsCounter];
            var req:URLRequest = new URLRequest(path);
            var loader:Loader = new Loader();
            loader.load(req);
            
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,RotateGearsLoaded);
        }

        function RotateGearsLoaded(e:Event):void
        {
            var loaderInfo:LoaderInfo = e.target as LoaderInfo;
            var displayObject:DisplayObject = loaderInfo.content;
            displayObject.width = gearWidths[displayGearsCounter];
            displayObject.height = gearHeights[displayGearsCounter];
//            displayObject.x = - gearWidths[displayGearsCounter];
//            displayObject.y = - gearWidths[displayGearsCounter];
            displayObject.x = 0;
            displayObject.y = 0;
            parent_container.addChild(displayObject);
            parent_container.x = 0;
            parent_container.y = 0;
            parent_container.alpha = 1;
            addChild(parent_container);
            var myTimeline:TimelineLite = new TimelineLite({useFrames:true});
            myTimeline.append(new TweenMax(parent_container, 1, 
{shortRotation:{rotation:gearAngles[displayGearsCounter]}}));
            }
        }

The problem is that displayGearsCounter traces to value 8 every iteration in 
function RotateGearsLoaded(). It increments when traced in the other two 
functions. Why is that? I tried to pass that var like this:

loader.contentLoaderInfo.addEventListener(Event.COMPLETE,RotateGearsLoaded(displayGearsCounter));


however the compiler complained that two variables were expected and only one 
passed. If I don't pass that var, somehow the e:Event var gets passed, and I 
don't understand that either.
TIA,
John



      

_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to