Articles Archive
Articles Search
Director Wiki
 

Flash Asset-Lingo communications

December 13, 1998
by Pat McClellan

Dear Multimedia Handyman,

I've created a navigation component in Flash and imported it into director as a cast member using the Flash Asset Xtra. have three buttons on my navigation; 'menu' , 'previous' and 'next'. I've given the menu button the getURL command: event: FlashMouseUp "menu"

And then added a handler script to the flash cast member within my director movie which reads:


on getURL me, stringFromFlash
  go to frame stringFromFlash
end

I can't for the life of me get my next and previous buttons to send a command to director which says go to the next marker, or go to the prvious marker.

Can you help?

Nathan Pitman

Nathan,

Good to see somebody is integrating Flash Assets into a Director movie. You've got the right idea... send a string from Flash, then process the string from a Lingo handler.

The difficulty you're running into is that in Lingo, 'next' and 'previous' are keywords, not treated as string data. Example: go next -- will go to the next marker go previous -- will go to the previous marker

However (and note the quotation marks)


go "next"
-- will look for a marker named "next"
go "previous"
-- will look for a marker named "previous"

In your case, you only have 3 buttons, so it's easy to deal with each possible case. But, just in case you wanted to have a lot of different buttons, we should make the handler as generic as possible. Therefore, I'll write it so that it deals with next and previous specifically, and everything else generically. (I'm changing the name of the handler to "on flashMouseUp" to match the event you're calling from your flash button.)


on FlashMouseUp me, stringFromFlash  
  case stringFromFlash of
    "next": go next
    "previous": go previous
  otherwise
    go to frame stringFromFlash
  end case
end

Now, let's talk a bit about the format of the data that you deal with in Director. It's important to understand the various types of data that Director expects to see. In this case, you have string data -- a word or phrase within quotes -- but you need it to NOT be in a string. In other cases, you'll have non-string data -- such as a list, an integer, or a symbol which you'll need to convert to a string. (You might need it in string format so that you can write it to an external file.)

To convert non-string data into a string, you can simply use the string() command. For example...


set x = 2 + 6
put x
-- 8
put string(x)
-- "8"

To go the other way is not so straight forward. In many cases you can use the value() function. This works well when the string -- when converted -- will be a recognizable data format. For example, let's say you were reading a list out of a field member or an external data file. Let's say that myList is a string that reads...

"[#Chicago: 27, #GreenBay: 13, #Pittsburgh: 4]"

To convert this string to a list...


put value(myList)
-- [#Chicago: 27, #GreenBay: 13, #Pittsburgh: 4]

Notice that there are no quotes. That means that Director recognizes this as a Lingo term that it can deal with -- in this case, a property list.

Now, for some reason, you can't do this with next and previous. I'm not sure why, but value("next") returns VOID. Not good. Luckily, you can you symbols to bridge this gap. Try this...


set myString = "next"
put myString
-- "next"
set mySymbol = symbol (myString)
put mySymbol
-- #next

Now, Lingo has no problem dealing with this command....

go #next

That works fine. Unfortunately, it doesn't know how to deal with...

go #menu

So, this is not a solution that you can use universally. Just something to keep in mind for other applications in the future. Good luck with your project.

Patrick McClellan is Director Online's co-founder. Pat is Vice President, Managing Director for Jack Morton Worldwide, a global experiential marketing company. He is responsible for the San Francisco office, which helps major technology clients to develop marketing communications programs to reach enterprise and consumer audiences.

Copyright 1997-2017, Director Online. Article content copyright by respective authors.