IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ActionScript 3 Discussion :

Erreur 1009 Préchargment


Sujet :

ActionScript 3

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Profil pro
    Inscrit en
    Août 2009
    Messages
    1
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2009
    Messages : 1
    Par défaut Erreur 1009 Préchargment
    Bonjour

    je suis un débutant(graphiste) qui bidouille des sources afin de réaliser son site .

    J'ai donc créer un fichier avec une animation (par tween) d'un grand clip ("BG") comprenant plusieurs petits clips (notemment "works_mc")

    tout fonctionne parfaitement, seulement si j'insère un préchargment au début de ma timeline principale ce message s'affiche et tout Bug :


    TypeError: Error #1009: Il est impossible d'accéder à la propriété ou à la méthode d'une référence d'objet nul.
    at 31_fla::MainTimeline/CenterBG_Frame1()
    at 31_fla::MainTimeline/frame2()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at 31_fla::Works_mc_3()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at flash.display::MovieClip/nextFrame()
    at 31_fla::MainTimeline/updatePreloader()
    après de nombreuses recherches j'ai l'impression qu'il faut passer par un Event.ADDED_TO_STAGE mais comment s'en servir et pour l'insérer comment ?
    voici le code que j'insère pour précharger les éléments:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
     
    stop();
     
    //Preloader
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
     
    function updatePreloader(evtObj:ProgressEvent):void
    {
            //container for the progress of the site (download)
            var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
            preloader_txt.text = percent+"%";
            if (percent==100){
                    nextFrame();
            }
    }



    et voici le code insèré dans le clip Works_mc (trouvé sur ce site http://www.flashmo.c...photo_rotator):

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
     
     
    load_gallery("flashmo_183_photo_list.xml");
     
    // Copyright © flashmo.com
    // Developed by Min Thu
     
    // Tweener
    // http://code.google.com/p/tweener/
    import caurina.transitions.Tweener;
     
    var auto_play:Boolean = false;  // true (OR) false
    var auto_play_duration:Number = 1000; // 1 second equals 1000
    var folder:String = "photos/";
    var timer:Timer;
    var i:Number;
    var tn:Number = 0;
    var pic:Number = 0;
    var previous_no:Number = 0;
    var current_no:Number = 0;
    var tween_duration:Number = 0.8;        // seconds
    var total:Number;
    var flashmo_xml:XML;
    var flashmo_photo_list = new Array();
    var photo_group:MovieClip = new MovieClip();
     
    this.addChild(photo_group);
    this.addChild(photo_title);
    this.addChild(photo_description);
    this.addChild(photo_button);
    this.addChild(flashmo_play);
    this.addChild(flashmo_pause);
    this.addChild(flashmo_previous);
    this.addChild(flashmo_next);
     
     
    photo_button.alpha = 0;
    photo_button.buttonMode = true;
     
    photo_group.x = flashmo_photo_area.x;
    photo_group.y = flashmo_photo_area.y;
    photo_group.mask = flashmo_photo_area;
     
    photo_group_info.text = "";
    photo_title.text = "";
    photo_description.text = "";
     
    if( auto_play == true )
    {
            flashmo_pause.visible = true;
            flashmo_play.visible = false;
    }
    else
    {
            flashmo_pause.visible = false;
            flashmo_play.visible = true;
    }
     
    function load_gallery(xml_file:String):void
    {
            var xml_loader:URLLoader = new URLLoader();
            xml_loader.load( new URLRequest( xml_file ) );
            xml_loader.addEventListener(Event.COMPLETE, create_photo_rotator);
    }
     
    function create_photo_rotator(e:Event):void 
    {
            flashmo_xml = new XML(e.target.data);
            total = flashmo_xml.photo.length();
            for( i = 0; i < total; i++ )
            {
                    flashmo_photo_list.push( {
                            filename: flashmo_xml.photo[i].filename.toString(), 
                            title: flashmo_xml.photo[i].title.toString(), 
                            description: flashmo_xml.photo[i].description.toString(),
                            url: flashmo_xml.photo[i].url.toString(),
                            target: flashmo_xml.photo[i].target.toString()
                    } );
            }
            load_photo();
            photo_title.text = flashmo_xml.photo[0].title.toString();
            photo_description.text = flashmo_xml.photo[0].description.toString();
    }
     
    function load_photo():void
    {
            var pic_request:URLRequest = new URLRequest( folder + flashmo_photo_list[pic].filename );
            var pic_loader:Loader = new Loader();
            pic_loader.load(pic_request);
            pic_loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, on_photo_progress);
            pic_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, on_photo_loaded);
            pic++;
    }
     
    function on_photo_progress(e:ProgressEvent):void
    {
            var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
            photo_group_info.text = "Loading image... " + pic + " of " + total + " (" + percent + "%)";
    }
     
    function on_photo_loaded(e:Event):void
    {
            if( pic < total )
            {
                    load_photo();
            }
            else if( auto_play == true )
            {
                    photo_group_info.text = "";
     
                    timer = new Timer(auto_play_duration);
                    timer.addEventListener(TimerEvent.TIMER, auto_play_timer);
                    timer.start();
            }
            else
            {
                    photo_group_info.text = "";
            }
     
            var flashmo_pic_bm:Bitmap = new Bitmap();
            var flashmo_pic_mc:MovieClip = new MovieClip();
     
            flashmo_pic_bm = Bitmap(e.target.content);
            flashmo_pic_bm.smoothing = true;
     
            flashmo_pic_mc.addChild( flashmo_pic_bm );
            flashmo_pic_mc.name = "flashmo_pic_" + photo_group.numChildren;
     
            if( photo_group.numChildren > 0 )
                    flashmo_pic_mc.alpha = 0;
     
            photo_group.addChild( flashmo_pic_mc );
    }
     
    function auto_play_timer(te:TimerEvent):void
    {
            current_no++;
            change_photo();
    }
     
    function change_photo():void
    {
            if( current_no >= photo_group.numChildren ) 
                    current_no = 0;
            if( current_no < 0 )
                    current_no = photo_group.numChildren - 1;
     
            Tweener.addTween( photo_group.getChildAt(previous_no), { alpha: 0, time: tween_duration, 
                                              transition: "easeInOutQuart" } );
            Tweener.addTween( photo_group.getChildAt(current_no), { alpha: 1, time: tween_duration, 
                                              transition: "easeInOutQuart" } );
     
            previous_no = current_no;
            photo_title.text = flashmo_photo_list[current_no].title;
            photo_description.text = flashmo_photo_list[current_no].description;
    }
     
    photo_button.addEventListener( MouseEvent.MOUSE_OVER, pic_over );
    photo_button.addEventListener( MouseEvent.MOUSE_OUT, pic_out );
    photo_button.addEventListener( MouseEvent.CLICK, pic_click );
     
    function pic_over(e:MouseEvent):void
    {
            var mc:MovieClip = MovieClip(e.target);
            Tweener.addTween( mc, { alpha: 0.2, time: tween_duration, transition: "easeIn" } );
    }
     
    function pic_out(e:MouseEvent):void
    {
            var mc:MovieClip = MovieClip(e.target);
            Tweener.addTween( mc, { alpha: 0, time: tween_duration, transition: "easeOut" } );
    }
     
    function pic_click(e:MouseEvent):void
    {
            navigateToURL( new URLRequest( flashmo_photo_list[current_no].url ), 
                                                                    flashmo_photo_list[current_no].target );
    }
     
    flashmo_play.addEventListener( MouseEvent.CLICK, pic_play );
    flashmo_pause.addEventListener( MouseEvent.CLICK, pic_pause );
    flashmo_previous.addEventListener( MouseEvent.CLICK, pic_previous );
    flashmo_next.addEventListener( MouseEvent.CLICK, pic_next );
     
    function pic_play(e:MouseEvent):void
    {
            flashmo_pause.visible = true;
            flashmo_play.visible = false;
            timer = new Timer(auto_play_duration);
            timer.addEventListener(TimerEvent.TIMER, auto_play_timer);
            timer.start();
    }
     
    function pic_pause(e:MouseEvent):void
    {
            flashmo_pause.visible = false;
            flashmo_play.visible = true;
            timer.removeEventListener(TimerEvent.TIMER, auto_play_timer);
    }
     
    function pic_previous(e:MouseEvent):void
    {
            current_no--;
            change_photo();
    }
     
    function pic_next(e:MouseEvent):void
    {
            current_no++;
            change_photo();
    }
    Merci d'avance
    Bertrand

  2. #2
    Membre éprouvé
    Profil pro
    Développeur multimédia
    Inscrit en
    Juin 2009
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : Développeur multimédia

    Informations forums :
    Inscription : Juin 2009
    Messages : 130
    Par défaut
    Bonjour,

    le ADDED_TO_STAGE est renvoyé par un MovieClip ou Sprite lorsqu'il est ajouter sur la scène. Cet événement est envoyé en général après un addChild(), on l'utilise pour commencer des animations en étant sur d'être vu par l'utilisateur.

    L'utilisation est la suivante:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
     
    addEventListener(Event.ADDED_TO_STAGE, init);
     
    function init(e:Event):void{
      //mon animation est présente sur la scène je peux faire ce que je veux
    }
    Dans ton cas, il faut que les tweens interviennent une fois le clip chargé.

    Quelque chose me turlupine dans ton code. la variable loaderInfo, c'est quoi? Si tu charge un swf, il faut créer un loader, et écouter son contentLoaderInfo
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    loader = new Loader()
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
    loader.load(urlRequest);
    Et plutôt que d'utiliser un test pour savoir si le chargement est effectuer à 100%, je te conseil d'utiliser l'évenement complete qui est fait pour ça

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
    function completeHandler(e:Event):void{
      nextFrame();
    }
    d'ailleur qu'y a t'il dans ta fonction nextFrame?

Discussions similaires

  1. [Flex4] Problème Focus ? - Erreur Error #1009 sur Formulaires
    Par tlafont2607 dans le forum Flex
    Réponses: 1
    Dernier message: 18/03/2013, 15h04
  2. erreur 1009 apparue
    Par kapac dans le forum ActionScript 3
    Réponses: 1
    Dernier message: 13/04/2011, 12h41
  3. Réponses: 1
    Dernier message: 17/03/2011, 01h54
  4. Simple précision sur l'erreur #1009
    Par NoArgl dans le forum ActionScript 3
    Réponses: 0
    Dernier message: 19/11/2009, 20h15
  5. chargement de texte erreur 1009
    Par artnoz dans le forum ActionScript 3
    Réponses: 0
    Dernier message: 12/05/2008, 02h34

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo