dcsimg
A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 40 of 40

Thread: Problem Reading XML - Help!

  1. #21
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    i had a quick look and cannot find a fix

    perhaps you could lose the auto-update.

    fresh data will be delivered when the browser is refreshed or when
    a user revisits the site due to the timestamp appended to the url .

  2. #22
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by a_modified_dog
    i had a quick look and cannot find a fix

    perhaps you could lose the auto-update.

    fresh data will be delivered when the browser is refreshed or when
    a user revisits the site due to the timestamp appended to the url .
    Well I'm actually using SWF Studio to convert this into a transparent EXE - which will run on a desktop/kiosk. I'm wondering if I create a new file that has a timeline, and will just call the "L". When the timeline loops the application will just refresh it's self.

    Otherwise - I think I'm out of options for getting this to auto update. At least for now...

  3. #23
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    I've been playing around with the set interval. The text totally wigs out when I update the XML - although it is updating... This exactly same thing happened when I added a timeline. I'm wondering if I need to unload and reload the XML somehow? Do you see this on your end?
    The animation problem in the scrolling text is because of the tween itself..

    When XML updated, calls the function to animate the text but the previous tween animation is still active (call itself recursively when finished) this in conjunction with the fact that used the same variables for all different parts of the tween animation, yields in this strange results as conflict the old and new tween animation and variable names..

    You have to wait the tween animation to finished or stop it [myTween.stop()] (and possibly delete its reference) before every new tween cycle:

    Use this for example (locate in your code and Use this variation for the tween animation -the replacement must be done is that shown in Red color- ):

    Code:
    ... ...
    ... ...
    trace(titles[0][p].LNK)
    		//getURL(titles[0][p].LNK); //open the url on Release
    	};
    }
    
    var myTweenX:Tween
    var myTweenAlpha:Tween
    
    var Completed=true  // Used to avoid abrupt tween stop whenever new data loaded
    
    //animate the text from right to left, pause when it is centered...
    function animateText() {
    	// Wait for the current tween to completed (to avoid abrupt animation end)
    	if (!Completed) return  
    
    	displayText();
    	setEvents(box_mc);
    	pauseTime = 2;
    	startX = w2+w1/2;
    	endX = 0-w1/2;
    	centerX = w2/2;
    	
         // To keep things clear, Delete tween reference before start a new cycle. Although
    	 // this is not absolutelly necessary (especially, you can omit it, if wait the tween to finished)
    	if (myTweenX) {
    		trace("Current Tween Completed: "+new Date().toString())
    		myTweenX.stop()
    		delete myTweenX 
    		myTweenAlpha.stop()
    		delete myTweenAlpha
    	}
    	
    	Completed=false // Set "Completed" to false on tween start
    	myTweenX = new Tween(box_mc.container_mc.news_mc, "_x", Strong.easeOut, startX, centerX, 2, true);
    	myTweenAlpha = new Tween(box_mc.container_mc.news_mc, "_alpha", Strong.easeOut, 0, 100, 2, true);
    
    	myTweenX.onMotionFinished = function() {
    		myTweenX = new Tween(box_mc.news_mc, "_x", Strong.easeOut, centerX, centerX, pauseTime, true);
    
    		myTweenX.onMotionFinished = function() {
    			myTweenX = new Tween(box_mc.container_mc.news_mc, "_x", Strong.easeIn, centerX, endX, 2, true);
    			myTweenAlpha = new Tween(box_mc.container_mc.news_mc, "_alpha", Strong.easeIn, 100, 0, 2, true);
    			//repeat the animateText function and change the text
    			myTweenX.onMotionFinished = function(){
    				Completed=true
    				changeText();
    				animateText();
    			}
    		};
    	};
    }
    
    var colorText:Color = new Color(box_mc.container_mc.news_mc.news_txt);
    var containerState:String = "down";
    
    ... ...
    ... ...

    Note: I selected to wait the previous tween to finished before start a new one, in order to avoid abrupt tween termination (stop) whenever a new XML data loaded. (Just for "memory clean up" reasons I combined also a current tween deletion, before every new tween cycle)

    Regards!

    Kostas
    Last edited by Kostas Zotos; 05-13-2008 at 10:27 AM.
    K. Zotos online portfolio: http://www.in3d.eu

  4. #24
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Thanks for the post Zotos! Is this from the original code Modified Dog posted? Or did you modify the FLA code from my web server?

    Assuming it's from the one the Modified Dog attached, I'll try this later tonight and repost the results in a hour.

  5. #25
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Quote Originally Posted by intromo
    Is this from the original code Modified Dog posted?
    Yes (the L.zip file given in the previous page)

    However independent of the file, the idea is to stop the running tweens (or wait them to finished) whenever the XML updated before call the function to animate the text. Stop the previous tween animation (or wait to finished) before start the new round..

    A simple way to do that (stop tweens) is for example:
    Code:
    if (myTweenX) {
    	myTweenX.stop()
    	//delete myTweenX 
    	myTweenAlpha.stop()
    	//delete myTweenAlpha
    }
    
    // Start here your new tween animation cycle..
    By stopping the running tweens is quite possible to expect an abrupt transition (actually sudden cut) form the current point of tween animations to that of tween start.

    To avoid this small problem may decide to wait the current animation to finished normally (this may takes a time from 1 to 6 seconds.. depends where the current tween(s) position is, when the XML data update occured)

    I tested both methods (sudden cut or waiting the tweens to finished) and worked with no problem (The code is that given in my previous post)

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  6. #26
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Yes!! That works like a charm! Thank you! Didn't know tweens would make such a difference....

    Thank you again for you help!

    Awesome website by the way!

  7. #27
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Thanks!

    Your welcome!

    Kostas
    K. Zotos online portfolio: http://www.in3d.eu

  8. #28
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Yes. Good stuff. One other quick question, i'm trying to get another swf to pop-up above the "L' - I'm having trouble defining the layer... is this rooted or leved? Maybe a stupid question, but I can't seem to get it to work eitherway. Am I missing something?

  9. #29
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    I'm having trouble defining the layer... is this rooted or leved?
    Both can be used producing the same results..

    Here is an example. No levels used, just a new depth value, to set z-order for the PopUp clip.

    In general: A background Clip firstly created dynamicaly, to cover the rest clips and the PopUp loaded in front of this background. The background used also to capture the underline clip's mouse events..

    1) Inser this code at the end of the code in your "L" file.
    2) Locate also this line "Mcl.loadClip("L_PopUp.swf", PopUpContainer)" (at about the end of code) and Replace the external (.swf) clip (this would be the PopUp clip) with yours.

    AS code (please read the comments for some additional details):
    PHP Code:
    // **************************** CODE FOR POPUP CLIP ****************************** //

    // -------------------- CREATE A BACKGROUND FOR OUR POPUP ------------------------

    // Create a background (for our PopUp) clip In front of all other clips
    // this will cover all the stage
    _root.createEmptyMovieClip("PopUpBg",_root.getNextHighestDepth())

    PopUpBg.useHandCursor=false

    // Draw a simple flat surface to cover the entire stage
    with (PopUpBg){
        var 
    OffStage=20 // A value (in pixels) beyond stage limits (to ensure full cover)
        
    var W=Stage.width+OffStage
        
    var H=Stage.height+OffStage
            
        
    //lineStyle(1, 0x222222, 100)  //If want border-outline (stroke)
            
        // Fill with a gray (or maybe white) color  (to gray out the underline clips)
        // (draw a rectangular area to cover the stage)
        
    beginFill(0x777777,80); // 80 => alpha (0-100)

        
    moveTo(-OffStage,-OffStage)
        
    lineTo(W, -OffStage);
        
    lineTo(WH);
        
    lineTo(-OffStageH);
        
    endFill();        
    }

    // Use an "empty" handler to capture the mouse events
    // (to "deactivate" the underline mouse events)
    PopUpBg.onRelease=function(){
    }

    // ----------- CREATE A CONTAINER WHERE TO LOAD THE ACTUAL POPUP CLIP ---------------

    _root.createEmptyMovieClip("PopUpContainer",_root.getNextHighestDepth())
    PopUpContainer._alpha=0  // Make it invisible (to avoid flickering, when move from top left to center of stage)

    // Optionally we use drop shadow filter in our PopUp
    import  flash.filters.DropShadowFilter
    var 
    ShadowF=new DropShadowFilter(5450x0000000.71010// (distance, angle, alpha (0-1), blurX, blurY)
    var filtersArray=[]
    filtersArray.push(ShadowF);


    // --------------------- LOAD THE EXTERNAL .SWF (POPUP) ----------------------------

    // Create a movie clip loader to load our external .swf  (PopUp file)
    var Mcl=new MovieClipLoader()

    Mcl.onLoadInit=function(target){    // "target" is the "PopUpContainer" clip
        // Center our PopUp on stage
        
    target._x=(Stage.width-target._width)/2
        target
    ._y=(Stage.height-target._height)/2    

        PopUpContainer
    .filters=filtersArray // Assign the drop Shadow Filter
        
    PopUpContainer._alpha=100 // make the PopUp visible (or use 90, 80, etc, for partial transparency)
    }

    // Load our external file (PopUp) in the container
    // USE YOUR .SWF FILE INSTEAD
    Mcl.loadClip("L_PopUp.swf"PopUpContainer)


    /* AFTER LOADING: TO CLOSE THE POPUP, A POSSIBLE CODE WOULD BE FOR EXAMPLE:

    // NOTE: This code normally must be palced inside PopUp file,
    // eg. in a button which is inside your loaded PopUp insert this code:

    CloseButton.onRelease=function(){
        // Hide the PopUp and its Background, if plan to re-use them.
        //_root.PopUpContainer._visible=false  
        //_root.PopUpBg._visible=false    

        // Completely unload the PopUp and its Background if you will not use them anymore.
        unloadMovie(_root.PopUpContainer)
        unloadMovie(_root.PopUpBg)
    }

    */ 
    Regards!

    Kostas
    Last edited by Kostas Zotos; 05-22-2008 at 01:28 PM.
    K. Zotos online portfolio: http://www.in3d.eu

  10. #30
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Hi Kostas,

    Thanks for the post. After a few delays, I'm back on this project again. Looking are you're code - it looks to be exacly what I need, however I'll need the pop-up called from the XML and I"m not exacly sure to incoporate this. I've tried serveral different ways, however it still comes-up behind the "L"...

    Any suggestions would be totally helpful.
    Hope all is well!
    ~ Brian

  11. #31
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi "intromo"!

    If I understood well.. You may put all the code in my previous post (that for PopUp) inside a custom function, and then call that function from inside your XML parser function..

    Example at the end of your parser function may insert something like (shown in red):
    Code:
    xmlParse = function (xmlObj) {
       // ... ...
       //  .. ... 
    
       //  Maybe also put the function call in a condition 
       //  if you don't want a popUp in every XML update cycle..
       ShowPopUp()   // Call to launch the PopUp
    }
    
    
    function ShowPopUp(){
      
       // Insert here all the code given in my previous post
     
    }
    Important: My code uses the "getNextHighestDepth()" to create a container for the PopUp clip.. So it is important to call the function for PopUp after all data has been loaded and any initialization actions (or dynamicaly created clips) have been completed..

    As alternative, you may insert pre-defined/custom values for depths -manually for all your major elements/objets- (you have then also to locate and change the depths in my code, giving the larger of these predefined depth values in my "PopUpBg" and "PopUpContainer" clips) [instead of use the "getNextHighestDepth()"] in order to ensure that the PopUp will be always the topmost movie in your screen.. However this means you have some additional coding and modifications

    Also may insert something like these AS lines, after (at the end of) the code that creates the PopUp , so that brings these clips in front of the rest (not test it, so i am not sure if actually works):
    PHP Code:
    _root.PopUpBg.swapDepths(_root.getNextHighestDepth())  // PopUpBg => a dynamicaly created  clip, used as background for the "PopUpContainer" clip
    _root.PopUpContainer.swapDepths(_root.getNextHighestDepth()) 
    I think you are close to success..

    ------------------------------------
    Hope all is well!
    Thank you! hope you too (U2)

    Kostas
    Last edited by Kostas Zotos; 05-30-2008 at 03:00 PM.
    K. Zotos online portfolio: http://www.in3d.eu

  12. #32
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Hi Kostas,

    Dis-regard that last posting. This seems to work, but I need the pop-up to be transparent... is that possible?

    Again - thanks for the help...

  13. #33
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by intromo
    Hi Kostas,

    Dis-regard that last posting. This seems to work, but I need the pop-up to be transparent... is that possible?

    Again - thanks for the help...
    Scratch that again - I'm way to eager to post before I play around with the code.

    Everything seems to be working great with what you sent over. Thank you! I just need to spend some time editing my SWF's to pop-up properly in the container. They seem to be load all weird...

    Again - hope all is well. Thanks for the help & support!!!

  14. #34
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    I just ran into another issue (which I know is on my end). I've gotten the pop-up to work well with some swfs, however - to complicate things, I now have and swf the pulls an external xml to play a list of other swf's. All of the swf's play just fine in standalone, but when i call them using the swf/xml - i get nothing....

    Here's the swf code calling the swf's:

    Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    
    // Fade functions
    function fadeIn(){
    var the_tween:Object;
    the_tween = new Tween(container_brian, "_alpha", Regular.easeOut, 0, 100, 1, true);
    }
    function fadeOut(){
    var the_tween:Object;
    the_tween = new Tween(container_brian, "_alpha", Regular.easeOut, 100, 0, 1, true);
    }
    
    // Load XML
    function loadXML(loaded) {
    	if (loaded) {
    		xmlNode = this.firstChild;
    		swiff = [];
    		total = xmlNode.childNodes.length;
    		for (i=0; i<total; i++) {
    			swiff[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
    		}
    		firstswiff();
    		} 
    	else {
    		content = "ERROR: Not loaded!";
    	}
    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    
    // make a timestamp, add to xml url to force fresh data
    vers = new Date().getTime();
    
    
    xmlData.load("main.xml?vers="+vers);
    // End of xml
    
    my_loader = new MovieClipLoader();
    my_loader.addListener(this);
    function onLoadInit(mc:MovieClip) {
    	preloader._visible = false;
    }
    function onLoadProgress(container_brian, bL, bT){
    	perc = Math.round((bL/bT)*100);
    	container_brian_txt.text = perc+" %";
    	preloader._visible = true;
    }
    var k:Number = 0;
    
    function firstswiff(){
    	my_loader.loadClip(swiff[k], container_brian);
    	fadeIn();
    }
    
    // External swf files call this function 
    // Call function AScode:    _root.nextswf();
    function nextswf(){
    	k++;
    	if(k > total-1){
    		k=0
    		fadeIn();
    		my_loader.loadClip(swiff[k], container_brian);
    	}
    	fadeIn();
    	my_loader.loadClip(swiff[k], container_brian);
    }

    Could this be a container issue? Totally stummped on this one...

  15. #35
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Hi,

    Thanks for the help & support!!!
    Don't mention it!
    --------------------------------------------

    Regarding your code: it seems OK..

    Check these points:
    1) Is the "container_brian" on the _root or inside another clip ?
    (Your code implies that is on _root, otherwise must give the correct path)
    Also the loaded files will replace the "container_brian" (Use it -the "container_brian" - to refer the loaded clip)

    2) Make sure your .swf file names inside XML have not leading or trailing spaces

    3) When test your file Offline use: xmlData.load("main.xml")
    When test it Online (or in a local running server) then use the: xmlData.load("main.xml?vers="+vers);

    --------------------------------------------

    Here is also a completely new approach based on levels:
    (This is just a very basic example: The PopUp loaded into _level1, and the _root (_level0) is made just invisible):
    PHP Code:
    ShowPopUp()  // Use it to call the "ShowPopUp" function

    // ***************** CODE FOR POPUP CLIP (LOADS POPUP IN _LEVEL1) ********************* //
    function ShowPopUp(){
            
        
    // --------------------- LOAD THE EXTERNAL .SWF (POPUP) ---------------------------- 

        // Create a movie clip loader to load our external .swf  (PopUp file) 
        
    var Mcl=new MovieClipLoader() 

        
    Mcl.onLoadInit=function(target){    // "target" is here the _level1
            
    _root._visible=false //Hide everything in the _root (_level0)

            // Center our PopUp on stage (if needded)
            //trace(target)
            
    _level1._visible=false
            target
    ._x=(Stage.width-target._width)/
            target
    ._y=(Stage.height-target._height)/2     

            _level1
    ._visible=true
        


        
    // Load our external file (PopUp) in the _level1
        // USE YOUR .SWF FILE INSTEAD 

        
    Mcl.loadClip("L2_LoadPopUp.swf"1
        
        
    /* AFTER LOADING: TO CLOSE THE POPUP, A POSSIBLE CODE WOULD BE FOR EXAMPLE: 

        // NOTE: This code normally must be palced inside PopUp file, 
        // eg. in a button which is inside your loaded PopUp insert this code: 
        
        closeButton.onRelease=function(){    
            _level0._visible=true
        
            unloadMovie(_level1)
            //_level1._visible=false
        }
        */

    Finally based on your code, I made this example -For Flash 8- (and works fine for me) [this is actually your code, adjusted to a working example (the external .swf files loaded from an XML in an empty clip -"container_brian"- No special PopUp used, just loaded into the previous container without problem..]

    Regards!

    Kostas
    Attached Files Attached Files
    K. Zotos online portfolio: http://www.in3d.eu

  16. #36
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Kostas,

    Pure genius! I had to do some modifications, but it's now working perfectly! Not to mention smoothly! Awesome stuff!!!

    Can't thank you enough for your help. If there's anything I can do for you - don't hesitate to ask. Keep in touch...

  17. #37
    http://www.in3d.eu Kostas Zotos's Avatar
    Join Date
    Jul 2007
    Location
    Athens - Greece
    Posts
    408
    Thanks for your kind words!
    (LoL.. I am a normal person -believe- )

    .. If there's anything I can do for you - don't hesitate to ask. Keep in touch...
    Thank you very much!

    BTW: In my example ("L2.zip" file -in my previous post- ) there is a function which removes spaces from a given string argument.
    This function removes all spaces and maybe this is unwanted in some cases..

    I recommend to replace that function with this one (which removes only any leading and/or trailing spaces):
    PHP Code:
    //Removes possible leading or trailing spaces from input arguments (eg. XML string values)
    function trim(Arg:String){ 
        var 
    Result="",Char=""
        
    var Start=0
        
    var End=Arg.length-1
        
        Char
    =Arg.charAt(Start)
        while(
    Char==" "){Start++; Char=Arg.charAt(Start)}
        
        
    Char=Arg.charAt(End)
        while(
    Char==" "){End--; Char=Arg.charAt(End)}    
        
        
    Result=Arg.substring(Start,End+1)    
        return 
    Result        
    }

    // Example use:
    var Name:String
    Name
    =trim(Name)  //Removes (any) leading and/or trailing spaces 
    Note: If input a value from an XML which contains spaces, and use this value (file name) to load eg. an external file, most probably the loading will fail..

    Best Regards!

    Kostas
    Last edited by Kostas Zotos; 06-05-2008 at 12:06 PM.
    K. Zotos online portfolio: http://www.in3d.eu

  18. #38
    Junior Member
    Join Date
    Nov 2007
    Posts
    20

    Quick question about adding description in xml and flash

    Hello I have a flash xml photo gallery that was previously made. I love everything about it but i would like to be able to have descriptions of the pictures once they are clicked. I know this isnt very hard i am just not very famililar with xml or flash. I know in xml i can just add something like <desc>THIS IS MY DESCRIPTION</desc> in the already created xml however I am not sure how to create the container or whatever so it will display in flash.

    The site that I am working on is
    http://www.wpc-consulting.com/~stxmi...=photo_gallery

    The gallery works great like i said i am just interested in getting some descriptions.

    xml looks like this

    Code:
    
    <?xml version="1.0" encoding="utf-8"?>
    <images>
      <image>
          <url>pics/img_1.png</url>
    	  <big_url>big_pics/img_1.png</big_url>
      </image>
      <image>
          <url>pics/img_2.png</url>
    	  <big_url>big_pics/img_2.png</big_url>
      </image>
      <image>
          <url>pics/img_3.png</url>
    	  <big_url>big_pics/img_3.png</big_url>
      </image>
      <image>
          <url>pics/img_4.png</url>
    	  <big_url>big_pics/img_4.png</big_url>
      </image>
      <image>
          <url>pics/img_5.png</url>
    	  <big_url>big_pics/img_5.png</big_url>
      </image>
      <image>
          <url>pics/img_6.png</url>
    	  <big_url>big_pics/img_6.png</big_url>
      </image>
      <image>
          <url>pics/img_7.png</url>
    	  <big_url>big_pics/img_7.png</big_url>
      </image>
      <image>
          <url>pics/img_8.png</url>
    	  <big_url>big_pics/img_8.png</big_url>
    	<desc>View of Seattle</desc>
      </image>
      <image>
          <url>pics/img_9.png</url>
    	  <big_url>big_pics/img_9.png</big_url>
      </image>
      <image>
          <url>pics/img_10.png</url>
    	  <big_url>big_pics/img_10.png</big_url>
      </image>
      <image>
          <url>pics/img_11.png</url>
    	  <big_url>big_pics/img_11.png</big_url>
      </image>
      <image>
          <url>pics/img_12.png</url>
    	  <big_url>big_pics/img_12.png</big_url>
      </image>
      <image>
          <url>pics/img_13.png</url>
    	  <big_url>big_pics/img_14.png</big_url>
      </image>
      <image>
          <url>pics/img_14.png</url>
    	  <big_url>big_pics/img_14.png</big_url>
      </image>
      <image>
          <url>pics/img_15.png</url>
    	  <big_url>big_pics/img_15.png</big_url>
      </image>
    </images>

    Let me know if you would like me to send you the .fla file. It is bigger than the 300kb so i will give you a link to download it if you need to. Thanks for the help.

  19. #39
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by welchyboy
    He
    Let me know if you would like me to send you the .fla file. It is bigger than the 300kb so i will give you a link to download it if you need to. Thanks for the help.
    Welchyboy - I would suggest creating a new topic for your question (as this doesn't really pertain to this thread). I can help you out then. Should be rather simple. Let me know when you've done that.

  20. #40
    Junior Member
    Join Date
    Nov 2007
    Posts
    20
    New thread created here http://board.flashkit.com/board/show...99#post4062199

    Thanks for the help!

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