views:

432

answers:

1

Good day.

I have little usage of Flash CS4, however i have to build a small animation.

It as six different bitmap images, each one with a effect on rollover.

However i want to each one of them to open a URL in a new Tab/Window when clicked.

And if someone know how to load each one of those URLs from a textfile.

I would be very thank full.

Regards.

+2  A: 

The command you're looking for is

navigateToURL(request:URLRequest, "_blank"):void

"_blank" specifies a new window.

You want to load them from a textfile, but this is just not possible from Flash because Flash does not allow disk access.

Unless you mean the textfile is hosted on a server.

EDIT: Here is a comprehensive overview of loading external data into Flash: Adobe Help

var data:Object;

// Load the external file at startup. 
// Variables will be loaded and can be referenced directly.
// The request by default can only call files on the server hosting the Flash.
private function onInitializationComplete(event:Event):void
{
    var loader:URLLoader = new URLLoader();
    var request:URLRequest = new URLRequest("externalFile.txt");
    loader.addEventListener(Event.COMPLETE, completeHandler); 
    loader.dataFormat=URLLoaderFormat.VARIABLES; // Change to .TEXT if you want to parse it yourself.
    loader.load(request);
}

private function completeHandler(event:Event):void
{
     data = event.target.data;
}    

private function onClickHandler(event:MouseEvent):void
{
    var bitmapName:String = (event.target as Sprite).name; // Get the name of the bitmap clicked.
    var URL:String = data[bitmapName]; // A variable with bitmapName should have been loaded from the text file, so I am calling it by name.
    var openMethod:String = data[bitmapName + "Method"];

    navigateToURL(URL, openMethod);
}

Text file should contain data like this:

bitmap1=www.google.com&bitmap1Method=_blank&bitmap2=www.amazon.com&bitmap2Method=_self

If you want to

CookieOfFortune
Yes it is to load from the hosting server.
Fábio Antunes
Just for wondering. Its possible to load the value "_blank" or "_self" from the hosted text file as well ?Thanks.
Fábio Antunes
yes, you should be able to, let me get that edit in.
CookieOfFortune
I'm looking forward to know how its done. Thanks for the help.
Fábio Antunes
Its done..Thanks friend :D
Fábio Antunes