dcsimg
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Popup windows from xml?

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3

    Popup windows from xml?

    Hi, I used Flash a wee bit several years ago, but now with AS3 I'm a bit out of my depths... Anyway I have this template I'm adapting, and at the moment it is a thumbnail gallery that loads via an external xml file, and the fullsize image it loads is a link to an html file. The only thing is that it loads the html file in a new window and I want it to load in a popup window. I have figured out how to make a regular popup window using AS3 but that doesn´t help me for this case as the actionscript is a bit more complex and going via the xml.... I have honestly spent a good 8 hours scouring the net for tutorials and nothing tells me exactky what I need to know to adapt my particular code.

    Here is the code in my actionscript that seems to be calling up the html link part of the xml file:

    function pic_click(e:MouseEvent):void
    {
    navigateToURL( new URLRequest( flashmo_tn_list[current_no].url ),
    flashmo_tn_list[current_no].target );
    }


    later the xml file looks like this:

    <thumbnails>
    <thumbnail>
    <filename>flashmo_173_film.jpg</filename>
    <title>Item No. 7 (173 film)</title>
    <description>Film template, free flash website </description>
    <url>http://www.flashmo.com/preview/flashmo_173_film</url>
    <target>_self</target>
    </thumbnail>
    </thumbnails>



    (of course there´s a lot more in the list but i just posted one here as an example).

    I can post more of the actionscript code if what I put here isn´t enough...I just didnt want to confuse things by posting the whole lot....

    My question is, is there a way to alter this code so that all the files in the xml will open as popups?

    Thank you!!!

    Anna

  2. #2
    Senior Member Computer Dork's Avatar
    Join Date
    Mar 2001
    Location
    St. Louis
    Posts
    1,026
    Is the URL the thumbnail image? Then it should work..

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    it works but it opens in a new tab. how can I make it open as a popup?

  4. #4
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    Anyone?

    here´s a link to the test site, for what it´s worth. The links o the images are still the default ones that came with the template, obviously I will change them later, but as you can see they load in a new window (or sometimes the same window), and I would much prefer them to load in a popup window:

    http://www.annagreve.com/marcos/marcos_site_08.html



    here´s the whole code in case it helps:

    import caurina.transitions.Tweener;

    var folder:String = "thumbnails/";
    var tn_width = flashmo_tn_small.width;
    var tn_height = flashmo_tn_small.height;
    var i:Number;
    var tn:Number = 0;
    var current_no:Number = 0;
    var no_of_column:Number = 4;
    var tween_duration:Number = 0.5; // seconds
    var total:Number;
    var flashmo_xml:XML;
    var flashmo_tn_list = new Array();
    var thumbnail_group:MovieClip = new MovieClip();

    this.addChild(thumbnail_group);
    this.addChild(tn_title);
    this.addChild(tn_description);

    thumbnail_group.mask = tn_group_area;
    thumbnail_group.x = flashmo_tn_small.x;
    thumbnail_group.y = flashmo_tn_small.y;
    flashmo_tn_small.visible = false;
    flashmo_tn_large.buttonMode = true;

    tn_title.text = "";
    tn_description.text = "";
    tn_info.text = "";
    flashmo_scrollbar.visible = false;

    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_thunbnail_grid);
    }

    function create_thunbnail_grid(e:Event):void
    {
    flashmo_xml = new XML(e.target.data);
    total = flashmo_xml.thumbnail.length();
    for( i = 0; i < total; i++ )
    {
    flashmo_tn_list.push( {
    filename: flashmo_xml.thumbnail[i].filename.toString(),
    title: flashmo_xml.thumbnail[i].title.toString(),
    description: flashmo_xml.thumbnail[i].description.toString(),
    url: flashmo_xml.thumbnail[i].url.toString(),
    target: flashmo_xml.thumbnail[i].target.toString()
    } );
    }
    load_tn();
    load_tn_large();
    }

    function load_tn_large():void
    {
    var pic_request:URLRequest = new URLRequest( folder + flashmo_tn_list[current_no].filename );
    var pic_loader:Loader = new Loader();
    pic_loader.load(pic_request);
    pic_loader.contentLoaderInfo.addEventListener(Prog ressEvent.PROGRESS, tn_large_progress);
    pic_loader.contentLoaderInfo.addEventListener(Even t.COMPLETE, tn_large_loaded);

    tn_title.text = flashmo_xml.thumbnail[current_no].title.toString();
    tn_description.text = flashmo_xml.thumbnail[current_no].description.toString();
    flashmo_tn_large.alpha = 0;
    }

    function tn_large_progress(e:ProgressEvent):void
    {
    var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
    tn_large_info.text = "Loading... " + percent + "%";
    }

    function tn_large_loaded(e:Event):void
    {
    tn_large_info.text = "";
    flashmo_tn_large.addChild( Bitmap(e.target.content) );
    Tweener.addTween( flashmo_tn_large, { alpha: 1, time: tween_duration, transition: "easeIn" } );
    }

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

    pic_loader.load(pic_request);
    pic_loader.contentLoaderInfo.addEventListener(Prog ressEvent.PROGRESS, tn_progress);
    pic_loader.contentLoaderInfo.addEventListener(Even t.COMPLETE, tn_loaded);
    tn++;
    }

    function tn_progress(e:ProgressEvent):void
    {
    var percent:Number = Math.round(e.bytesLoaded / e.bytesTotal * 100);
    tn_info.text = "Loading thumbnail... " + tn + " of " + total + " (" + percent + "%)";
    }

    function tn_loaded(e:Event):void
    {
    if( tn < total )
    {
    load_tn();
    }
    else
    {
    flashmo_scrollbar.visible = true;
    flashmo_scrollbar.scrolling("thumbnail_group", "tn_group_area", 0.35);
    tn_info.text = "";
    }

    var flashmo_tn_bm:Bitmap = new Bitmap();
    var flashmo_tn_mc:MovieClip = new MovieClip();

    flashmo_tn_bm = Bitmap(e.target.content);
    flashmo_tn_bm.smoothing = true;

    flashmo_tn_mc.addChild(flashmo_tn_bm);
    flashmo_tn_mc.width = tn_width;
    flashmo_tn_mc.height = tn_height;
    flashmo_tn_mc.name = "flashmo_tn_" + thumbnail_group.numChildren;
    flashmo_tn_mc.buttonMode = true;

    flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_OVER, tn_over );
    flashmo_tn_mc.addEventListener( MouseEvent.MOUSE_OUT, tn_out );
    flashmo_tn_mc.addEventListener( MouseEvent.CLICK, tn_click );

    flashmo_tn_mc.x = thumbnail_group.numChildren % no_of_column * ( tn_width + 10 );
    flashmo_tn_mc.y = Math.floor( thumbnail_group.numChildren / no_of_column ) * ( tn_height + 10 );

    thumbnail_group.addChild( flashmo_tn_mc );
    }

    function tn_over(e:MouseEvent):void
    {
    var mc:MovieClip = MovieClip(e.target);
    Tweener.addTween( mc, { alpha: 0.5, time: tween_duration, transition: "easeIn" } );
    }

    function tn_out(e:MouseEvent):void
    {
    var mc:MovieClip = MovieClip(e.target);
    Tweener.addTween( mc, { alpha: 1, time: tween_duration, transition: "easeOut" } );
    }

    function tn_click(e:MouseEvent):void
    {
    var mc:MovieClip = MovieClip(e.target);
    current_no = parseInt(mc.name.slice(11,13));

    Tweener.addTween( flashmo_tn_large, { alpha: 0, time: tween_duration,
    transition: "easeOut", onComplete: unload_tn_large } );
    }

    function unload_tn_large():void
    {
    flashmo_tn_large.removeChildAt(1);
    load_tn_large();
    }

    flashmo_tn_large.addEventListener( MouseEvent.MOUSE_OVER, pic_over );
    flashmo_tn_large.addEventListener( MouseEvent.MOUSE_OUT, pic_out );
    flashmo_tn_large.addEventListener( MouseEvent.CLICK, pic_click );

    function pic_over(e:MouseEvent):void
    {
    var mc:MovieClip = MovieClip(e.target);
    Tweener.addTween( mc, { alpha: 0.5, time: tween_duration, transition: "easeIn" } );
    }

    function pic_out(e:MouseEvent):void
    {
    var mc:MovieClip = MovieClip(e.target);
    Tweener.addTween( mc, { alpha: 1, time: tween_duration, transition: "easeOut" } );
    }

    function pic_click(e:MouseEvent):void
    {
    navigateToURL( new URLRequest( flashmo_tn_list[current_no].url ),
    flashmo_tn_list[current_no].target );
    }




    AND HERE THE XML:

    <?xml version="1.0" encoding="utf-8"?>
    <thumbnails>
    <thumbnail>
    <filename>flashmo_178_photo_tab.jpg</filename>
    <title>Item No. 1 (178 photo tab)</title>
    <description>Flash XML Photo Tab in ActionScript 3.0, Two versions horizontal or vertical thumbnail listing, auto play function</description>
    <url>http://www.flashmo.com/preview/flashmo_178_photo_tab</url>
    <target>_self</target>
    </thumbnail>
    <thumbnail>
    <filename>flashmo_177_particles.jpg</filename>
    <title>Item No. 2 (177 particles)</title>
    <description>Green Flash Particles, ActionScript 3 Flash Website, Particle Effects built on Tweener Transition Engine, Blue Background Color</description>
    <url>http://www.flashmo.com/preview/flashmo_177_particles</url>
    <target>_parent</target>
    </thumbnail>
    <thumbnail>
    <filename>flashmo_177_orange.jpg</filename>
    <title>Item No. 3 (177 orange)</title>
    <description>Orange Flash Particles, ActionScript 3 Flash Website, Particle Effects built on Tweener Transition Engine</description>
    <url>http://www.flashmo.com/preview/flashmo_177_orange</url>
    <target>_blank</target>
    </thumbnail>
    <thumbnail>
    <filename>flashmo_176_gift.jpg</filename>
    <title>Item No. 4 (176 gift)</title>
    <description>Gift shop flash template, simply attractive flash actionscript 3 website layout for gift and flower websites</description>
    <url>http://www.flashmo.com/preview/flashmo_176_gift</url>
    <target>_self</target>
    </thumbnail>
    <thumbnail>
    <filename>flashmo_175_photo_gallery.jpg</filename>
    <title>Item No. 5 (175 photo gallery)</title>
    <description>Flash photo gallery website with multiple XML files for multiple categories, fade in fade out transition effects, ActionScript 3</description>
    <url>http://www.flashmo.com/preview/flashmo_175_photo_gallery</url>
    <target>_parent</target>
    </thumbnail>

    </thumbnails>

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