PDA

View Full Version : Passing variable to html - Link


eivindt
10-26-2010, 11:48 PM
Ok. I am giving this another try:-)
The asfunction was replaced by the LINK TextEvent, blah blah blah....
Is it possible or not possible to populate a dynamic textfield from clicks made in an array menu, and then be able to click those textbox entries to go back to the array elements?
I am going to post my code here. It is almost working, which is to say that I can populate the textField with my mouseclicks from the array menu, and I can select all of these text-entries again as links,.... But, I can only seem to pass 1 of them into the html- link, and I can't understand why I can't pass "labelName" - this being the string variable for the array menu items. Do I have to assign all the menu items to the html - link separately or what?
I can't seem to figure this out......

Please read the code!

This is for the actions layer, frame 1, Main Timeline:
import flash.display.*;
import flash.events.*;
import flash.display.Stage;
var buttonTrace:TextField;

var sectionNames:Array = new Array("Frontpage","Introduction",
"Designparadigm", "Tooling", "Maya & c++ API", "Geometric Vectors","Lindenmayer systems","Artificial Life",
"Projects","Litterature","Disclaimer","Site credits","Newsletter & Rss",
"Blogging","Plugins","LINKS");
var sectionCount: int = sectionNames.length;
var menu:Sprite = new Sprite();
menu.x = 452;
menu.y = 172;
this.addChild(menu);
buildMenu();
function buildMenu():void {
for(var i:int=0; i < sectionCount ; i++){
var item:MovieClip = new MenuItem();
item.labelName = sectionNames[i];
item.targetClip = this;
if(i<4){
item.y = i*125
menu.addChild(item)}
else if (i>3 && i<8){
item.y = (i-4)*125
item.x = 125
menu.addChild(item)}
else if (i>7 && i<12){
item.y = (i-8)*125
item.x = 250;
menu.addChild(item)}
else if (i>11 && i<16){
item.y = (i-12)*125
item.x = 375
menu.addChild(item)}
}
}

, and here is the code for the library movieclip for the sprite menu -
Movieclip "MenuItem", actions layer, "MenuItem Timeline(I have only added some of the items for the menu here, as I won't bother with the rest untill I get it right:

import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.display.Stage;
import flash.text.TextField;
import flash.events.Event;
import flash.events.TextEvent;
import flash.display.Sprite;
//TextField labelField;
var buttonTrace:TextField;
var labelName:String;
var targetClip:MovieClip;
clickButton.addEventListener(MouseEvent.CLICK, onClick);
function onClick(evt:MouseEvent):void {
trace(labelName);
targetClip.gotoAndStop(labelName);
MovieClip(root).buttonTrace.appendText("\n" + labelName);

}
MovieClip(root).buttonTrace.htmlText=labelName;
MovieClip(root).buttonTrace.addEventListener(TextE vent.LINK,linkHandler);

function linkHandler(linkEvent:TextEvent):void {
switch (linkEvent.text) {
case "Introduction":

Intro();
break;
case "Designparadigm":
DP();
break;
case "Artificial Life":
AL();
break;
case "Projects":
Projects();
}
}
function Intro():void {
targetClip.gotoAndStop("Introduction");

}
function DP():void {
targetClip.gotoAndStop("Designparadigm");
}
function AL():void {
targetClip.gotoAndStop("Artificial Life");
}
function Projects():void {
targetClip.gotoAndStop("Projects");
}
MovieClip(root).buttonTrace.htmlText="<a href=\'event:Projects'\>Retrace your steps</a>";