Archive for July, 2007

AS3: TextEvent.LINK and ContextMenu incompatibilities.

Monday, July 23rd, 2007 by Luis

This morning I run into a small problem when using the new TextEvent.LINK.

Basically as with ActionScript 1 and ActionScript 2, ActionScript 3 allows you to associate ActionScript events with links in a textfield.

In AS3, the LINK event is dispatched when a user clicks a hyperlink in an HTML-enabled text field, where the URL begins with "event:". The remainder of the URL after "event:" will be placed in the text property of the LINK event.

Everything is good until here, but the problem comes when you right-click the link in the textfield. By default the flash player shows one type of context menu that is not any of the 3 types defined in the docs.

contextmenu

According with the AS3 language reference the Flash Player has three types of context menus: the standard menu (which appears when you right-click in Flash Player), the edit menu (which appears when you right-click a selectable or editable text field), and an error menu (which appears when a SWF file has failed to load into Flash Player).

The problem with the context menu appearing when you right-click a link inside a textfield is basically that igonres completely the new LINK event and by default tries to open the link generating an obvious alert message from the browser:

'Firefox doesn't know how to open this address, becuase the protocol (event) isn't associated with any program'.

So far I don't think there is a way to edit or modify this type of context menu.

Sample swf:

Sample Code:

Actionscript:
  1. package
  2. {
  3.     import flash.display.Sprite;
  4.     import flash.events.TextEvent;
  5.     import flash.text.TextField;
  6.     import flash.text.TextFieldAutoSize;
  7.     import flash.text.TextFormat;
  8.    
  9.     [SWF(width="450", height="150", frameRate="31", backgroundColor="#FFFFFF")]
  10.    
  11.     public class TextEventLinkTest extends Sprite
  12.     {
  13.         private var myTextField     : TextField;
  14.        
  15.         public function TextEventLinkTest():void
  16.         {
  17.            
  18.             myTextField             =   new TextField();
  19.             myTextField.autoSize    =  TextFieldAutoSize.LEFT;
  20.             myTextField.multiline   = true;
  21.  
  22.             var format:TextFormat   =     new TextFormat();
  23.             format.font             =   "Verdana";
  24.             format.color          =  0xFF0000;
  25.             format.size             =   11;
  26.  
  27.             myTextField.defaultTextFormat = format;
  28.             myTextField.x=20;
  29.             myTextField.y=20;
  30.        
  31.             addChild(myTextField);
  32.        
  33.             myTextField.htmlText = 'With the new method of event handling in AS3,<br>' +
  34.                     'event (asfunction) no longer calls a method you defined but,<br>' +
  35.                     'rather, sends out a TextEvent (<b><u><a href="event:flash.events.TextEvent">flash.events.TextEvent</a></u></b>) of the<br>' +
  36.                     'type <b><u><a href="event: TextEvent.LINK">TextEvent.LINK</a></u></b> for the text field instance in which it exists.<br>' +
  37.                     '<br>The text following the event: keyword in the link is accessible from<br>' +
  38.                     'the TextEvent object through its text property.';
  39.            
  40.             myTextField.addEventListener(TextEvent.LINK, linkEvent);
  41.  
  42.         }
  43.        
  44.         private function linkEvent(event_:TextEvent):void
  45.         {
  46.             trace('click: '+event_.text);
  47.         }
  48.        
  49.        
  50.     }
  51. }


Papervision3D 1.5 (AS3) Official Release

Saturday, July 21st, 2007 by Torsten

So now it's official. The latest release of Papervision3D comes with merged and cleaned code, new objects and materials, interactive materials and performance updates.

John Grden gives an overview of the change list:

  1. Optimized main render loop.
  2. Implemented ‘plugable’ face culler - 1 extra available at this time.
  3. Moved rendering from Face3D to materials, adjusted all current materials to override drawFace3D().
  4. New Materials : BitmapWire, BitmapColor, and CompositeMaterial (add multiple materials to this one single material).
  5. Moved all instances to their respective classes…fixed stars, vertices and DisplayObject3D to do so.
  6. Face normals are implemented.
  7. BitmapFileMaterial bug fixed - if used more than once, bitmap was displayed flat within the model’s body.
  8. Added progress events to BitmapFileMaterial and Collada objects
  9. Integrated InteractiveScene3D to 1.5
  10. Added Interactive materials for use with InteractiveScene3D - makes displayObjects that use an interactive material dispatch mouse events via InteractiveSceneManager.

Have a look at the Demo and Download Papervision3D 1.5

And now let's have a closer look at it. Thanks papervision!

Bumptop, now available in Flash

Thursday, July 19th, 2007 by Carsten Schneider

Coming soon. Patrick wants someone to do this as a background transparent Air application so he can replace his desktop interface.

Related Posts: Organize your Desktop

UPDATE on Red Bull FFC Project

Tuesday, July 17th, 2007 by Luis

We have put together a nice set of photos where you can see the Red Bull Formula 1 cars in detail.

See Photos.

faces for charity

Related Post: