A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: If there is no url found doing something else

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Posts
    18

    If there is no url found doing something else

    Hey,

    I'm working on this project which loads texts and images from xml,
    the texts and images are loaded in and then put in arrays.

    But when I don't put an url in the xml it will say url not found and just display nothing, so this is what I'm trying to get, A way to like if it can't find one of the urls to just skip it and move the text loaded over that spot. But I just can't seem to get it right, I'm sort of a beginner so srry if this is a stupid question I just can't find how to fix this and can't find any good fix for it so I hope you guys know something.

    Greetings, Roger

  2. #2
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    both Loader and URLLoader dispatch events when there's an error like that - you can assign handlers to do stuff when those events are fired.

    post the code you're using now.

  3. #3
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    It probably looks noobish since I used a tut and extended it alot.

    So in my xml I have about 8 urls listed, it gets loaded into flash, stored in an array and played one by one, but since I wanna leave one away, I have work around that , thanks for your help already, this is the full script

    PHP Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    import flash.sampler.NewObjectSample;
    import flash.display.Sprite;
    import flashx.textLayout.elements.OverflowPolicy;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFormat;

    stage.scaleMode StageScaleMode.NO_SCALE//preventing to stretch when embedded

    //=====================================================================================================
    //Here we make a var for everything we are gonna import from the xml etc.
    //=====================================================================================================
    var my_speed:Number// the var where our transition speed will be put in
    var my_total:Number// the var where the amount of images will be put in
    var my_images:XMLList// the var where our image settings will be stored

    var my_loaders_array:Array = []; // Array where all images are stored
    var my_labels_array:Array = []; // Array where all Texts are stored
    var my_authors_array:Array = []; // Array where we will store our authors

    // Arrays where all the width/height, x and y values are gonna be stored
    var my_textWidth_array:Array = [];
    var 
    my_textHeight_array:Array = [];
    var 
    my_textX_array:Array = [];
    var 
    my_textY_array:Array = [];
    //========
    var my_imgWidth_array:Array = [];
    var 
    my_imgHeight_array:Array = [];
    var 
    my_imgX_array:Array = [];
    var 
    my_imgY_array:Array = [];
    // End of the arrays with values

    var my_success_counter:Number 0// counter to check if everything is loaded
    var my_playback_counter:Number 0// counter to go to the next message

    var my_slideshow:Sprite = new Sprite(); // container for our total slideshow
    var my_image_slides:Sprite = new Sprite(); // container for our images
    var my_label_slides:Sprite = new Sprite(); // container for our texts
    var my_author_slides:Sprite = new Sprite(); // container for our authors

    var my_preloader:TextField// here we add a preloader

    var my_timer:Timer// making a timer
    var my_prev_tween:Tween// tween for removing our previous message
    var my_tweens_array:Array = []; // making an array to store our tweens





    //=====================================================================================================
    //Here we import the xml file and make it process
    //=====================================================================================================

    var my_xml_loader:URLLoader = new URLLoader();
    my_xml_loader.load(new URLRequest("slideshow.xml"));
    my_xml_loader.addEventListener(Event.COMPLETEprocessXML);

    //=====================================================================================================
    //Here the speed, image url's and the number of images are imported from the xml
    //=====================================================================================================

    function processXML (e:Event):void
    {
        
        var 
    my_xml:XML = new XML(e.target.data);
        
    my_speed=my_xml.@SPEED// Getting our transition speed in seconds from the xml

        
    my_images=my_xml.IMAGE// Importing the slides
        
    my_total=my_images.length(); // counting the number of slides
        
        
    loadImages();
        
        
    my_xml_loader.removeEventListener(Event.COMPLETEprocessXML); 
        
    my_xml_loader null;
        

        
    }

    //=====================================================================================================
    //Here we simply load the images and text's
    //=====================================================================================================

    function loadImages():void
    {
        
        for (var 
    i:Number 0my_totali++)
        { 
        
            var 
    my_format:TextFormat = new TextFormat();    
            
    my_format.size my_images[i].@FONTSIZE;
            
    my_format.color my_images[i].@COLOR;
        
            var 
    my_Aformat:TextFormat = new TextFormat();
            
    my_Aformat.size my_images[i].@AUTHORSIZE;
            
    my_Aformat.color my_images[i].@AUTHORCOLOR;
            
            
    //adding our fonts from the library to actionscript
            
    var F1 = new Font1();
            var 
    F2 = new Font2();
            var 
    F3 = new Font3();
            var 
    F4 = new Font4();
            var 
    F5 = new Font5();
            var 
    F6 = new Font6();
            var 
    F7 = new Font7();
            var 
    F8 = new Font8();
            var 
    F9 = new Font9();
            var 
    F10 = new Font10();
            var 
    F11 = new Font11();
            
            
            if(
    my_images[i].@FONTFAMILY == "Impact")
                {
                    
    my_format.font F1.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Times New Roman")
                {
                    
    my_format.font F2.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Verdana")
                {
                    
    my_format.font F3.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Brush Script MT")
                {
                    
    my_format.font F4.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Georgia")
                {
                    
    my_format.font F5.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Arial")
                {
                    
    my_format.font F6.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Trebuchet MS")
                {
                    
    my_format.font F7.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Webdings")
                {
                    
    my_format.font F8.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Andale Mono")
                {
                    
    my_format.font F9.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Arial Black")
                {
                    
    my_format.font F10.fontName;
                }
                if(
    my_images[i].@FONTFAMILY == "Comic Sans MS")
                {
                    
    my_format.font F11.fontName;
                }
                
    // author fontfamily's
                
    if(my_images[i].@AUTHORFONT == "Impact")
                {
                    
    my_Aformat.font F1.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Times New Roman")
                {
                    
    my_Aformat.font F2.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Verdana")
                {
                    
    my_Aformat.font F3.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Brush Script MT")
                {
                    
    my_Aformat.font F4.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Georgia")
                {
                    
    my_Aformat.font F5.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Arial")
                {
                    
    my_Aformat.font F6.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Trebuchet MS")
                {
                    
    my_Aformat.font F7.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Webdings")
                {
                    
    my_Aformat.font F8.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Andale Mono")
                {
                    
    my_Aformat.font F9.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Arial Black")
                {
                    
    my_Aformat.font F10.fontName;
                }
                if(
    my_images[i].@AUTHORFONT == "Comic Sans MS")
                {
                    
    my_Aformat.font F11.fontName;
                }
        
            var 
    my_url:String my_images[i].@URL;
            var 
    my_loader:Loader = new Loader();
            
    my_loader.load(new URLRequest(my_url));
            
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETEonComplete);
            
    my_loaders_array.push(my_loader);
            
            var 
    my_txtWidth:Number
            my_txtWidth 
    my_images[i].@txtW;
                    
            var 
    my_label:TextField = new TextField();
            
    my_label.defaultTextFormat my_format;
            
    my_label.text my_images[i].@TITLE;
            
    my_labels_array.push(my_label);

        
            
            var 
    my_author:TextField = new TextField();
            
    my_author.defaultTextFormat my_Aformat;
            
    my_author.text my_images[i].@AUTHOR;
            
    my_authors_array.push(my_author);
            
            
    // Pushing the text width/height, x and y into our arrays
            
    var my_textWidth:Number = new Number();
            
    my_textWidth my_images[i].@txtW;
            
    my_textWidth_array.push(my_textWidth);
            var 
    my_textHeight:Number = new Number();
            
    my_textHeight my_images[i].@txtH;
            
    my_textHeight_array.push(my_textHeight);
            var 
    my_textX:Number = new Number();
            
    my_textX my_images[i].@txtX;
            
    my_textX_array.push(my_textX);
            var 
    my_textY:Number = new Number();
            
    my_textY my_images[i].@txtY;
            
    my_textY_array.push(my_textY);
            
            
    // Pushing the img width/height, x and y into our arrays
            
    var my_imgWidth:Number = new Number();
            
    my_imgWidth my_images[i].@imgW;
            
    my_imgWidth_array.push(my_imgWidth);
            var 
    my_imgHeight:Number = new Number();
            
    my_imgHeight my_images[i].@imgH;
            
    my_imgHeight_array.push(my_imgHeight);
            var 
    my_imgX:Number = new Number();
            
    my_imgX my_images[i].@imgX;
            
    my_imgX_array.push(my_imgX);
            var 
    my_imgY:Number = new Number();
            
    my_imgY my_images[i].@imgY;
            
    my_imgY_array.push(my_imgY);
            
        }
        
        
    my_preloader = new TextField();
        
    my_preloader.text="Loading";
        
    my_preloader.autoSize TextFieldAutoSize.CENTER;
        
    my_preloader.= (stage.stageWidth my_preloader.width)/2;
        
    my_preloader.= (stage.stageHeight my_preloader.height)/2;
        
    addChild(my_preloader);

    }


    function 
    onComplete(e:Event):void
    {
        
    my_success_counter++;
        if (
    my_success_counter == my_total)
        {
            
    startShow();
        }
        
        var 
    my_loaderInfo:LoaderInfo LoaderInfo(e.target); 
        
    my_loaderInfo.removeEventListener(Event.COMPLETEonComplete);
    }

    //=====================================================================================================
    //Here we add everything to the stage and specify our timer
    //=====================================================================================================

    function startShow():void
    {
        
        
    removeChild(my_preloader);
        
    my_preloader null;
        
        
    addChild(my_slideshow);
        
    my_slideshow.addChild(my_image_slides);
        
    my_slideshow.addChild(my_label_slides);
        
    my_slideshow.addChild(my_author_slides);
        
        
    nextImage();
        
        
    my_timer = new Timer(my_speed*1000);
        
    my_timer.addEventListener(TimerEvent.TIMERtimerListener); 
        
    my_timer.start();
        
    }

    //=====================================================================================================
    //All our settings for the next image are set here
    //=====================================================================================================

    function nextImage():void
    {

        var 
    my_image:Loader Loader(my_loaders_array[my_playback_counter]);
        var 
    my_imgWidth:Number Number(my_imgWidth_array[my_playback_counter]);
        var 
    my_imgHeight:Number Number(my_imgHeight_array[my_playback_counter]);
        var 
    my_imgX:Number Number(my_imgX_array[my_playback_counter]);
        var 
    my_imgY:Number Number(my_imgY_array[my_playback_counter]);
        
    my_image_slides.addChild(my_image); 
        
        
    my_image.my_imgX;
        
    my_image.my_imgY;
        
    my_image.width my_imgWidth;
        
    my_image.height my_imgHeight;
        
        
    my_tweens_array[0] = new Tween(my_image,"alpha",Strong.easeOut,0,1,4,true);
        
        var 
    my_label:TextField TextField(my_labels_array[my_playback_counter]);
        var 
    my_textWidth:Number Number(my_textWidth_array[my_playback_counter]);
        var 
    my_textHeight:Number Number(my_textHeight_array[my_playback_counter]);
        var 
    my_textX:Number Number(my_textX_array[my_playback_counter]);
        var 
    my_textY:Number Number(my_textY_array[my_playback_counter]);
        
    my_label_slides.addChild(my_label);
        
    my_label.wordWrap true;
        
    my_label.width my_textWidth;
        
    my_label.height my_textHeight;
        
    my_label.my_textX;
        
    my_label.my_textY;
        
        
        
    my_tweens_array[1] = new Tween(my_label,"alpha",Strong.easeOut,0,1,4,true);
        
        var 
    my_author:TextField TextField(my_authors_array[my_playback_counter]);
        
    my_author_slides.addChild(my_author);
        
    my_author.wordWrap true;
        
    my_author.my_textX;
        
    my_author.= (my_textY my_textHeight 10);
        
    my_author.width my_textWidth;

        
        
    my_tweens_array[2] = new Tween (my_author,"alpha",Strong.easeOut,0,1,4,true);
        
        
        
        
    }

    //=====================================================================================================
    //Here we make a timer to make our images change after a specified time
    //=====================================================================================================

    function timerListener (e:TimerEvent):void
    {
        
        
    hidePrev();
        
        
    my_playback_counter++;
        
        if (
    my_playback_counter == my_total)
        {
            
    my_playback_counter =0;
        }
            
        
    nextImage();

    }

    //=====================================================================================================
    //Here we hide the previous message
    //=====================================================================================================

    function hidePrev():void
    {

        var 
    my_image:Loader=Loader(my_image_slides.getChildAt(0)); 
        
    my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
        
    my_prev_tween.addEventListener(TweenEvent.MOTION_FINISHonFadeOut)
        
        var 
    my_label:TextField=TextField(my_label_slides.getChildAt(0)); 
        
    my_tweens_array[3] = new Tween(my_label,"alpha",Strong.easeOut,1,0,1,true); 
        
        var 
    my_author:TextField=TextField(my_author_slides.getChildAt(0));
        new 
    Tween(my_author,"alpha",Strong.easeOut,1,0,1,true);

    }

    function 
    onFadeOut(e:TweenEvent):void
    {
        
        
    my_image_slides.removeChildAt(0);
        
    my_label_slides.removeChildAt(0);
        
    my_author_slides.removeChildAt(0);



  4. #4
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    so you're basically just worried about images, right? if an image isn't found, then skip that step entirely? no textfields or anything, just continue processing as if that node didn't exist... correct?

  5. #5
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    Yeah but next each image is a textfield and I want that to move to cover the area where the image should be, which would be no problem If this is fixed with a event listener i guess.

  6. #6
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    you could so something like this:

    PHP Code:
    my_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRORmissingImagefalse0true);
    //  later...
    private function missingImage(event:IOErrorEvent):void{
      
    // do whatever...

    that'd be right around where you're assigning the complete listener to my_loader in your loop.

    also, just some advice - you don't need to re-instance those fonts during each iteration - i'd take the font instantiation out of the loop... also, you could break down that @FONTFAMILY / @AUTHORFONT if stack to a switch statement, or better yet a map... e.g.,

    PHP Code:
    // outside the loop
    var fontMap:Object = {
        
    "Imact" F1.fontName,
        
    "Times New Roman" F2.fontName,
        ... 
    etc
    }

    // in the loop
    my_format.font fontMap[my_images[i].@FONTFAMILY];
    my_Aformat.font fontMap[my_images[i].@AUTHORFONT]; 

  7. #7
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    wow thanks Am gonna try that and I'll update you with the results!

  8. #8
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    I can't seem to find a place for the loader code to work any suggestions? srry for the beginner questions >_<

    Edit:
    The font thing worked great thanks!
    Last edited by Rkokie; 12-08-2010 at 11:53 AM.

  9. #9
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    put the my_loader.contentLoaderInfo.addEventListener on the line before or after the existing line of the same...

    PHP Code:
    var my_url:String my_images[i].@URL
    var 
    my_loader:Loader = new Loader(); 
    my_loader.load(new URLRequest(my_url)); 
    my_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRORmissingImagefalse0true);
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETEonComplete); 
    my_loaders_array.push(my_loader); 
    then put the function (missingImage) with the other private/public functions.

  10. #10
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    srry but I don't have any other private/public functions and if I use yours with the private in front of it it gives me an error:
    Scene 1, Layer 'actionscript', Frame 1, Line 192 1013: The private attribute may be used only on class property definitions.

    I have tried to put it this way now:
    function missingImage(e:IOErrorEvent):void
    {
    my_textX_array[my_playback_counter].x -150;
    }

    just above the onComplete function.

    Edit:
    I have just checked for private/public functions, but I'm not using a package, should I or can I just keep it like this and not use them?
    Last edited by Rkokie; 12-09-2010 at 06:22 AM.

  11. #11
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    if you're not using classes, you don't need private/public - what you have for the missingImage function is fine.

    but - something else is going to give you a problem. that event is going to fire after some time has passed - just like the COMPLETE event fires after everything else in that loop happens - which will be after all the other code executes. so my_playback_counter is going to be the very last value it was set at, for each error event that fires. you need to find a way to match the erroring instance to the textfield you want to move.

  12. #12
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    wow and this is quite complicated right? I just can't find a way to make it move that textfield that is on the same slide as the no url image, sorry to be such a hardass but I've been working on this for a few hours already and I can't get it clear.

  13. #13
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    i obviously don't have the rest of your package, so i can't test this, but in theory it should work. the changes i made are marked with a comment starting like so:

    PHP Code:
    // *FK* whatever... 
    i also changed the font thing...

    PHP Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    import flash.sampler.NewObjectSample;
    import flash.display.Sprite;
    import flashx.textLayout.elements.OverflowPolicy;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFormat;

    stage.scaleMode StageScaleMode.NO_SCALE;//preventing to stretch when embedded 

    //===================================================================================================== 
    //Here we make a var for everything we are gonna import from the xml etc. 
    //===================================================================================================== 
    var my_speed:Number;// the var where our transition speed will be put in 
    var my_total:Number;// the var where the amount of images will be put in 
    var my_images:XMLList;// the var where our image settings will be stored 

    var my_loaders_array:Array = [];// Array where all images are stored 
    var my_labels_array:Array = [];// Array where all Texts are stored 
    var my_authors_array:Array = [];// Array where we will store our authors 

    // Arrays where all the width/height, x and y values are gonna be stored 
    var my_textWidth_array:Array = [];
    var 
    my_textHeight_array:Array = [];
    var 
    my_textX_array:Array = [];
    var 
    my_textY_array:Array = [];
    //======== 
    var my_imgWidth_array:Array = [];
    var 
    my_imgHeight_array:Array = [];
    var 
    my_imgX_array:Array = [];
    var 
    my_imgY_array:Array = [];
    // End of the arrays with values 

    var my_success_counter:Number 0;// counter to check if everything is loaded 
    var my_playback_counter:Number 0;// counter to go to the next message 

    var my_slideshow:Sprite = new Sprite();// container for our total slideshow 
    var my_image_slides:Sprite = new Sprite();// container for our images 
    var my_label_slides:Sprite = new Sprite();// container for our texts 
    var my_author_slides:Sprite = new Sprite();// container for our authors 

    var my_preloader:TextField;// here we add a preloader 

    var my_timer:Timer;// making a timer 
    var my_prev_tween:Tween;// tween for removing our previous message 
    var my_tweens_array:Array = [];// making an array to store our tweens 

    var my_loaderinfo_array:Array = [];  // *FK* hold loader info objects to match up...



    //===================================================================================================== 
    //Here we import the xml file and make it process 
    //===================================================================================================== 

    var my_xml_loader:URLLoader = new URLLoader();
    my_xml_loader.load(new URLRequest("slideshow.xml"));
    my_xml_loader.addEventListener(Event.COMPLETEprocessXML);

    //===================================================================================================== 
    //Here the speed, image url's and the number of images are imported from the xml 
    //===================================================================================================== 

    function processXML(e:Event):void {

        var 
    my_xml:XML = new XML(e.target.data);
        
    my_speed=my_xml.@SPEED;// Getting our transition speed in seconds from the xml 

        
    my_images=my_xml.IMAGE;// Importing the slides 
        
    my_total=my_images.length();// counting the number of slides 
        
    loadImages();

        
    my_xml_loader.removeEventListener(Event.COMPLETEprocessXML);
        
    my_xml_loader null;



    }

    //===================================================================================================== 
    //Here we simply load the images and text's 
    //===================================================================================================== 

    var F1 = new Font1();
    var 
    F2 = new Font2();
    var 
    F3 = new Font3();
    var 
    F4 = new Font4();
    var 
    F5 = new Font5();
    var 
    F6 = new Font6();
    var 
    F7 = new Font7();
    var 
    F8 = new Font8();
    var 
    F9 = new Font9();
    var 
    F10 = new Font10();
    var 
    F11 = new Font11();
            
    var 
    fontMap:Object = {
        
    "Impact" F1.fontName
        
    "Times New Roman" F2.fontName
        
    "Verdana" F3.fontName
        
    "Brush Script MT" F4.fontName
        
    "Georgia" F5.fontName
        
    "Arial" F6.fontName
        
    "Trebuchet MS" F7.fontName
        
    "Webdings" F8.fontName
        
    "Andale Mono" F9.fontName
        
    "Arial Black" F10.fontName
        
    "Comic Sans MS" F11.fontName
    };

    function 
    loadImages():void {

        for (var 
    i:Number 0my_totali++) {

            var 
    my_format:TextFormat = new TextFormat();
            
    my_format.size my_images[i].@FONTSIZE;
            
    my_format.color my_images[i].@COLOR;
            
    my_format.font fontMap[my_images[i].@FONTFAMILY];

            var 
    my_Aformat:TextFormat = new TextFormat();
            
    my_Aformat.size my_images[i].@AUTHORSIZE;
            
    my_Aformat.color my_images[i].@AUTHORCOLOR;
            
    my_Aformat.font fontMap[my_images[i].@AUTHORFONT];
            
            var 
    my_url:String my_images[i].@URL;
            var 
    my_loader:Loader = new Loader();
            
    my_loader.load(new URLRequest(my_url));
            
    my_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRORmissingImagefalse0true); // *FK*
            
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETEonComplete);
            
    my_loaders_array.push(my_loader);
            
    my_loaderinfor_array.push(my_loader.contentLoaderInfo); // *FK*

            
    var my_txtWidth:Number;
            
    my_txtWidth my_images[i].@txtW;

            var 
    my_label:TextField = new TextField();
            
    my_label.defaultTextFormat my_format;
            
    my_label.text my_images[i].@TITLE;
            
    my_labels_array.push(my_label);



            var 
    my_author:TextField = new TextField();
            
    my_author.defaultTextFormat my_Aformat;
            
    my_author.text my_images[i].@AUTHOR;
            
    my_authors_array.push(my_author);

            
    // Pushing the text width/height, x and y into our arrays 
            
    var my_textWidth:Number = new Number();
            
    my_textWidth my_images[i].@txtW;
            
    my_textWidth_array.push(my_textWidth);
            var 
    my_textHeight:Number = new Number();
            
    my_textHeight my_images[i].@txtH;
            
    my_textHeight_array.push(my_textHeight);
            var 
    my_textX:Number = new Number();
            
    my_textX my_images[i].@txtX;
            
    my_textX_array.push(my_textX);
            var 
    my_textY:Number = new Number();
            
    my_textY my_images[i].@txtY;
            
    my_textY_array.push(my_textY);

            
    // Pushing the img width/height, x and y into our arrays 
            
    var my_imgWidth:Number = new Number();
            
    my_imgWidth my_images[i].@imgW;
            
    my_imgWidth_array.push(my_imgWidth);
            var 
    my_imgHeight:Number = new Number();
            
    my_imgHeight my_images[i].@imgH;
            
    my_imgHeight_array.push(my_imgHeight);
            var 
    my_imgX:Number = new Number();
            
    my_imgX my_images[i].@imgX;
            
    my_imgX_array.push(my_imgX);
            var 
    my_imgY:Number = new Number();
            
    my_imgY my_images[i].@imgY;
            
    my_imgY_array.push(my_imgY);

        }
        
    my_preloader = new TextField();
        
    my_preloader.text="Loading";
        
    my_preloader.autoSize TextFieldAutoSize.CENTER;
        
    my_preloader.= (stage.stageWidth my_preloader.width)/2;
        
    my_preloader.= (stage.stageHeight my_preloader.height)/2;
        
    addChild(my_preloader);

    }

    function 
    missingImage(event:IOErrorEvent):void// *FK*
        
    var ref:LoaderInfo event.currentTargt as LoaderInfo;
        var 
    position:uint my_loaderinfo_array.indexOf(ref);
        
    my_textX_array[position].-= 150// *FK*  - i assume you want it 150 less, so '-='.  if that's wrong and you want it to be 150, use '=' not '-='
    }

    function 
    onComplete(e:Event):void {
        
    my_success_counter++;
        if (
    my_success_counter == my_total) {
            
    startShow();
        }
        var 
    my_loaderInfo:LoaderInfo LoaderInfo(e.target);
        
    my_loaderInfo.removeEventListener(Event.COMPLETEonComplete);
    }

    //===================================================================================================== 
    //Here we add everything to the stage and specify our timer 
    //===================================================================================================== 

    function startShow():void {

        
    removeChild(my_preloader);
        
    my_preloader null;

        
    addChild(my_slideshow);
        
    my_slideshow.addChild(my_image_slides);
        
    my_slideshow.addChild(my_label_slides);
        
    my_slideshow.addChild(my_author_slides);

        
    nextImage();

        
    my_timer = new Timer(my_speed*1000);
        
    my_timer.addEventListener(TimerEvent.TIMERtimerListener);
        
    my_timer.start();

    }

    //===================================================================================================== 
    //All our settings for the next image are set here 
    //===================================================================================================== 

    function nextImage():void {

        var 
    my_image:Loader Loader(my_loaders_array[my_playback_counter]);
        var 
    my_imgWidth:Number Number(my_imgWidth_array[my_playback_counter]);
        var 
    my_imgHeight:Number Number(my_imgHeight_array[my_playback_counter]);
        var 
    my_imgX:Number Number(my_imgX_array[my_playback_counter]);
        var 
    my_imgY:Number Number(my_imgY_array[my_playback_counter]);
        
    my_image_slides.addChild(my_image);

        
    my_image.my_imgX;
        
    my_image.my_imgY;
        
    my_image.width my_imgWidth;
        
    my_image.height my_imgHeight;

        
    my_tweens_array[0] = new Tween(my_image,"alpha",Strong.easeOut,0,1,4,true);

        var 
    my_label:TextField TextField(my_labels_array[my_playback_counter]);
        var 
    my_textWidth:Number Number(my_textWidth_array[my_playback_counter]);
        var 
    my_textHeight:Number Number(my_textHeight_array[my_playback_counter]);
        var 
    my_textX:Number Number(my_textX_array[my_playback_counter]);
        var 
    my_textY:Number Number(my_textY_array[my_playback_counter]);
        
    my_label_slides.addChild(my_label);
        
    my_label.wordWrap true;
        
    my_label.width my_textWidth;
        
    my_label.height my_textHeight;
        
    my_label.my_textX;
        
    my_label.my_textY;


        
    my_tweens_array[1] = new Tween(my_label,"alpha",Strong.easeOut,0,1,4,true);

        var 
    my_author:TextField TextField(my_authors_array[my_playback_counter]);
        
    my_author_slides.addChild(my_author);
        
    my_author.wordWrap true;
        
    my_author.my_textX;
        
    my_author.= (my_textY my_textHeight 10);
        
    my_author.width my_textWidth;


        
    my_tweens_array[2] = new Tween (my_author,"alpha",Strong.easeOut,0,1,4,true);




    }

    //===================================================================================================== 
    //Here we make a timer to make our images change after a specified time 
    //===================================================================================================== 

    function timerListener(e:TimerEvent):void {

        
    hidePrev();

        
    my_playback_counter++;

        if (
    my_playback_counter == my_total) {
            
    my_playback_counter =0;
        }
        
    nextImage();

    }

    //===================================================================================================== 
    //Here we hide the previous message 
    //===================================================================================================== 

    function hidePrev():void {

        var 
    my_image:Loader=Loader(my_image_slides.getChildAt(0));
        
    my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
        
    my_prev_tween.addEventListener(TweenEvent.MOTION_FINISHonFadeOut);
        var 
    my_label:TextField=TextField(my_label_slides.getChildAt(0));
        
    my_tweens_array[3] = new Tween(my_label,"alpha",Strong.easeOut,1,0,1,true);

        var 
    my_author:TextField=TextField(my_author_slides.getChildAt(0));
        new 
    Tween(my_author,"alpha",Strong.easeOut,1,0,1,true);

    }

    function 
    onFadeOut(e:TweenEvent):void {

        
    my_image_slides.removeChildAt(0);
        
    my_label_slides.removeChildAt(0);
        
    my_author_slides.removeChildAt(0);



  14. #14
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    I had changed the font thing already to your advice but thanks,

    now I have added your things but its telling me that it can't find a property x at Number and there is no standart value < badly translated its a error message but is in dutch :/
    ReferenceError: Error #1069

    well this is my code now, once again thanks for all your effort
    PHP Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import fl.transitions.TweenEvent;
    import flash.sampler.NewObjectSample;
    import flash.display.Sprite;
    import flashx.textLayout.elements.OverflowPolicy;
    import flash.events.Event;
    import flash.text.TextField;
    import flash.text.TextFormat;

    stage.scaleMode StageScaleMode.NO_SCALE//preventing to stretch when embedded

    //=====================================================================================================
    //Here we make a var for everything we are gonna import from the xml etc.
    //=====================================================================================================
    var my_speed:Number// the var where our transition speed will be put in
    var my_total:Number// the var where the amount of images will be put in
    var my_images:XMLList// the var where our image settings will be stored

    var my_loaders_array:Array = []; // Array where all images are stored
    var my_labels_array:Array = []; // Array where all Texts are stored
    var my_authors_array:Array = []; // Array where we will store our authors

    // Arrays where all the width/height, x and y values are gonna be stored
    var my_textWidth_array:Array = [];
    var 
    my_textHeight_array:Array = [];
    var 
    my_textX_array:Array = [];
    var 
    my_textY_array:Array = [];
    //========
    var my_imgWidth_array:Array = [];
    var 
    my_imgHeight_array:Array = [];
    var 
    my_imgX_array:Array = [];
    var 
    my_imgY_array:Array = [];
    // End of the arrays with values

    var my_success_counter:Number 0// counter to check if everything is loaded
    var my_playback_counter:Number 0// counter to go to the next message

    var my_slideshow:Sprite = new Sprite(); // container for our total slideshow
    var my_image_slides:Sprite = new Sprite(); // container for our images
    var my_label_slides:Sprite = new Sprite(); // container for our texts
    var my_author_slides:Sprite = new Sprite(); // container for our authors

    var my_preloader:TextField// here we add a preloader

    var my_timer:Timer// making a timer
    var my_prev_tween:Tween// tween for removing our previous message
    var my_tweens_array:Array = []; // making an array to store our tweens

    var my_loaderinfo_array:Array = [];  // *FK* hold loader info objects to match up...


    //adding our fonts from the library to actionscript
            
    var F1 = new Font1();
            var 
    F2 = new Font2();
            var 
    F3 = new Font3();
            var 
    F4 = new Font4();
            var 
    F5 = new Font5();
            var 
    F6 = new Font6();
            var 
    F7 = new Font7();
            var 
    F8 = new Font8();
            var 
    F9 = new Font9();
            var 
    F10 = new Font10();
            var 
    F11 = new Font11();
    //making an object to store the fonts
    var fontMap:Object 
    {
        
    "Impact" F1.fontName,
        
    "Times New Roman (standard)" F2.fontName,
        
    "Verdana" F3.fontName,
        
    "Brush Script MT" F4.fontName,
        
    "Georgia:" F5.fontName,
        
    "Arial" F6.fontName,
        
    "Trebuchet MS" F7.fontName,
        
    "Webdings" F8.fontName,
        
    "Andale Mono" F9.fontName,
        
    "Arial Black" F10.fontName,
        
    "Comic Sans MS" F11.fontName
    }





    //=====================================================================================================
    //Here we import the xml file and make it process
    //=====================================================================================================

    var my_xml_loader:URLLoader = new URLLoader();
    my_xml_loader.load(new URLRequest("slideshow.xml"));
    my_xml_loader.addEventListener(Event.COMPLETEprocessXML);

    //=====================================================================================================
    //Here the speed, image url's and the number of images are imported from the xml
    //=====================================================================================================

    function processXML (e:Event):void
    {
        
        var 
    my_xml:XML = new XML(e.target.data);
        
    my_speed=my_xml.@SPEED// Getting our transition speed in seconds

        
    my_images=my_xml.IMAGE// Importing the slides
        
    my_total=my_images.length(); // counting the number of slides
        
        
    loadImages();
        
        
    my_xml_loader.removeEventListener(Event.COMPLETEprocessXML); 
        
    my_xml_loader null;
        

        
    }

    //=====================================================================================================
    //Here we simply load the images and text's
    //=====================================================================================================

    function loadImages():void
    {
        
        for (var 
    i:Number 0my_totali++)
        { 
        
            var 
    my_format:TextFormat = new TextFormat();    
            
    my_format.size my_images[i].@FONTSIZE;
            
    my_format.color my_images[i].@COLOR;
        
            var 
    my_Aformat:TextFormat = new TextFormat();
            
    my_Aformat.size my_images[i].@AUTHORSIZE;
            
    my_Aformat.color my_images[i].@AUTHORCOLOR;
            
            
    my_format.font fontMap[my_images[i].@FONTFAMILY];
            
    my_Aformat.font fontMap[my_images[i].@AUTHORFONT];
            
            var 
    my_url:String my_images[i].@URL;
            var 
    my_loader:Loader = new Loader();
            
    my_loader.load(new URLRequest(my_url));
            
    my_loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERRORmissingImagefalse0true);
            
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETEonComplete);
            
    my_loaders_array.push(my_loader);
            
    my_loaderinfo_array.push(my_loader.contentLoaderInfo); // *FK*

            
                    
            
    var my_label:TextField = new TextField();
            
    my_label.defaultTextFormat my_format;
            
    my_label.text my_images[i].@TITLE;
            
    my_labels_array.push(my_label);

        
            
            var 
    my_author:TextField = new TextField();
            
    my_author.defaultTextFormat my_Aformat;
            
    my_author.text my_images[i].@AUTHOR;
            
    my_authors_array.push(my_author);
            
            
    // Pushing the text width/height, x and y into our arrays
            
    var my_textWidth:Number = new Number();
            
    my_textWidth my_images[i].@txtW;
            
    my_textWidth_array.push(my_textWidth);
            var 
    my_textHeight:Number = new Number();
            
    my_textHeight my_images[i].@txtH;
            
    my_textHeight_array.push(my_textHeight);
            var 
    my_textX:Number = new Number();
            
    my_textX my_images[i].@txtX;
            
    my_textX_array.push(my_textX);
            var 
    my_textY:Number = new Number();
            
    my_textY my_images[i].@txtY;
            
    my_textY_array.push(my_textY);
            
            
    // Pushing the img width/height, x and y into our arrays
            
    var my_imgWidth:Number = new Number();
            
    my_imgWidth my_images[i].@imgW;
            
    my_imgWidth_array.push(my_imgWidth);
            var 
    my_imgHeight:Number = new Number();
            
    my_imgHeight my_images[i].@imgH;
            
    my_imgHeight_array.push(my_imgHeight);
            var 
    my_imgX:Number = new Number();
            
    my_imgX my_images[i].@imgX;
            
    my_imgX_array.push(my_imgX);
            var 
    my_imgY:Number = new Number();
            
    my_imgY my_images[i].@imgY;
            
    my_imgY_array.push(my_imgY);
            
        }
        
        
    my_preloader = new TextField();
        
    my_preloader.text="Loading";
        
    my_preloader.autoSize TextFieldAutoSize.CENTER;
        
    my_preloader.= (stage.stageWidth my_preloader.width)/2;
        
    my_preloader.= (stage.stageHeight my_preloader.height)/2;
        
    addChild(my_preloader);

    }

    function 
    missingImage(event:IOErrorEvent):void// *FK*
        
    var ref:LoaderInfo event.currentTarget as LoaderInfo;
        var 
    position:uint my_loaderinfo_array.indexOf(ref);
        
    my_textX_array[position].-= 150// *FK*  - i assume you want it 150 less, so '-='.  if that's wrong and you want it to be 150, use '=' not '-='
    }


    function 
    onComplete(e:Event):void
    {
        
    my_success_counter++;
        if (
    my_success_counter == my_total)
        {
            
    startShow();
        }
        
        var 
    my_loaderInfo:LoaderInfo LoaderInfo(e.target); 
        
    my_loaderInfo.removeEventListener(Event.COMPLETEonComplete);
    }

    //=====================================================================================================
    //Here we add everything to the stage and specify our timer
    //=====================================================================================================

    function startShow():void
    {
        
        
    removeChild(my_preloader);
        
    my_preloader null;
        
        
    addChild(my_slideshow);
        
    my_slideshow.addChild(my_image_slides);
        
    my_slideshow.addChild(my_label_slides);
        
    my_slideshow.addChild(my_author_slides);
        
        
    nextImage();
        
        
    my_timer = new Timer(my_speed*1000);
        
    my_timer.addEventListener(TimerEvent.TIMERtimerListener); 
        
    my_timer.start();
        
    }

    //=====================================================================================================
    //All our settings for the next image are set here
    //=====================================================================================================

    function nextImage():void
    {

        var 
    my_image:Loader Loader(my_loaders_array[my_playback_counter]);
        var 
    my_imgWidth:Number Number(my_imgWidth_array[my_playback_counter]);
        var 
    my_imgHeight:Number Number(my_imgHeight_array[my_playback_counter]);
        var 
    my_imgX:Number Number(my_imgX_array[my_playback_counter]);
        var 
    my_imgY:Number Number(my_imgY_array[my_playback_counter]);
        
    my_image_slides.addChild(my_image); 
        
        
        
        
        
    my_image.my_imgX;
        
    my_image.my_imgY;
        
    my_image.width my_imgWidth;
        
    my_image.height my_imgHeight;
        
        
    my_tweens_array[0] = new Tween(my_image,"alpha",Strong.easeOut,0,1,4,true);
        
        var 
    my_label:TextField TextField(my_labels_array[my_playback_counter]);
        var 
    my_textWidth:Number Number(my_textWidth_array[my_playback_counter]);
        var 
    my_textHeight:Number Number(my_textHeight_array[my_playback_counter]);
        var 
    my_textX:Number Number(my_textX_array[my_playback_counter]);
        var 
    my_textY:Number Number(my_textY_array[my_playback_counter]);
        
    my_label_slides.addChild(my_label);
        
    my_label.wordWrap true;
        
    my_label.width my_textWidth;
        
    my_label.height my_textHeight;
        
    my_label.my_textX;
        
    my_label.my_textY;
        
        
        
    my_tweens_array[1] = new Tween(my_label,"alpha",Strong.easeOut,0,1,4,true);
        
        var 
    my_author:TextField TextField(my_authors_array[my_playback_counter]);
        
    my_author_slides.addChild(my_author);
        
    my_author.wordWrap true;
        
    my_author.my_textX;
        
    my_author.= (my_textY my_textHeight 10);
        
    my_author.width my_textWidth;

        
        
    my_tweens_array[2] = new Tween (my_author,"alpha",Strong.easeOut,0,1,4,true);
        

        
        
    }

    //=====================================================================================================
    //Here we make a timer to make our images change after a specified time
    //=====================================================================================================

    function timerListener (e:TimerEvent):void
    {
        
        
    hidePrev();
        
        
    my_playback_counter++;
        
        if (
    my_playback_counter == my_total)
        {
            
    my_playback_counter =0;
        }
            
        
    nextImage();

    }

    //=====================================================================================================
    //Here we hide the previous message
    //=====================================================================================================

    function hidePrev():void
    {

        var 
    my_image:Loader=Loader(my_image_slides.getChildAt(0)); 
        
    my_prev_tween = new Tween(my_image,"alpha",Strong.easeOut,1,0,1,true);
        
    my_prev_tween.addEventListener(TweenEvent.MOTION_FINISHonFadeOut)
        
        var 
    my_label:TextField=TextField(my_label_slides.getChildAt(0)); 
        
    my_tweens_array[3] = new Tween(my_label,"alpha",Strong.easeOut,1,0,1,true); 
        
        var 
    my_author:TextField=TextField(my_author_slides.getChildAt(0));
        new 
    Tween(my_author,"alpha",Strong.easeOut,1,0,1,true);

    }

    function 
    onFadeOut(e:TweenEvent):void
    {
        
        
    my_image_slides.removeChildAt(0);
        
    my_label_slides.removeChildAt(0);
        
    my_author_slides.removeChildAt(0);


    Edit:
    maybe a translator can give a more accurate translation for the error:

    ReferenceError: Error # 1069: Can not find the x property of Number and there is no default value.
    at My_Slideshow_fla::maintimeline/missing image()
    Last edited by Rkokie; 12-09-2010 at 02:28 PM.

  15. #15
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    apparently my_textX_array is an array of numbers... you were trying to assign the x value, so i assumed it was display objects.

    try changing this line in the missingImage function:

    PHP Code:
    my_textX_array[position].-= 150
    to this:

    PHP Code:
    my_textX_array[position] -= 150
    again, that's assuming you want to reduce the current value by 150, which is what it looked like you wanted. if you want to set it to 150, change -= to =

  16. #16
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    offcourse, its a value not a coördinate, thanks man. but now somehow when I started up flash today it just doesn't load the texts etc. anymore

    I have just tried to put a valid url in for the image and it works then, the IOErrorEvent makes it just skip it and continue loading the rest right? somehow it doesn't load the rest of the texts so it keeps on loading
    Last edited by Rkokie; 12-10-2010 at 07:34 AM.

  17. #17
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    Any Idea what to do now? :/

  18. #18
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    it's hard to debug blind. can you upload your source file package (incl. xml and images)?

    doesn't have to be complete, but enough to work with...

  19. #19
    Junior Member
    Join Date
    Dec 2010
    Posts
    18
    K here it is,

    can you tell me when you got it so I can remove it again? greatly appreciated
    Last edited by Rkokie; 12-10-2010 at 05:11 PM.

  20. #20
    ___________________
    Join Date
    May 2004
    Posts
    3,174
    i've got it download, so feel free to remove it. i probably won't have a chance to do anything with it until this evening tho

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