homepage Welcome to WebmasterWorld Guest from 54.242.200.172
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Multiple Banner Clickable Link Flash 8
How to make multiple banner a clickable link in Flash 8?
kurazi




msg:4021728
 4:12 pm on Nov 9, 2009 (gmt 0)

Hi there,

I have created a banner in flash, that has 2 images that rotate every 15 seconds or so. It is the banner at the top of the screen.

What i need to be able to do is, on each banner make it clickable so it goes to a specific page. There are just 2 banners, so i didnt think it would be that hard, but I cannot figure it out.

I tried:
on (release) {
getURL("http://www.example.ca/hosting.html");
}
but it takes you to that page for both the banners. I think i need to stop this script and start another one for the other banner when it starts? But im not sure how to do that?

Any suggestions?

Thanks a bunch,
Shawna

[edited by: eelixduppy at 5:01 pm (utc) on Nov. 9, 2009]
[edit reason] no personal URLs, please [/edit]

 

oldflasher




msg:4023305
 7:10 pm on Nov 11, 2009 (gmt 0)

Create 2 Buttons. Insert your images in this buttons. For each buttons write its link, and rotate this buttons every 15 seconds

rocknbil




msg:4023951
 6:39 pm on Nov 12, 2009 (gmt 0)

I would approach it something like this:

- use the xml data import methods to get the data from an external file. The xml file would be something like


<?xml version="1.0" encoding="ISO-8859-1"?>
<imageData>
<image src="/images/flash/image1.jpg" url="http://www.example.com/" caption="Advertiser 1"/>
<image src="/images/flash/image2.jpg" url="http://www.example2.com" caption="Advertiser2"/>
</imageData>

- import this data, store it in the arrays.
You could use a multidimensional array or object, but for simplicity the example here shows three arrays named images, urls, and captions.


var xmlSource = "/data/your-xml.xml";
var xmlObject:XML = new XML();
xmlObject.ignoreWhite = true;
xmlObject.load(xmlSource);
xmlObject.onLoad = function () {
var imageData:Array =this.firstChild.childNodes;
for (j = 0; j < imageData.length; j++){
images[j]=imageData[j].attributes.src;
urls[j]=imageData[j].attributes.url;
captions[j]=imageData[j].attributes.caption;
}
xmlLoaded=true;
}

- Set up an image symbol, button object symbol, and caption symbol (caption probably not needed for this project)

- You would then increment a number and reference them by their index (0, 1, 2, etc.) Note that you aren't loading images directly in Flash, you are referencing their location for import.

- Loop through the array to assign array values to your symbols. In this example, I increment the value of "num" to the current array index in a separate function, which is controlled by a timeout setting that reflects how long the image stays on screen. Set the image object source, url, and caption to the current object in the array:


function loadImage (num) {
var tmp:MovieClip = _root.picBox;
var mcLoader:MovieClipLoader = new MovieClipLoader();
var imgListener:Object = new Object();
imgListener.onLoadComplete = function (tmp:MovieClip) {
_root.picLabel.text = captions[num];
_root.picButton.onRelease = function() { getURL(urls[num]); }
}
var test:String="http://www.your-site.com/"+images[num];
mcLoader.loadClip(test, "picBox");
}

Note the above is for example and methods only, there are some things missing out of context, like how you set and clear timeouts to control duration of the clip, fade ins, fade outs, etc.

The overall structure is 4 frames long. The first sets the global functions, the second does a goToAndStop() of frame 4 only if the XML is loaded (see xmlLoaded=true above.) Frame 3 is a simple goToAnyPlay() of frame 2, which will only execute if xmlLoaded is false. Frame 4 does all the work, incrementing num, calling loadImage, etc. When the last index of the array is reached, it resets num to 0.

There's lots of stuff missing there but it's a basic framework for a configurable application, download and review some slide shows using XML imports for more examples.

Why would you do this?

Instead of compiling the Flash every time you change an image, all you need to do is upload the images and make the changes to the XML file. Never have to edit the Flash again. You could even (and I have) set up an upload interface so the client can upload, resize, and crop images and update the XML file automatically.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved