View Full Version : Create this slider without XML?
westy2005
04-22-2010, 06:27 PM
Hello,
I was wondering if anyone knew or could point me in the direction of a tutorial that will allow me to achieve this slider effect - but without using xml http://www.flashmo.com/preview/flashmo_107_slider
The effect is exactly what I need but on the particular network I need to upload to it doesn't seem to be able to load the images, I have tested it on other sites so know it is not a error.
Is there a way to achieve the same effect with the images already embeded in flash?
Thank you in advance for any help, much appreciated.
tacos
04-23-2010, 12:19 AM
XML is similar to a text file holding data... It does nothing else.
All code for this slider is in the Flash document(.fla)... The xml only holds images' urls and switches info such as autoplay on or off, nothing else.
westy2005
04-23-2010, 08:45 PM
Hi tacos, thank you for your reply. Thats what I couldn't understand as it seems to work when I upload it to server and view on plan html page. But when I embed to network it loads the flash but not the images.
I am a real newbie with actionscript could you tell me if it is possible for me to import the images to be displayed into flash 'leave them off the stage' and change the actionscript so it doesn't go to xml for images but gets them from the flash library or stage.
This is the code at the moment:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
flashmo_item._visible = false;
var xml_file:String = "flashmo_107_list.xml";
var folder:String = "thumbnails/";
var auto_duration:Number = 6000; // where 1 second equals 1000
var auto_play:Boolean = true; // true = ON | false = OFF
var tween_duration:Number = 0.6; // in seconds
var item_filename:Array = new Array();
var item_url:Array = new Array();
var item_url_target:Array = new Array();
var item_title:Array = new Array();
var item_description:Array = new Array();
var total:Number;
var i:Number;
var interval_id:Number;
var current:Number = 0;
var xml:XML = new XML();
xml.onLoad = function()
{
item_list.fm_item._visible = false;
var nodes = this.firstChild.childNodes;
total = nodes.length;
for( i = 0; i < total; i++)
{
item_filename[i] = nodes[i].attributes.filename;
item_url[i] = nodes[i].attributes.url;
item_url_target[i] = nodes[i].attributes.target;
item_title[i] = nodes[i].attributes.title;
item_description[i] = nodes[i].attributes.description;
}
create_item_list();
}
xml.load( xml_file );
xml.ignoreWhite = true;
function create_item_list():Void
{
for( i = 0; i < total; i++)
{
var item = flashmo_item.duplicateMovieClip("fm_item"+i, i);
item.fm_pic.loadMovie(folder + item_filename[i]);
item._x = i*751;
item.fm_title.text = item_title[i];
item.fm_description.text = item_description[i];
item.no = i;
item.fm_button.onRelease = function()
{
getURL( item_url[this._parent.no], item_url_target[this._parent.no] );
}
}
if( auto_play == true )
{
interval_id = setInterval(this, "change_item", auto_duration);
}
}
function change_item(command)
{
fm_previous.enabled = fm_next.enabled = false;
old_number = current;
if( command == "previous" )
current--;
else
current++;
if( current < 0 )
current = total - 1;
if( current >= total )
current = 0;
old_item = this["fm_item" + old_number];
new_item = this["fm_item" + current];
if( command == "previous" )
{
var fm_tween = new Tween(old_item, "_x", Strong.easeInOut, 0, 751, tween_duration, true);
new Tween(new_item, "_x", Strong.easeInOut, -751, 0, tween_duration, true);
}
else
{
var fm_tween = new Tween(old_item, "_x", Strong.easeInOut, 0, -751, tween_duration, true);
new Tween(new_item, "_x", Strong.easeInOut, 751, -0, tween_duration, true);
}
fm_tween.onMotionFinished = function()
{
fm_previous.enabled = fm_next.enabled = true;
}
}
function fm_interval()
{
if( fm_auto._currentframe == 2 )
{
interval_id = setInterval(this, "change_item", auto_duration);
}
else
{
clearInterval(interval_id);
}
fm_auto.play();
}
fm_previous.onRelease = function()
{
change_item("previous");
}
fm_next.onRelease = function()
{
change_item("next");
}
fm_auto.onRelease = function()
{
this._parent.fm_interval();
}
if( auto_play == true )
fm_auto.gotoAndStop(1);
else
fm_auto.gotoAndStop(2);
tacos
04-24-2010, 01:27 AM
This is basically the section you need to get rid of, and hardcode the differents arrays to hold the info that was read from the .xml file...
//...
var xml:XML = new XML();
xml.onLoad = function()
{
item_list.fm_item._visible = false;
var nodes = this.firstChild.childNodes;
total = nodes.length;
for( i = 0; i < total; i++)
{
item_filename[i] = nodes[i].attributes.filename;
item_url[i] = nodes[i].attributes.url;
item_url_target[i] = nodes[i].attributes.target;
item_title[i] = nodes[i].attributes.title;
item_description[i] = nodes[i].attributes.description;
}
create_item_list();
}
xml.load( xml_file );
xml.ignoreWhite = true;
//...
westy2005
04-24-2010, 10:54 AM
I am sorry to keep bothering you, I am so bad at this!!
I have deleted the section from the actionscript that you said.
The xml code was - <items>
<item filename="flashmo_300x225_01.jpg"
url="http://www.example.com"
target="_parent"
title="Item No. 1 - Lorem ipsum dolor sit amet"
description="Example1." />
<item filename="flashmo_300x225_02.jpg"
url="http://www.example.com"
target="_blank"
title="Item No. 2 - Ut wisi enim ad minim veniam"
description="Example 2" />
</items>
Do I now drag the images on to the stage (out of view) and give them instance names of 1, 2, 3 etc?
Please could you help with how to hardcode the different arrays, I just don't know where to begin?
tacos
04-26-2010, 02:16 AM
Attach or provide a link to your .fla in a no higher format than CS3, not CS4.
westy2005
04-26-2010, 10:52 AM
Thank you, I have upload the .fla in a zip file. It is version Flash 8. The images in the library are just colours at the moment. Any questions or if you need any more info let me know. Thank you again for your time.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.