Calling a GIF (java/actionscript) on a Flash rollover?

  • ajm786
  • Born
  • Born
  • ajm786
  • Posts: 2

Post 3+ Months Ago

Hey guys. I was hoping you could help me out with this.

Granted, I'm just a beginner with Flash. However, I have found and modified a Flash 3d wall that I like, and now I only have one obstacle to getting it all working properly.

Here's what I'd like to do. I want a MouseOver event to trigger an actionscript/javascript that will pull open a GIF, JPG, or whatever else file that I want, so that it's basically a hovering image that can also be clickable, and then fade/disappear if not clicked after a specified time.

Here's the code.

Code: [ Select ]
import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.materials.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.display.Sprite;
import flash.events.MouseEvent;

var container:Sprite = new Sprite();
container.x = 340;
container.y = 245;
addChild(container);

var scene:Scene3D = new MovieScene3D(container);
var cam:Camera3D = new Camera3D();
cam.zoom = 1;

tn_title.text = "";
tn_desc.text = "";
tn_url.text = "";

var p_dict:Dictionary=new Dictionary();
var pc:Plane = new Plane();
pc.visible = false;
cam.target = pc;

var numOfRotations:Number = 3;
var yPos:Number = 0;
var angle:Number = 0;

var filename_list = new Array();
var url_list = new Array();
var url_target_list:Array = new Array();
var title_list = new Array();
var description_list = new Array();
var folder:String = "/v/vspfiles/files/flash/curvewall/thumbnails/";

var i:Number;
var j:Number = 0;
var k:Number = 0;
var l:Number = 0;
var m:Number = 0;
var total:Number;
var flashmo_xml:XML = new XML();
var loader:URLLoader = new URLLoader();
loader.load(new URLRequest("/v/vspfiles/files/flash/curvewall/thumbnail_list_3.xml"));
loader.addEventListener(Event.COMPLETE, create_thumbnail);

function create_thumbnail(e:Event):void
{
    flashmo_xml = XML(e.target.data);
    total = flashmo_xml.thumbnail.length();
    var anglePer:Number = ((Math.PI*2) * numOfRotations) / total;
    
    for( i = 0; i < total; i++ )
    {
        url_list.push( flashmo_xml.thumbnail[i].@url.toString() );
        url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );
        title_list.push( flashmo_xml.thumbnail[i].@title.toString() );
        description_list.push( flashmo_xml.thumbnail[i].@description.toString() );
        
        var bfm:BitmapFileMaterial = new BitmapFileMaterial(
            folder + flashmo_xml.thumbnail[i].@filename.toString());
        bfm.oneSide = false;
        bfm.smooth = true;
        var p:Plane = new Plane(bfm, 107, 80, 2, 2);
        scene.addChild(p);
        var p_container:Sprite = p.container;
        p_container.name = "flashmo_" + i;
        p_dict[p_container] = p;
        p_container.buttonMode = true;
        p_container.addEventListener( MouseEvent.ROLL_OVER, p_rollover );
        p_container.addEventListener( MouseEvent.ROLL_OUT, p_rollout );
        p_container.addEventListener( MouseEvent.CLICK, p_click );
        
        p.rotationY = (-i*anglePer) * (180/Math.PI) + 90;
        p.x = Math.cos(i * anglePer) * 350;
        p.z = Math.sin(i * anglePer) * 350;
        p.y = yPos;

        if( (i+1) % 20 == 0 )
        {
            yPos += 84;
        }
    }
}

function p_rollover(me:MouseEvent)
{
    var sp:Sprite = me.target as Sprite;
    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 0.5, 1, 0.6, true);
    var s_no:Number = parseInt(sp.name.slice(8,10));
    tn_title.text = title_list[s_no];
    tn_desc.text = description_list[s_no];
    tn_url.text = url_list[s_no];
}
function p_rollout(me:MouseEvent)
{
    var sp:Sprite = me.target as Sprite;
    var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 1, 0.5, 0.6, true);
    tn_title.text = "";
    tn_desc.text = "";
    tn_url.text = "";
}
function p_click(me:MouseEvent)
{
    var sp:Sprite = me.target as Sprite;
    var s_no:Number = parseInt(sp.name.slice(8,10));
    navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);
}

addEventListener(Event.ENTER_FRAME, render);

function render(e:Event):void
{
    var dist2:Number = ((stage.mouseX) - 400) * 0.00003;
    angle += dist2;
    cam.x = - Math.cos(angle) * 50;
    cam.z = Math.sin(angle) * 50;
    var new_zoom = 5.1 - stage.mouseY * 0.003;
    cam.zoom += ( new_zoom - cam.zoom ) * 0.005;
    scene.renderCamera(cam);
}
  1. import org.papervision3d.scenes.*;
  2. import org.papervision3d.cameras.*;
  3. import org.papervision3d.objects.*;
  4. import org.papervision3d.materials.*;
  5. import fl.transitions.Tween;
  6. import fl.transitions.easing.*;
  7. import flash.display.Sprite;
  8. import flash.events.MouseEvent;
  9. var container:Sprite = new Sprite();
  10. container.x = 340;
  11. container.y = 245;
  12. addChild(container);
  13. var scene:Scene3D = new MovieScene3D(container);
  14. var cam:Camera3D = new Camera3D();
  15. cam.zoom = 1;
  16. tn_title.text = "";
  17. tn_desc.text = "";
  18. tn_url.text = "";
  19. var p_dict:Dictionary=new Dictionary();
  20. var pc:Plane = new Plane();
  21. pc.visible = false;
  22. cam.target = pc;
  23. var numOfRotations:Number = 3;
  24. var yPos:Number = 0;
  25. var angle:Number = 0;
  26. var filename_list = new Array();
  27. var url_list = new Array();
  28. var url_target_list:Array = new Array();
  29. var title_list = new Array();
  30. var description_list = new Array();
  31. var folder:String = "/v/vspfiles/files/flash/curvewall/thumbnails/";
  32. var i:Number;
  33. var j:Number = 0;
  34. var k:Number = 0;
  35. var l:Number = 0;
  36. var m:Number = 0;
  37. var total:Number;
  38. var flashmo_xml:XML = new XML();
  39. var loader:URLLoader = new URLLoader();
  40. loader.load(new URLRequest("/v/vspfiles/files/flash/curvewall/thumbnail_list_3.xml"));
  41. loader.addEventListener(Event.COMPLETE, create_thumbnail);
  42. function create_thumbnail(e:Event):void
  43. {
  44.     flashmo_xml = XML(e.target.data);
  45.     total = flashmo_xml.thumbnail.length();
  46.     var anglePer:Number = ((Math.PI*2) * numOfRotations) / total;
  47.     
  48.     for( i = 0; i < total; i++ )
  49.     {
  50.         url_list.push( flashmo_xml.thumbnail[i].@url.toString() );
  51.         url_target_list.push( flashmo_xml.thumbnail[i].@target.toString() );
  52.         title_list.push( flashmo_xml.thumbnail[i].@title.toString() );
  53.         description_list.push( flashmo_xml.thumbnail[i].@description.toString() );
  54.         
  55.         var bfm:BitmapFileMaterial = new BitmapFileMaterial(
  56.             folder + flashmo_xml.thumbnail[i].@filename.toString());
  57.         bfm.oneSide = false;
  58.         bfm.smooth = true;
  59.         var p:Plane = new Plane(bfm, 107, 80, 2, 2);
  60.         scene.addChild(p);
  61.         var p_container:Sprite = p.container;
  62.         p_container.name = "flashmo_" + i;
  63.         p_dict[p_container] = p;
  64.         p_container.buttonMode = true;
  65.         p_container.addEventListener( MouseEvent.ROLL_OVER, p_rollover );
  66.         p_container.addEventListener( MouseEvent.ROLL_OUT, p_rollout );
  67.         p_container.addEventListener( MouseEvent.CLICK, p_click );
  68.         
  69.         p.rotationY = (-i*anglePer) * (180/Math.PI) + 90;
  70.         p.x = Math.cos(i * anglePer) * 350;
  71.         p.z = Math.sin(i * anglePer) * 350;
  72.         p.y = yPos;
  73.         if( (i+1) % 20 == 0 )
  74.         {
  75.             yPos += 84;
  76.         }
  77.     }
  78. }
  79. function p_rollover(me:MouseEvent)
  80. {
  81.     var sp:Sprite = me.target as Sprite;
  82.     var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 0.5, 1, 0.6, true);
  83.     var s_no:Number = parseInt(sp.name.slice(8,10));
  84.     tn_title.text = title_list[s_no];
  85.     tn_desc.text = description_list[s_no];
  86.     tn_url.text = url_list[s_no];
  87. }
  88. function p_rollout(me:MouseEvent)
  89. {
  90.     var sp:Sprite = me.target as Sprite;
  91.     var tw:Tween = new Tween(sp, 'alpha', Strong.easeOut, 1, 0.5, 0.6, true);
  92.     tn_title.text = "";
  93.     tn_desc.text = "";
  94.     tn_url.text = "";
  95. }
  96. function p_click(me:MouseEvent)
  97. {
  98.     var sp:Sprite = me.target as Sprite;
  99.     var s_no:Number = parseInt(sp.name.slice(8,10));
  100.     navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);
  101. }
  102. addEventListener(Event.ENTER_FRAME, render);
  103. function render(e:Event):void
  104. {
  105.     var dist2:Number = ((stage.mouseX) - 400) * 0.00003;
  106.     angle += dist2;
  107.     cam.x = - Math.cos(angle) * 50;
  108.     cam.z = Math.sin(angle) * 50;
  109.     var new_zoom = 5.1 - stage.mouseY * 0.003;
  110.     cam.zoom += ( new_zoom - cam.zoom ) * 0.005;
  111.     scene.renderCamera(cam);
  112. }


Your help, pointers, and suggestions would be much appreciated. Thanks!
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ajm786
  • Born
  • Born
  • ajm786
  • Posts: 2

Post 3+ Months Ago

Bump? Can anyone offer some input on this? Thanks.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 13 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.