A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Test Movie = FINE, Projector = loads all XML data at once!

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    10

    Test Movie = FINE, Projector = loads all XML data at once!

    I've created a swf player that loads urls from an XML playlist. One of the key features is accessing the timeline of those swfs in order to loop and scrub their timelines. Everything works just fine when I test the movie, but once I publish to projector, all of my swfs in the XML playlist are loaded at once. AND they all load as soon as I open the page, not on click, as it should be. This is my first major project that I've created from scratch in AS3, so I need all the help I can get. I'm wondering if it has to do with the way I've structured my code. I have my main fla, then I have my document class in an external package, and each "page" of this menu (much like pages of a website) have only one package/class. In the case of the swf player, it is the ToolsPage Class. I know this structure isn't ideal, but it has worked until now (if that's the issue).

    Please, please, please help. Deadline is soon.

    Essentially, swf_loader:Loader loads each swf and puts it into a MovieClip called swfHolder. swfHolder allows for all the remote timeline access.

    I'll abbreviate the code here:

    PHP Code:
    //--------------------------------------------------------------------------------------//
    //ToolsPage.as (Tools Page)
    //--------------------------------------------------------------------------------------//
    package 
    {
    ...
    imports

        
    public class ToolsPage extends MovieClip
        
    {
    ...
    vars including:
            public var 
    toolsXMLList:XMLList;
            public var 
    toolsXML:XML;
            public var 
    toolsXMLLoader:URLLoader = new URLLoader();
            public var 
    swf_loader:Loader;

            public var 
    swfHolder:MovieClip;

            public var 
    tooltype:Sprite;
            public var 
    toolname:Sprite;
            public var 
    specs:Sprite;
            public var 
    thumbs:Sprite;    



            public function 
    processXML (event:Event):void 
            
    {
                
    toolsXML = new XML(toolsXMLLoader.data);
                
    ...
    assign variables to XML data
            
    }
            
            
            public function 
    makeContainers ():void 
            
    {

                
    swf_container = new Sprite();
                
    swf_container.420;
                
    swf_container.20;
                
    addChild(swf_container);
                
                
    swf_player = new SWFPlayer();
                
    swf_container.addChild(swf_player);
                
                
    list_container = new Sprite();
                
    list_container.40;
                
    list_container.100;
                
    addChild(list_container);
                
                
    spec_container = new Sprite();
                
    spec_container.400;
                
    spec_container.220;            
                
    addChild(spec_container);

                
    text_container = new Sprite();
                
    list_container.addChild (text_container);

                
    thumb_container = new Sprite();
                
    list_container.addChild (thumb_container);
        
                
    thumbs = new Sprite();
                
    thumbs.addEventListener (MouseEvent.CLICKswf_specs_loader);
                
    //thumbs.addEventListener (MouseEvent.CLICK, specs_loader);
                
    thumbs.addEventListener (MouseEvent.MOUSE_OVERonOver);
                
    thumbs.addEventListener (MouseEvent.MOUSE_OUTonOut);
                
    thumbs.thumbs_x;
                
    thumbs.thumbs_y;
                
    thumbs.buttonMode true;
                
    thumb_container.addChild (thumbs);
                
                
    tooltype = new Sprite();
                
    tooltype.thumbs_x 20;
                
    tooltype.thumbs_y;
                
    text_container.addChild (tooltype);

                
    toolname = new Sprite();
                
    toolname.thumbs_x 20;
                
    toolname.thumbs_y;
                
    text_container.addChild(toolname);
                
                
    specs = new Sprite();
                
    specs.20;
                
    specs.20;            
                
    spec_container.addChild(specs);
                

                
    trace("Tools_5 : makeContainers() has been read");        
            }
                    
            
    //Loading XML data and adding THUMB data to display list
            
    public function callThumbs ():void 
            
    {
                for (var 
    i:Number 0total_swfsi++) 
                {
                    
    //XML THUMB
                    
    var thumb_url toolsXMLList[i].@THUMB;
                    var 
    thumb_loader = new Loader();
                    
    thumb_loader.name i;
                    
    thumb_loader.load (new URLRequest(thumb_url));
                    
    thumb_loader.= (thumb_height 4)*i;                
                    
    thumb_loader.contentLoaderInfo.addEventListener (Event.COMPLETEthumbLoaded);
                    
    //BUT IF THE THUMBS VARY IN SIZE WHAT IS THE Y PROPERTY 
                    //IF THE THUMB IS A TOOLNAME THE Y IS (thumb_height+2)*i;
                    //IF THE THUMB IS A TOOLTYPE THE Y IS (thumb_placeholder_height+2)*i;
                
    }
                
    trace("Tools_11  : callThumbs() has been read");
            }
            public function 
    thumbLoaded (event:Event):void 
            
    {
                var 
    my_thumb:Loader Loader(event.target.loader);
                
    thumbs.addChild (my_thumb);
                
    my_thumb.contentLoaderInfo.addEventListener (Event.COMPLETEprocessXML);

                
    trace("Tools_28 : each thumb loaded");
                
            
            }
            public function 
    callText ():void 
            
    {
                for (var 
    i:Number 0total_swfsi++) 
                {
    ...
    add text from XML to display list
                }
                
    trace("Tools_9 : callText() has been read");
            }
            
            public function 
    makeLoader():void
            
    {
                
    swf_loader = new Loader();
                
    swf_loader.swf_x;
                
    swf_loader.swf_y;
                
    swf_loader.scaleX .5;
                
    swf_loader.scaleY .5;
                
    swf_container.addChild(swf_loader);

                
    swfHolder = new MovieClip()
                
    swfHolder.0;
                
    swfHolder.0;
                
    swf_container.addChild(swfHolder);            

                
    //swfHolder.scaleX = .5;
                //swfHolder.scaleY = .5;

            
    }

            public function 
    swf_specs_loader(event:MouseEvent):void
            
    {
                
    //does this need to be in a new function?
                
    spec_format.font  myFont.fontName;
                
    spec_format.size  10;
                
    spec_format.color 0xFFFFFF;                

                
    //XML SPECS
                
    var thumb_specs toolsXMLList[event.target.name].@SPECS;
                
    spec_txt.embedFonts true;
                
    spec_txt.width 380;
                
    spec_txt.height 240;
                
    spec_txt.20;
                
    spec_txt.60;
                
    spec_txt.autoSize TextFieldAutoSize.LEFT;
                
    spec_txt.antiAliasType AntiAliasType.ADVANCED;
                
    spec_txt.defaultTextFormat spec_format;
                
    spec_txt.text thumb_specs;
                
    spec_txt.wordWrap true;
                
    specs.addChild(spec_txt);
                
    trace("Tools_l_specs");

                
    //if there is a swf already loaded, unload it
                //OR compare the specs loader for eliminating the multiple loading
                //swf_loader.unload();

                //XML SWF_URL
                
    var thumb_swf_url toolsXMLList[event.target.name].@SWF_URL;        
                
    swf_loader.load (new URLRequest(thumb_swf_url));
                
                
    trace(this.loaderInfo.url);
                
    swf_loader.contentLoaderInfo.addEventListener(Event.COMPLETEswf_loaded);
                
    trace("Tools_11  : swfLoader() has been read");
                
    //var my_swf:Loader = Loader(event.target.loader);
                //swf_container.addChild (my_swf);
        
            
    }

            public function 
    swf_loaded(event:Event):void
            
    {
                
                
    swfHolder event.currentTarget.content;


                
    trace("yay completed");
            }
    ...
    a lot more code giving playback functionality to the swf player
            
    //CONSTRUCTOR
            
    public function ToolsPage()
            {
                
    toolsXMLLoader.load(new URLRequest("tools_content.xml"));
                
    trace("Tools_2 : XML has been loaded");
                
    toolsXMLLoader.addEventListener (Event.COMPLETEprocessXML);
                
    trace("Tools_3 : Once XML is loaded, process the XML (processXML)");
            }
        }

    Thanks so much!
    Deb
    Last edited by doodle20; 11-04-2009 at 10:58 AM.

  2. #2
    Junior Member
    Join Date
    Oct 2008
    Posts
    10
    Hmm. I just noticed in thumbLoaded(), the following line probably shouldn't redirect the reader back up to processXML, since that has already been called, right?

    my_thumb.contentLoaderInfo.addEventListener (Event.COMPLETE, processXML);

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center