Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is xlink possible in flash?

Status
Not open for further replies.

jFernandes

Programmer
Oct 2, 2008
6
I'm importing an XML document into flash and interpreting each XML node as HTML and loading it into a movieclip. I was not aware that my client wanted to create links within this text that would link to the same movieclip that the text is already loaded into. I thought perhaps this could be achieved with xlink but I don't think there is enough support for this feature if it even works at all with flash.

External links are simple since flash understands 'A' tags but how could I create links within the text that replaces the content in the movieclip? Is this even possible? Any help is appreciated.
 
That definitely helps a lot, still learning. I'm actually using AS3 so I found this code:

Code:
var linkText:TextField = new TextField();
linkText.htmlText = 'Link: <a href="event:Link Clicked">Click</a>';
addChild(linkText);

linkText.addEventListener(TextEvent.LINK, linkEvent);

function linkEvent(event:TextEvent):void {
    trace(event.text); // Link Clicked
}

This creates a dynamic textfield that then becomes an html link that can have functions applied to it but the problem is creating a link in my prexisting HTML formatted XML node that can then perform a function in flash. The reason for using external text being that it can be connected to a CMS.

Here's a link to the SWF so you can see what I'm trying to do, please don't mind the design - in progress. The scrollable text potentially will have several links in it that will replace itself with new text, if possible.

SWF File, XML File

I've also attached the XML so you can see the nodes. Each link at the top is dynamically driven from the XML, hence 'NAVIGATION_1', 'NAVIGATION_2' etc. Each nav item swaps out one node for another, using a MouseEvent function, so the content gets updated in the dynamic textfield, hence 'ABOUT_COPY', TICKET_COPY' etc.

The problem is that each node will potentially have more than one link that will need to swap the copy out of that same movieclip.
 
var linkText:TextField = TXT;
var linkNum:Number = Number(event.text);

linkText.addEventListener(TextEvent.LINK, linkEvent);

function linkEvent(event:TextEvent):void {
if (linkNum == 1)
{
TXT= xml.NODE;
}
else if (linkNum == 2)
TXT= xml.NODE;
}
}
 
Oops, messed up my post. I meant to say thank you. Did not realize 'asfunction from AS2 has been replaced by simply 'event'. All I needed is the link: <a href="event:1"> and the following actionscript:

Code:
var linkText:TextField = TXT;
var linkNum:Number = Number(event.text);

linkText.addEventListener(TextEvent.LINK, linkEvent);

function linkEvent(event:TextEvent):void {
    if (linkNum == 1)
    {
     TXT= xml.NODE;
    }
    else if (linkNum == 2)
    TXT= xml.NODE;
    }
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top