Articles Archive
Articles Search
Director Wiki
 

Flash Asset Xtra

January 22, 1998
by Pat McClellan

A new way of thinking

I have only begun working with this awesome Xtra, so I'm sure that many of you have already exceeded the extent of my exploration of Flash and Director interaction. This article isn't intended to tell you how to use the new Xtra, and it's not even a product review. I haven't used it long enough to know a bug from a feature. Rather, I hope to spur some conversation about how we can all make the most of it. I hope you'll write me with your experiences so that we can share them here. That said, let me tell you why I think this Xtra will change the way most of us work.

Since Macromedia added Flash to its lineup, many of us Lingo-heads have been quick to dismiss it. My experience with Flash 2 has been limited to a few simple logo splash animations and a series of still technical drawings that I needed to be able to scale with high resolution in a browser-based training module. I didn't use it for buttons, because I'm never sure where my clients are going to put my programs on their server, and Flash has required absolute URLs for its buttons. I realize the potential of Flash, but I've just never had the need to make it a big part of my development arsenal. For most of my work I've depended on Director, primarily because of the power that Lingo brings to interactivity. Sure, Director lacks the power of vector-based graphics; rotating sprites has not been an option (except with Media Lab's recently released Effector Set); still, it was a paradigm in which I was comfortable.

This new Flash Asset Xtra is big. So big, in fact, that I'm still not sure how to think about it. It's easy to say "now Director can use vector-based graphics", but we've been working without them for so long, I've only begun to imagine how I'll use them. Scale, rotation, anti-aliasing, and major file size reduction. Nice features, but how will we apply them? I must start thinking about these capabilities in the early stages of the development process. This adds a lot to Director.

Shockwave

When I first heard about the Flash Asset Xtra (back at UCON 97), I was dissappointed to discover that in order to use these capabilities in Shockwave, the user would have to download the Xtra. It's always been enough of a hassle to get them to download the Shockwave plugin! Macromedia gives really good instructions for how to do this. For an example of this, check out the CheesyPoofs game listed in the User Showcase. Actually, downloading the installer was really easy -- and worth the trouble (great game!)

But now you can kiss this download hassle goodbye. According to Bill Schulze (Macromedia's Xtras Essentials Product Manager), "The great news... is that starting in February, the runtime component of the Flash Asset Xtra will be included with the normal download of Shockwave from our site. As this download proliferates, we'll see a high degree of compatibility of the Flash Asset running in Shockwave." That's right: the standard Shockwave-Flash plugin will soon handle playing back Flash WITHIN Director Shockwave movies. (Check out Bill's full Macromedia Insider interview in the Features Section.)

At the time I'm writing this (Feb 15th), the new Shockwave is not posted. So, you may need to download the Xtra in order to see my demo movie. It's worth the trouble. Download the Xtra

I created this demo movie so that you can play around, inputing Lingo to manipulate and query the properties of the Flash sprites in the right half of the movie. Just type standard lingo into the field, then press the Execute button. You can enter multiple lines of instructions. (Sorry, it's a field, so your lingo isn't going to indent, but it will still execute without the indentations.) The text entry field "input" can also display results, so if you want to check a property of one of the Flash sprites (such as "scale" or "rotation"), enter something like...


put the scale of sprite 4 into field "input"

Don't forget to press the "Execute" button.

Lingo

Let's not ignore what this Xtra does for Flash. By importing a Flash movie into Director, you add the power of Lingo to a previously non-scriptable application. (Of course, you have to import the Flash movie into Director to use it.) I am really impressed by the extent of the new Lingo which has been developed with this Xtra. I count 60 new Lingo properties or functions which are specific to Flash control. See the full list of new Lingo. And they're good ones too -- much more than I expected. For example, I expected that we'd be able to control the rotation angle of the Flash sprite with Lingo. No problem. Let's say that our Flash member is in sprite 4 and we want to rotate it 1 full revolution (in 5 degree increments):

 repeat with i = 1 to 72
    set the rotation of sprite 4 = i * 5
    updatestage
 end repeat
   

Of course, you could do this animation in Flash without Lingo, but you couldn't control the rotation with Lingo. Flash animation is much like creating animation in Director, if you JUST use the stage and score. But now, let's add some Lingo to the execution of the animation that you can't ordinarily do in Flash.

Lingo commands, including originMode, originPoint, originV, and originH give us complete control of the axis of that rotation. For example, we can rotate the sprite around its center point, its top-left point, or any other point you care to specify! You could have quite a complex bit of animation by combining rotation and a moving origin.


 set the originMode of sprite 4 to #point
 set the originPoint of sprite 4 to point(1,1)
 set myAngle = 0
 repeat while myAngle < 360
    set myAngle = myAngle + 5
    set the rotation of sprite 4 = myAngle
    updatestage
    set the originPoint of sprite 4 = the ¬
      originPoint of sprite 5 + point(2,2)
 end repeat
   

I expect that a year from now, rotation behaviors will be as common as rollover scripts. OK, I can't wait. I just have to try to do something that I've never been able to pull off in Director: a plain old radial clock. Nothing fancy. In Director, you have to do some trig calculations and some frustrating sprite swapping (QuickDraw lines slope right or left, but can't be switched) just to simulate a second hand moving around the dial. With a "rotation" property, this should be a breeze! [author leaves]

[author returns]
And it was. 10 minutes in Flash to create 4 concentric movies (static images of each hand pointing to 12, and the clock face). Then about 30 minutes in Director to write this behavior. I included this demo in the FlashTest shockwave movie.


-- Clock Hands behavior
-- This behavior moves Flash 
-- sprite members as the hour, 
-- minute and second hands of a 
-- radial-style clock
-- Requires that the sprites be 
-- imported Flash members
-- uses "the long time" which 
-- returns current time in 
-- format "(h)h:mm:ss am" or "(h)h:mm:ss pm"
property pHand     -- which clock hand
on getPropertyDescriptionList
  set handList = [#Hour, #Minute, #Second]
  set p_list = [ ¬
     #pHand: [ #comment:  "Which Hand?", ¬
               #format:   #symbol, ¬
               #default:  #Second,¬
               #range:    handList ]]
  return p_list 
end


on prepareFrame me
  set timeNow = the long time 
  -- time in string format
  set timeChars = the number of chars in timeNow
  set secNow= value(char timeChars-4 ¬
     to timeChars-3 of timeNow)
  set minNow= value(char timeChars-7 ¬
     to timeChars-6 of timeNow)
  
  -- hour might be 1 digit or 2, so I delete
  -- the last 9 chars of timeNow
  -- which leaves either 1 or 2 digits, 
  -- which represent the hour
  
  delete char timeChars-8 to timeChars of timeNow
  set hourNow= value(timeNow)
  
  -- hour could be in 24 hour format, 
  --which can't be shown on radial clock
 
  if hourNow > 12 then set hourNow = hourNow - 12
  
  -- check to see which hand this sprite is,
  -- then update its postion
  
  case pHand of
    #Second: updateSecond me, secNow
    #Minute: updateMinute me, minNow, secNow
    #Hour: updateHour me, hourNow, minNow
  end case
end


on updateSecond me, secNow
  set the rotation of sprite the spriteNum ¬
    of me = secNow * 6
  updateStage
end


on updateMinute me, minNow, secNow
  -- secAdd allows the minute hand to move smoothly
  -- in correspondence to elapsed seconds
  set secAdd = secNow/10.00
  set the rotation of sprite the spriteNum of me = ¬
    (minNow * 6) + secAdd
  updateStage
end


on updateHour me, hourNow, minNow
  -- minAdd allows the hour hand to move smoothly
  -- in correspondence to elapsed minutes
  set minAdd = minNow/2
  set the rotation of sprite the spriteNum of me = ¬
    (hourNow * 30) + minAdd
  updateStage
end

Buttons

Many people use Flash for web-page buttons -- just check out Macromedia's web site. They're very easy to do in Flash, but they have always had the drawback that you must use absolute URLs on them -- no relative page calls. But now you can import that button panel into Director and have the full power of Lingo controlling their functions. I'm really not sure WHY you'd do this, instead of just creating the buttons in Director, but time will surely reveal this utility.

To work with buttons which are part of a Flash movie, you should start in the Link Properties:Button dialog box in Flash. Here, you can assign an event that gets passed to Director when the button is pressed. For example, (in Flash) in the Network URL field, enter


put the ticks into field "ticksDisplay"

Now, when the Flash button is pressed, the Lingo gets executed. I used this for the demo movie. There are other options for Flash button/Director communications, but I was immediately attracted to the option in which you use the word "lingo" in a Flash dialog box! All this is explained at length in the documentation, but it seems really easy.

Other possibilities

There are many other possibilities to explore.

Take some time to experiment with various options in the demo movie. For example, on the "Send Lingo" button section, set the buttonsEnabled to false. See how that affects the button's functioning. I hope that you'll help me explore the possibilities that the Flash Asset Xtra has to offer. And, again, I ask that you share your experiences and ideas by posting them in our User Showcase.

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.