A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: xml gallery flash

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    5

    xml gallery flash

    I'm working on a flashsite with a xml gallery , the problem is when i change the scene , the gallery is always there in all scenes and i don't want to make it in separated swf!! What can i do to "unload" the xml? if is it posible?

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    the xml is not the problem. xml simply brings external data into Flash.

    look at how your gallery is built up.
    are you using createMovieClip or MovieclipLoader class ?
    if so, use removeMovieClip to destroy those clips.

  3. #3
    Junior Member
    Join Date
    Oct 2001
    Posts
    5

    thanks modified dog but don't understand it well...

    here is the code :

    stop();
    var folder:String = "thumbnails/";
    var total:Number;
    var radiusX:Number = 300;
    var radiusY:Number = 100;
    var centerX:Number = 500;
    var centerY:Number = 450;
    var speed:Number = 0.015;
    tn_group_mc._visible = false;
    fm_label.text = ""; fm_url.text = "";

    var xml:XML = new XML();
    xml.ignoreWhite = true;

    xml.onLoad = function()
    {
    var nodes = this.firstChild.childNodes;
    total = nodes.length;

    for( var i=0; i < total; i++)
    {
    var t = tn_group_mc.duplicateMovieClip("tn"+i, i);
    t.angle = i * ((Math.PI*2)/total);
    t.onEnterFrame = mover;
    t.tn_mc.inner.loadMovie( folder + nodes[i].attributes.filename );
    t.tn_reflection_mc.inner.loadMovie( folder + nodes[i].attributes.filename );
    t.fm_label = nodes[i].attributes.label;
    t.fm_url = nodes[i].attributes.url;

    t.fm_button.onRollOver = function()
    {
    fm_label.text = "Titulo: " + this._parent.fm_label;
    fm_url.text = "URL: " + this._parent.fm_url;
    }
    t.fm_button.onRollOut = function()
    {
    fm_label.text = "";
    fm_url.text = "";
    }
    t.fm_button.onRelease = function()
    {
    getURL(this._parent.fm_url);
    }
    }
    }
    xml.load( folder + "thumbnails.xml");

    function mover()
    {
    this._x = Math.cos(this.angle) * radiusX + centerX;
    this._y = Math.sin(this.angle) * radiusY + centerY;
    var s = this._y /(centerY+radiusY);
    this._xscale = this._yscale = s*100;
    this.angle += this._parent.speed;
    this.swapDepths(Math.round(this._xscale) + 100);
    }
    this.onMouseMove = function()
    {
    speed = (this._xmouse-centerX) * 0.0001;
    }

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    to remove clips -

    PHP Code:
    tn_group_mc.removeMovieClip();

     for(var 
    i=0100i++){
    this["tn"+i].removeMovieClip();


  5. #5
    Junior Member
    Join Date
    Oct 2001
    Posts
    5
    it doesn't work or i can't make it work!
    how can i use that code? where ?

  6. #6
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    where ?

    add it to the code you use to change scenes

    use Test Movie / List Variables to show the instance names of all duplicated movieclips
    remove all clips with those instance names (the for(loop) should do that)

  7. #7
    Junior Member
    Join Date
    Feb 2009
    Posts
    9

    Issue with my Flash gallery also

    I inserted a Flash gallery into my Flash website. Copied all the layers and actions and it works. One issue though is the gallery pictures remain, the text and description goes away not the photos.
    I have checked it all and cannot figure it out.
    The website is posted at www.greenhousegraphix.com/trial

    The action for the frame is:

    // Copyright © flashmo.com
    // Developed by Min Thu

    stop();
    import fl.transitions.Tween;
    import fl.transitions.TweenEvent;
    import fl.transitions.easing.*;

    var filename_list = new Array();
    var url_list = new Array();
    var url_target_list:Array = new Array();
    var title_list = new Array();
    var description_list = new Array();

    var i:Number;
    var tn:Number = 0;
    var tween_duration:Number = 0.4;

    var fm_tween:Tween;
    var total:Number;
    var flashmo_xml:XML = new XML();
    var folder:String = "photos/";
    var xml_loader:URLLoader = new URLLoader();
    xml_loader.load(new URLRequest("flashmo_130_photo_list.xml"));
    xml_loader.addEventListener(Event.COMPLETE, create_thumbnail);

    var thumbnail_group:MovieClip = new MovieClip();
    stage.addChild(thumbnail_group);

    thumbnail_group.x = tn_group.x;
    var default_y:Number = thumbnail_group.y = tn_group.y;

    tn_group.visible = false;
    url_button.visible = false;
    tn_title.text = "";
    tn_desc.text = "";
    tn_url.text = "";
    tn_url_target.text = "";

    function create_thumbnail(e:Event):void
    {
    flashmo_xml = XML(e.target.data);
    total = flashmo_xml.thumbnail.length();

    for( i = 0; i < total; i++ )
    {
    filename_list.push( flashmo_xml.thumbnail[i].@filename.toString() );
    url_list.push( flashmo_xml.thumbnail[i].@url.toString() );
    url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );
    title_list.push( flashmo_xml.thumbnail[i].@title.toString() );
    description_list.push( flashmo_xml.thumbnail[i].@description.toString() );
    }
    load_tn();
    }

    function load_tn():void
    {
    var pic_request:URLRequest = new URLRequest( folder + filename_list[tn] );
    var pic_loader:Loader = new Loader();

    pic_loader.load(pic_request);
    pic_loader.contentLoaderInfo.addEventListener(Even t.COMPLETE, on_loaded);
    tn++;
    }

    function on_loaded(e:Event):void
    {
    if( tn < total )
    {
    load_tn();
    tn_desc.text = "Loading " + tn + " of " + total + " photos";
    }
    else
    {
    tn_title.text = title_list[0];
    tn_desc.text = description_list[0];
    tn_url.text = url_list[0];
    tn_url_target.text = url_target_list[0];

    var mc:MovieClip = MovieClip( thumbnail_group.getChildAt(total-2) );
    mc.addEventListener( MouseEvent.CLICK, go_out );
    new Tween(mc, "rotation", Bounce.easeOut, mc.rotation, 0, tween_duration, true);
    url_button.visible = true;
    url_button.addEventListener(MouseEvent.CLICK, goto_URL);
    }

    var flashmo_bm:Bitmap = new Bitmap();
    var flashmo_mc:MovieClip = new MovieClip();

    flashmo_bm = Bitmap(e.target.content);
    flashmo_bm.x = - flashmo_bm.width * 0.5;
    flashmo_bm.y = - flashmo_bm.height * 0.5;
    flashmo_bm.smoothing = true;

    var bg_width = flashmo_bm.width + 14;
    var bg_height = flashmo_bm.height + 14;

    flashmo_mc.addChild(flashmo_bm);
    flashmo_mc.graphics.lineStyle(1, 0x666666);
    flashmo_mc.graphics.beginFill(0xFFFFFF);
    flashmo_mc.graphics.drawRect( - bg_width * 0.5, - bg_height * 0.5, bg_width, bg_height );
    flashmo_mc.graphics.endFill();

    flashmo_mc.name = "flashmo_" + thumbnail_group.numChildren;

    new Tween(flashmo_mc, "x", Strong.easeOut, 200, Math.random() * 20 - 10, tween_duration * 2, true);
    new Tween(flashmo_mc, "y", Strong.easeOut, -300, Math.random() * 20 - 10, tween_duration * 2, true);
    new Tween(flashmo_mc, "rotation", Strong.easeOut, 60, Math.random() * 30 - 15, tween_duration * 2, true);

    thumbnail_group.addChildAt(flashmo_mc, 0);
    }

    function go_out(e:MouseEvent):void
    {
    var mc:MovieClip = MovieClip(e.target);
    mc.removeEventListener( MouseEvent.CLICK, go_out );

    fm_tween = new Tween(mc, "x", Strong.easeIn, mc.x, 100, tween_duration, true);
    fm_tween.addEventListener(TweenEvent.MOTION_FINISH , go_in);
    new Tween(mc, "y", Strong.easeIn, mc.y, -180, tween_duration, true);
    }

    function go_in(te:TweenEvent):void
    {
    var mc:MovieClip = MovieClip( thumbnail_group.getChildAt(total-1) );
    var s_no:Number = parseInt( mc.name.slice(8,10) ) + 1;
    if(s_no == total) s_no = 0;

    fm_tween = new Tween(mc, "x", Strong.easeOut, mc.x, Math.random() * 20 - 10, tween_duration, true);
    fm_tween.addEventListener(TweenEvent.MOTION_FINISH , add_click);
    new Tween(mc, "y", Strong.easeOut, mc.y, Math.random() * 20 - 10, tween_duration, true);
    new Tween(mc, "rotation", Regular.easeOut, mc.rotation, Math.random() * 30 - 15, tween_duration, true);

    thumbnail_group.addChildAt( mc, 0 );

    tn_title.text = title_list[s_no];
    tn_desc.text = description_list[s_no];
    tn_url.text = url_list[s_no];
    tn_url_target.text = url_target_list[s_no];
    }

    function add_click(te:TweenEvent):void
    {
    var mc:MovieClip = MovieClip(thumbnail_group.getChildAt(total-1) );
    mc.addEventListener( MouseEvent.CLICK, go_out );
    new Tween(mc, "rotation", Bounce.easeOut, mc.rotation, 0, tween_duration, true);
    }

    function goto_URL(me:MouseEvent)
    {
    navigateToURL(new URLRequest(tn_url.text), tn_url_target.text);
    }

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