Hi,
Flash CS5 AS3
Having googled what I thought would have many instances of how its done, I have gotten nowhere, as have others with no replies to their postings.
Google shows nothing for as3; flex3 forum has something but we are not using flex.
Is it possible to have a dataGrid and text for websites in cells that when clicked on go to that URL ?
Has Adobe overlooked the ability to create a hyperlink from a url in a cell ?
My situation. We have a dataGrid populated from a csv file. col1 has bus service number, nothing shows for that. col2 to 6 have settlement names and display MC's, col7 and col8 have url's which we want as hyperlinks, one goes to a timetable the other to a very detailed map.
Currently we have it that click on row outputs data from all cells in that row. Sttmnt names are output less gaps and apostrophes and code appends _Layer2 or _Layer3 depending on where they are in the map display hierarchy. Output tab also shows it identifying the col1 data which are service numbers, but there doesnt seem to be a need to disable that as its not causing any problems despite there being no matching MC's !
We also see the two url's output. They are however stripped of // gaps and full stops
We dont want any websites being launched until user deliberately clicks the cell in col7 or col8.
How is this done ? i.e what is the code to make a hyperlink from a cell ?
In with this we also need to tell the code to ignore col7 and 8 on click that shows up the sttmnts and appends _Layer2 or _Layer3 yet accept a click when made in col7 or col8 and not to strip out the characters and gaps and not to append _Layer2 or _Layer3.
Just what should this code below be to accomplish this ?
our code thus far:-
import flash.net.URLLoader;
import flash.events.Event;
import flash.net.URLRequest;
import fl.data.DataProvider;
import fl.controls.DataGrid;
import fl.events.ListEvent
makeAllVisibleF(false);
var urlLoader:URLLoader = new URLLoader();
urlLoader.addEventListener(Event.COMPLETE,completeF);
urlLoader.load(new URLRequest("BusMapHyperlinks_txtMatchMCv3.csv"));
var dg:DataGrid
//-------------------------------------------------------------------- -------------------------------
function completeF(e:Event):void{
var dataS:String = e.target.data;
var dataA:Array = dataS.split("\n").join("").split("\r");
var dpA:Array = [];
var itemA:Array;
var r:RegExp = /\W/g;
for(var i:int=0;i<dataA.length;i++){
itemA = dataA[i].split(",");
dpA.push({"col1":itemA[0],"col2":itemA[1],"col3":itemA[2],"col4":item A[3],"col5":itemA[4],"col6":itemA[5],"col7":itemA[6],"col8":itemA[7]}) ;
}
var dp:DataProvider = new DataProvider(dpA);
dg.columns = ["col1","col2","col3","col4","col5","col6","col7","col8"]
dg.columns[0].width = 57;
dg.columns[1].width = 182;
dg.columns[2].width = 143;
dg.columns[3].width = 90;
dg.columns[4].width = 110;
dg.columns[5].width = 65;
dg.columns[6].width = 62;
dg.columns[7].width = 30;
dg.dataProvider = dp;
}
dg.addEventListener(ListEvent.ITEM_CLICK,dgClickF);
function dgClickF(e:ListEvent):void{
trace(e.columnIndex, e.rowIndex);
}
dg.addEventListener(ListEvent.ITEM_CLICK,ShowSymbols);
function ShowSymbols(e:ListEvent):void{
makeAllVisibleF(false);
var r:RegExp = /\W/g;
for(var s:String in e.item){
if(e.item[s]){
var clipName :String = String(e.item[s]).replace(r,"")+currentLevel;
trace(clipName)
if(Map_Collection[clipName]){
Map_Collection[clipName].visible=true;
}
trace(s,e.item[s])
trace(currentLevel)
}
}
}
function makeAllVisibleF(b:Boolean):void{
Map_Collection.MitresGate_Level2.visible=b;
Map_Collection.MitresGate_Level3.visible=b;
and many more names !!!
Envirographics