Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Papervision - How To Make Irregular Planes Into Buttons



Hi all, I'm not a regular here, but I hope you don't mind me dropping in with this question ...Here's a demo showing how far I've got: danwashere.com/dev/papervision/interactive_cows.html What I want is to be able to click on any of the three planes and make the corresponding red dot show or hide. It works on the top most cow - try clicking on it. But you can't click on the other two. I've also tried this with transparent PNGs with the same result. I think that because it's really a rectangular plane with some transparent bits, that it blocks the mouse click from getting to the planes below. What would be a good approach here? Do I have to create these via collada or somesuch to make them into lots of smaller planes? Or is there something I can do with what I've got?



KirupaForum > Flash > ActionScript 3.0
Posted on: 09-16-2008, 10:45 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Making Buttons Irregular Shapes
How can I make a button I already have an irregular shape. Example - I ahve a map and i want to make each state it's own button. I have already seperated the states, but the 'hit' area of the state is still a large box that covers other states as well. Can you understand what I'm saying?

Thx

Creating Buttons From Irregular Shapes
Hi

I'm sure there is an easy solution to this so pardon my newbieism!

I have created two images in photoshop and saved them as button_up.gif and button_over.gif. The shape is irregular in form (not round or square), for simplicity lets say it is star shaped.

When i create a button in flash and hover over it it will change from button_up.gif to button_over.gif.

This is exactly what i want, but i've noticed that the button will change to button_over.gif outside the actual star shape like the button has a rectangular button around it.

How do i get the button to shrink around the shape of the star?

Your helps is much appreciated.

Ant

Best Way To Make A Rotating Object Using Papervision
Hi there,

I am trying to figure out the best way to make a floating, rotating object. The object would be a triangular pen (being 3 sided). I figured I could use papervision3D, and possible create an object that would be a pyramid, but I'm not sure how I would make the pyramid... I was thinking using the plane class?

If anybody could suggest any tutorials or blogs where I could check it out, it would be greatly appreciated!

Thanks!

Perspected Planes In AS
I've been seaching and even trying some motion prototypes on my own, but I can't figure it out:

Does any one know how to make shapes appear to move in perspective with ActionScript?

Xml Loops And Planes
Hi all
Can anyone share some light on how I can create these multiple planes using a loop and xml?

Many thanks
ActionScript Code:


Code:

package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.*;
import flash.events.*;
import flash.events.*;
import flash.net.*;
import flash.utils.*;
import flash.display.StageDisplayState;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.objects.Plane;
import org.papervision3d.scenes.MovieScene3D;
import caurina.transitions.Tweener;

public class ExampleCameraHoverType1 extends Sprite
{
private var container :Sprite;
private var scene :MovieScene3D;
private var camera :Camera3D;
private var plane1 :Plane;
private var plane2 :Plane;
private var plane3 :Plane;
private var plane4 :Plane;
private var plane5 :Plane;
private var plane6 :Plane;
private var plane7 :Plane;
private var plane8 :Plane;


public function ExampleCameraHoverType1()
{
container = new Sprite;
container.x = 200;
container.y = 200;
addChild( container );
// stage.displayState = StageDisplayState.FULL_SCREEN;

scene = new MovieScene3D( container );
camera = new Camera3D();
camera.z = -500;
camera.zoom = 3;
camera.focus = 100;


var loader:URLLoader = new URLLoader()
loader.addEventListener(Event.COMPLETE, onLoadXML)
loader.load(new URLRequest("images.xml"))
function onLoadXML(ev:Event){
try{

//Convert the downloaded text into an XML
var myXML:XML = new XML(ev.target.data)
var list:XMLList = myXML.data.title
//walks the list and show in textfields
trace(list);
for(var i=0; i<list.length(); i++){
//trace(list[i].@name+"-"+list[i].comments+" - "+list[i].image)
var L:String = list[i].image;
var material:BitmapFileMaterial = new BitmapFileMaterial(L);
material.doubleSided = true;
material.smooth = true;

//create plane
this["plane"+i] = new Plane( material, 250, 200, 3, 3);

// register plane
scene.addChild( this["plane"+i] );

this["plane"+i].x = 510;
this["plane"+i].container.addEventListener( MouseEvent.CLICK, onMouseOver );


}
} catch (e:TypeError){
//Could not convert the data, probavlu because
//because is not formated correctly
trace("Could not parse the XML")
trace(e.message)
}
}













// create Bitmap texture
// please place a "texture.jpg" file to your code root or change the path





stage.addEventListener( Event.ENTER_FRAME, onEnterFrame );
stage.addEventListener( Event.ENTER_FRAME, threeD_Render );

}

private function onEnterFrame( event: Event ): void
{

// influence the camera with the hover method
camera.hover(1, (100-mouseX)*.002, (200-mouseY)*.002);
// render scene


}

private function onMouseOver( event: MouseEvent ): void
{
stage.removeEventListener( Event.ENTER_FRAME, onEnterFrame );
trace("mosiue");

Tweener.addTween(camera, {x:335, y:320, z:-1800, zoom:9, time:1, transition:"easeOutBack"});
Tweener.addTween(plane2, {x:255, time:1, transition:"easeOutBack"});
//scene.renderCamera( camera );
// render scene

}

private function threeD_Render( event: Event ): void
{
scene.renderCamera( camera );

}
}

}

3D Bitmaps On Planes
I've seen many an example of 3D cubes and 3D objects over the years. I've never had the need to use anything regarding 3D in actionscript. As of late I need to look into how to apply bitmaps to a 3D surface. It doesn't need to go on 6 sides of a cube and spin with the mouse. This is as simple as drawing a 3d plane in space and apply a dynamically loaded bitmap to that plane so that it distorts. I'm hoping some can point me to some tutorials, blog posts, source files or anything else that would help get me started with the Z axis

Loading Xml Loop And New Planes
Hi all
Can anyone share some light on how I can create these multiple planes using a loop and xml?

Many thanks

ActionScript Code:
package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.display.*;
    import flash.events.*;
    import flash.events.*;
    import flash.net.*;
    import flash.utils.*;
    import flash.display.StageDisplayState;
    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.materials.BitmapFileMaterial;
    import org.papervision3d.objects.Plane;
    import org.papervision3d.scenes.MovieScene3D;
    import caurina.transitions.Tweener;
   
    public class ExampleCameraHoverType1 extends Sprite
    {
        private var container   :Sprite;
        private var scene      :MovieScene3D;
        private var camera    :Camera3D;
        private var plane1   :Plane;
        private var plane2   :Plane;
private var plane3   :Plane;
private var plane4   :Plane;
private var plane5   :Plane;
private var plane6   :Plane;
private var plane7   :Plane;
private var plane8   :Plane;


        public function ExampleCameraHoverType1()
        {
            container = new Sprite;
            container.x = 200;
            container.y = 200;
            addChild( container );
 // stage.displayState = StageDisplayState.FULL_SCREEN;
                                   
            scene = new MovieScene3D( container );
            camera = new Camera3D();
            camera.z = -500;
            camera.zoom = 3;
            camera.focus = 100;
           

            var loader:URLLoader = new URLLoader()
loader.addEventListener(Event.COMPLETE, onLoadXML)
loader.load(new URLRequest("images.xml"))
function onLoadXML(ev:Event){
   try{
    
        //Convert the downloaded text into an XML
        var myXML:XML = new XML(ev.target.data)
        var list:XMLList = myXML.data.title
        //walks the list and show in textfields
          trace(list);
        for(var i=0; i<list.length(); i++){
            //trace(list[i].@name+"-"+list[i].comments+" - "+list[i].image)
            var L:String = list[i].image;
            var material:BitmapFileMaterial = new BitmapFileMaterial(L);
            material.doubleSided = true;
            material.smooth = true;
       
            //create plane
            this["plane"+i] = new Plane( material, 250, 200, 3, 3);

            // register plane
            scene.addChild( this["plane"+i] );
           
            this["plane"+i].x = 510;
            this["plane"+i].container.addEventListener( MouseEvent.CLICK, onMouseOver );
           
                 
        }
    } catch (e:TypeError){
        //Could not convert the data, probavlu because
        //because is not formated correctly
        trace("Could not parse the XML")
        trace(e.message)
    }
}
           

       
            stage.addEventListener( Event.ENTER_FRAME, onEnterFrame );
            stage.addEventListener( Event.ENTER_FRAME, threeD_Render );

        }

        private function onEnterFrame( event: Event ): void
        {

            // influence the camera with the hover method
            camera.hover(1, (100-mouseX)*.002, (200-mouseY)*.002);
            // render scene
           

        }

private function onMouseOver( event: MouseEvent ): void
        {
            stage.removeEventListener( Event.ENTER_FRAME, onEnterFrame );
            trace("mosiue");
           
            Tweener.addTween(camera, {x:335, y:320, z:-1800, zoom:9,  time:1, transition:"easeOutBack"});
            Tweener.addTween(plane2, {x:255,   time:1, transition:"easeOutBack"});
//scene.renderCamera( camera );
            // render scene
           
        }
       
        private function threeD_Render( event: Event ): void
        {
        scene.renderCamera( camera );
       
        }
    }
   
}

Papervision3D 2.0 Using Planes/Movieclip
Ok, I got this code from the video tutorial using a cube, but I was wondering to how to use planes instead of cubes? And having the planes be a movieclip rather than a bitmap/static image that doesn't animate. I want the movieclips to animate, and have event handlers where the user can click on the plane, and it opens a animating within the movieclip. Here's the code for a animating cube:

import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.render.*;
import org.papervision3d.view.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.utils.virtualmouse.VirtualM ouse;

//container
var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
addChild(viewport);
viewport.buttonMode = true;

var renderer:BasicRenderEngine = new BasicRenderEngine();

var scene:Scene3D = new Scene3D();

var camera:Camera3D = new Camera3D();
camera.zoom = 11;
camera.focus = 100;


//material
var mam:MovieMaterial = new MovieMaterial(face);
mam.interactive = true;
mam.smooth = true;
mam.animated = true;

var mam2:MovieMaterial = new MovieMaterial(face2);
mam2.interactive = true;
mam2.smooth = true;
mam2.animated = true;

var mam3:MovieMaterial = new MovieMaterial(face3);
mam3.interactive = true;
mam3.smooth = true;
mam3.animated = true;

var mam4:MovieMaterial = new MovieMaterial(face4);
mam4.interactive = true;
mam4.smooth = true;
mam4.animated = true;

var mam5:MovieMaterial = new MovieMaterial(face5);
mam5.interactive = true;
mam5.smooth = true;
mam5.animated = true;

var mam6:MovieMaterial = new MovieMaterial(face6);
mam6.interactive = true;
mam6.smooth = true;
mam6.animated = true;


//cube, 200 200 200 is width depth height, 10, 10, 10 is the triangles rendered(the more, the more cpu heavy)
var cube:Cube = new Cube(new MaterialsList({front:mam, back:mam2, left:mam3, right:mam4,top:mam5, bottom:mam6}), 200, 200, 200, 10, 10, 10);
scene.addChild(cube);


//Enter frame to continously render scene
addEventListener(Event.ENTER_FRAME, loop);

function loop(e:Event):void
{
var xDist:Number = mouseX - stage.stageWidth * 0.5;
var yDist:Number = mouseY - stage.stageHeight * 0.5;
cube.rotationY += xDist * 0.05;
cube.rotationX += -yDist * 0.05;
renderer.renderScene(scene, camera, viewport);
}

face.addEventListener(MouseEvent.CLICK, faceClick);

function faceClick(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.yahoo.com"));
}

face2.addEventListener(MouseEvent.CLICK, face2Click);

function face2Click(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.google.com"));
}

face3.addEventListener(MouseEvent.CLICK, face3Click);

function face3Click(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.flickr.com"));
}

face4.addEventListener(MouseEvent.CLICK, face4Click);

function face4Click(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.youtube.com"));
}

face5.addEventListener(MouseEvent.CLICK, face5Click);

function face5Click(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.facebook.com"));
}

face6.addEventListener(MouseEvent.CLICK, face6Click);

function face6Click(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.adobe.com"));
}

PV3D Interacting With Planes
Hello all, first post so hopefully I'm in the right place.

In my first venture into PV3D, I'm working on an XML-driven Jeopardy game. Typically I'm not satisfied with static, and I'm creating Planes on the fly for each question/answer block. So far I have got it to dynamically add blocks in a nice curved wall and now I'm stumped on the interactivity.

The material for each plane is a three framed movie-clip. Frame one is point value, two is the answer, three is the question. When I run my swf right now, everything comes up with a point value. This is where I'm stuck. I know I can change the Material when I click, but I don't know how to target a specific dynamic square and its specific instance of the Material MovieClip.

Basically all I'm making is a 3D Wall, in case I confused anyone with the above.

Here's the relevent AS so far:
Code:

import org.papervision3d.scenes.*;
import org.papervision3d.cameras.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.materials.shaders.*;
import org.papervision3d.materials.utils.*;
import org.papervision3d.lights.*;
import org.papervision3d.render.*;
import org.papervision3d.view.*;
import org.papervision3d.events.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.core.utils.virtualmouse.VirtualMouse;
import org.papervision3d.events.*;

//Setup container for 3D scene
var viewport:Viewport3D = new Viewport3D(0, 0, true, true);
addChild(viewport);

//Shows hand cursor when you roll over clickable items
viewport.buttonMode = true;

//Create rendering engine
var renderer:BasicRenderEngine = new BasicRenderEngine();

//Create Scene
var scene:Scene3D = new Scene3D();

//Create camera
var camera:Camera3D = new Camera3D();
camera.zoom = 9;
camera.focus= 100;

//Create Materials

var mm2:MovieMaterial = new MovieMaterial(face2);
mm2.interactive = true;
mm2.animated = true;
mm2.smooth = true;

//Trigonometric Calculations for curved wall of screens

//Variable Elements
var numCols:Number = 6; //Number of items on stage
var numRows:Number = 6;
var itemWidth:Number = 230; //Width in pixels
var itemHeight:Number = 200; //Height in pixels
var itemMargin:Number = 5; //Margin width in pixels
var radius:Number = 900; //Radius of curvature

var cubes:Array = new Array();
var materials:Array = new Array();

//Calculated elements
var arcTheta:Number; //Total arc of the screen (determined later, used to center screen)
var theta:Number; //Instantaneous theta of items

//Get half angle
var itemTheta:Number = Math.atan((itemWidth + (itemMargin * 2))/radius);
arcTheta = (numCols-1) * itemTheta;
theta = ((90*Math.PI)/180) - arcTheta/2;

trace("Circ = " + (2 * Math.PI * radius));
trace("Item Arc = " + itemTheta + "rads ( " + ((180 * itemTheta)/Math.PI) + "degs )");
trace("Total Arc = " + arcTheta + "rads ( " + ((180 * arcTheta)/Math.PI) + "degs )");
trace("Starting Arc = " + theta + "rads ( " + ((180 * theta)/Math.PI) + "degs )");
trace("");

for(var i = 0; i < numCols; i++)
{
   cubes[i] = new Array();
   materials[i] = new Array();
   for( var j = 0; j < numRows; j++)
   {
      materials[i][j] = new square();
      var temp = materials[i][j];
      var mm:MovieMaterial = new MovieMaterial(temp);
      mm.interactive = true;
      mm.animated = true;
      mm.smooth = true;
   
      var cube:Plane = new Plane(mm, itemWidth, itemHeight, 3, 3);
      cube.y = j * (itemHeight + (2*itemMargin));
      
      trace("");
      trace("ITEM " + i + "-" + j + " = Theta( " + theta + ") ==================================");
      trace("");
      cube.x = (radius * Math.cos(theta))
      trace("   X = " + cube.x + "px");
      cube.z = (radius * Math.sin(theta))
      trace("   Y = " + (radius * Math.sin(theta)) + "px");                                    
      cube.rotationY += (90 - ((theta * 180)/Math.PI));
      trace("   R = " + cube.rotationY);
      trace("");
      function cubeClick(e:InteractiveScene3DEvent) {
         trace(e);
         temp.gotoAndPlay(temp.currentFrame + 1);
         var newM:MovieMaterial = new MovieMaterial(temp);
         newM.interactive = true;
         newM.animated = true;
         newM.smooth = true;
         this.mm = newM;
         
         renderer.renderScene(scene, camera, viewport);
      }
      
      cubes[i][j] = cube;
      cubes[i][j].addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, cubeClick);
      scene.addChild(cubes[i][j]);
   }
   
   theta += itemTheta;
}
camera.y = ((numRows-2)*(itemHeight + (2*itemMargin)))/2;
camera.rotationX += -5;
renderer.renderScene(scene, camera, viewport);



If some of that looked familiar I used Lee's 3D cube tutorial as my starting point and I've been working from there. Also, I'm calling panels cubes because I started using blocks rather than planes.

If anyone knows where to start helping withthis I'd appreciate it.

Papervision3D Planes Overlapping Problem
http://omgplaylist.com/playa/

i have planes that fight for being on top of each other. the planes only have 4 segments for speed reasons. anything more than that and it's slow. the button in the topleft corner toggles a zoom.

google/the search was no help. has anyone had that issue before? adding segments to the planes didn't help.

thanks.

Movie Clip Materials On Planes
Ok so i have a couple of planes that I have been playing around with but im having dificulty assining a movie clip as a material. I think I might be missing a simple peice of the puzzle.

Here is what im doing.

Code:

//Making material
var movieMat:MovieMaterial = new MovieMaterial(mcMat);
movieMat.interactive = true;
movieMat.smooth = true;
movieMat.animated = true;

//making a plane and attaching it to a holder
var plane:Plane = new Plane(mcMat,500,500)
plane.x = -500 + -50;

//add to holder
holder.addChild(plane)

but i keep getting errors can you guys help ? Thanks again.

Interactive Planes With Papervision3d, Great White.
I just recently started to play with papervision and its great fun, right now im trying to do a photogallery.

The reason why im posting here is because I cannot get the MouseEvent.CLICK to work. I've checked out Lee Brimelow's tutorials(thanks Lee!) but I still couldn't figure out where the problem was.

So this is the material im using_
Code:

var AOT:MovieAssetMaterial = new MovieAssetMaterial("antonOllieTweakMC");
AOT.interactive = true;
AOT.oneSide = true;
AOT.smooth = true;
As you can see, its interactive, and im using the MovieAssetMaterial. Is there any other more suiteble material to use?

And this is the plane code I use:
Code:

var plane2:Plane = new Plane(AOT, 297, 400, 2, 2);
scene.addChild(plane2)
plane2.x = 350;
plane2.y = 0;
plane2.z = 0;
I can see it on the stage and it works just great.

This is the code I use to make the plane interactive:
Code:

plane2.addEventListener(MouseEvent.CLICK, plane2Click);
function plane2Click(e:MouseEvent):void
{
   trace("hi");
}
When I start the movie everything works just fine, but it won't trace when the plane is clicked, where did I go wrong?

I can post the .fla or any other information that you guys might need to help me out. Thanks in advance, and I hope this post is understandable.

Yours, Peter

How Do I Make Buttons That Just Make A Movie Carry On?
I am trying to figure out either how to make a movie end, instead of keep going around, and around again in a loop. Or, I need to know how to get a replay button.

Thanks Please help.

--LONDONABOY--

Irregular HitTest
ive recently made a game in which you have to avoid some big evil round planets. i found out the in the making of that that using the function hittest uses square objects. i dident bother much then with it, i just brought out the ol'e algebra book and looked up the distance formual and made my own hittest.

now my questyion is is there a more refined way of using hittest for a more irregular object than a circle.

I made somewhat irregualr objects have hittest boxxes so that it was split up into many smaller parts, this gets kinda tedious if its really irregualr or if i need to move it around on the screen

btw if anyone wants ta c the game i made
http://xev.mine.nu/jens/revengeofdots.html
avoid everyting , and shop at the store on the planet , u can go over the big planet in lower left corner but not the ones in orbit
a few bugs still like only way to restart is the reload button in browser

Irregular HitTest
ive recently made a game in which you have to avoid some big evil round planets. i found out the in the making of that that using the function hittest uses square objects. i dident bother much then with it, i just brought out the ol'e algebra book and looked up the distance formual and made my own hittest.

now my questyion is is there a more refined way of using hittest for a more irregular object than a circle.

I made somewhat irregualr objects have hittest boxxes so that it was split up into many smaller parts, this gets kinda tedious if its really irregualr or if i need to move it around on the screen

btw if anyone wants ta c the game i made
http://xev.mine.nu/jens/revengeofdots.html
avoid everyting , and shop at the store on the planet , u can go over the big planet in lower left corner but not the ones in orbit
a few bugs still like only way to restart is the reload button in browser

Irregular Loading Position
Hi
I have loadmovie actions that loads several swf`s into
a their seperate movieclips in my main movie-simple...

On these movieclips I have a load movie action on the first frame,then a blanc and then in the third frame, a setproperty action to position the swf`s where they should be.

when I test/export my movie, the swf`s are sometimes (irregularly)
positioned in the default top left position.When I repeat the action it positions correctly.

This is frustrating- I don`t know what I`m doing wrong.
Please help me.
Thanks for your time.

Irregular Or Circular Hittest
Hi everyone,
I would reallly like to learn how to create an irregular or circular hittest. If anyone knows a link to a tutorial or can explain the code, please reply.
Oh and I was thinknig of getting a book on Actionscript, I use Flash MX, and I was wondering whjat would be the best one.
Cheers

HitTest Irregular Shape
I've created an irregular shape movieclip and would like to do a hitTest testing. Whenever I hit the boundary of the "movieclip" itself, hitTest would give me a true value. But my purpose was it would only give me a true value ONLY when I hit the shape itself. How can I do this?

Thanks.

Dragable Within Irregular Shape?
i have something that i want to be dragable, but let's say i want it to stay within a trapazoid shape. How can i do this?

How To Draw Irregular Polygons?
I know I can use the polyStar tool to draw regular polygons and stars, but HOW do I draw irregular polygons?

I know I can use the lasso tool to "create" irregular polygon selection shapes, but I can't see how to convert those to line-polygons.

HELP!

Movement Along An Irregular Surface
I'm developing a platform game in Flash 8 and I don't know how to make the character automatically run along a hill or some irregular ground like that. It's all fine to have them run along some square symbol you can make in 5 seconds but any help on this is appreciated.

Thanks

Irregular Collision Detection
how do you make an object roll along an irregular surface? I'm trying to code a character that runs around on hills and stuff and i don't know how to do it and any help would be appreciated.

Thanks.

Irregular Mask Behaviour?
Hi all, I have recently jumped back on the flash bandwagon (after a lengthy absence)…banged an old website of mine into 8, that had a scrolling MC filled with text and pics (just wish to make a few alterations), and more importantly- the thought of adding a gradient mask here and there appealed greatly. Problem is, all works well until little orange lines appear randomly (the border of the MC scrolling object underneath the mask/ and partial mask disappearance underneath the objects that are above the mask) whilst scrolling?? Any ideas to what’s coursing this / the mask obviously…but why?

Any help appreciated (hoping its something simple)- Cheers!

HitTest With Two Irregular Shapes
Does anyone have a clue how i can hitTest two irregular shapes.

What i have done so far works fine with one irregular shape. I loop through my target movieclip, and assign their X and Y value to an Object, like this:

--------------------------------------------------
for(var i in arrEnemy[enemyIndex].hit) {
enemyHit = new Object();
enemyHit.x = arrEnemy[enemyIndex].hit[i]._x;
enemyHit.y = arrEnemy[enemyIndex].hit[i]._y;
arrEnemy[enemyIndex].localToGlobal(enemyHit);
if(arrLaban[labanIndex].hitTest(enemyHit.x, enemyHit.y, true)) {
trace ("busted");
}
}
--------------------------------------------------

But now I have to irregular shapes, and I need your help to figure out how to hitTest those shapes!

Best Regards
Eirik

[Q] HitTest With Irregular Shape...
Howdy...

One of those 'Um' moment has struck me again, as usual...

If you have a slanted box and a star shape which you want to do the hitTest, you cannot really use hitTest() function because it will be checking the bounding box of the slanted box... (Please see an attached file for better explanation...)

The only thing I can currently think of is to create multiple invisible box movieClips that covers the slanted area, but that does add some CPU problem if the shape is really irregular... I think I have used something that's totally different than that, but my brain just does not remember that...

Does anybody know how to do this in AS1/AS2/FMX 2004???

Irregular Shape Detection
I have a challenging question for an Actionscript genius.

I want to populate an irregular shaped area with a given amount of clips randomly.

Traditionally I would use a method like:


Code:
// For each clip
x = Math.random()*area.width;
y = Math.random()*area.height;
However, this assumes the boundaries are rectangular, what about when they are irregular?

This diagram shows a simple example:



My initial thoughts were to create a bitmapData object from the shape, then loop through in a grid like fashion within the rectangular boundaries, pushing coorinates into an array if there is pixel data at that position. So I would end up with something like so:



This is satisfactory, yet rather than adding one clip for every point detected inside the shape, I would rather add a predefined amount of clips to the shape, and for these clips to be scattered randomly throughout the shape. As in the example below:



I appreciate that often this would not give me an accurate visual representation of the shape, as the random factor may cause the added clips to give less indication of the exact boundaries of the shape, or for their own shapes to spill outside of the main shape. None the less, this is what I need for the project!

Do any of the more mathematically endowed out there have any suggestions?

If not for a direct solution, perhaps for a more optimal way of achieving the irregular grid approach I mentioned in the first diagram?

This may not be AS3 persay (though it is for an AS3 project), however I have a feeling there may be new methods in AS3 to at least help make this possible, hence the post in this forum.

Thank you in advance

BitmapFill An Irregular Shape
Hello everybody, I'm just learning AS3 and I have the following question.
I'd like to apply a bitmap to a very irregular shape.
What I did is:

1) load the image from disk with the URLRequest class
2) create an irregular shape using CurveTo
3) apply the image using beginBitmapFill

The result is that the image texture coordinates are completely messed up in the shape, so the image is not even recognizable.
Just note that if I use a rectangle instead of the irregular shape, the image is properly shown.
So now I'm wondering if there is a way to define the image coordinates with the Matrix applied with BeginBitmapFill.

Give me some hints please...

Cutting Irregular Shapes
I needed a way to cut out irregular shapes and didn't see any post about this on the forms so I thought I'd share. The process is quite fast (I would have thought I would have taken more clock cycles), but if anyone has some optimizations feel free.

In the attached files, click on the image and drag.

Cheers
fg

Irregular Shape HitTest
http://flash-creations.com/notes/astb_bounceCollide.php


link above

the irregular hitTest dowloaded the fla from the website link above, on the border edge of the shape inivisble movieclips are placed, now i dont need the complicated movement part just ireggular shape part for the hitTest ........


if any 1 checks out the download how do place the invis clips movie place the invis movie clips on stage or nested inside




//important not my code//

// for each sentry in this clip ("clip b")
for (i in this.perim) {
// get the sentry's point on the stage
this.perim.localToGlobal(p={x:this.perim[i]._x,y:this.perim[i]._y});
// see if it's touching o ("clip a")
if(o.hitTest(p.x, p.y, true)){
o._alpha=50;
}
}

Irregular Button Shapes
Hello,
I have an image that I import to flash movie. In the image there are certain shapes that I would like to make buttons. So, I trace the bitmap, use the free transform tool to select the shape and right click on it and convert to symbol. This basically gets what I want, but I would rather have these buttons that I am creating, be instances of one main button so that I can create on onpress function for all of them. There could be anywhere from 5 to 150 of those irregular shapes that need to be buttons.

Anyone have an idea about how to go about this?
Thank You

Drawing Irregular Shapes? HELP?
Hi,

I'm looking for some assistance in using the drawing API to draw irregular, random type curved shapes.

An example would be to generate different amoebas or 'blobs'.

Thanks in advance, I'm really stuck on this on.

b

BitmapData Onto Irregular Shape
How can I attachBitmap to an irregular shape?

I load a pattern into my movie (pattern.jpg), it is a square image 500x500. I want to draw that image onto an irregular shape. If I do the following it simply shows the large square overtop of my shape. The pattern isn't actually applied to my shape.


Code:
var bitmap:BitmapData = new BitmapData(500, 500, true, 0x00000000);
myShape.attachBitmap(bitmap,1,"auto",true);
bitmap.draw(pattern);
Any Ideas?

Thanks

A Very Irregular Variable Problem
I'm trying to combine two variables as moviecliip name so that I dont have to type it out a million times I can just use a loop... however it doesn't seem to work... heres an example...


Code:
var num = 1;
_root.attachMovie("box","box"+num,1);
var locate = "box"+num;
locate._x = 40;
box1._y = 20;
box1.date_txt.text = 25;
var num = num + 1;
now the y shows up but the x doesn't show... it just starts at the default 0... I know that the "box" shouldn't be in quotations however whenever I take the quotations out... it identifies box as a number... which it obviously isn't..

Now I have tried every possible combination of things even making a seperate varable named box = "box" nad making location = box+num (taking out that NaN factor) but that doesn't work either... it traces the right word but it doesn't factor in...

Scrolling Text On An Irregular Curve?
Hi,

I'm wondering if there is an easy way to scroll text on an irregular curve. Here's a visual example just to illustrate what I'm after:

http://www.turnerdesign.net/scrollingtext/

I don't want to convert the text to graphics if I don't have to, as it's going to be some sort of "news ticker" type thing.

Thanks,
Andrew

Drawing Irregular Polygon With Trig - Help
Okay, I'm generating 4 random angles for the sides of my irregular quadrilateral.
I am then using these angles to determine the co-ords of my four corners.
Lastly, I am drawing lines between the corners to construct my quad.

This all seems to work, until I look at the angles....which are all wrong!
So, what am I doing? Am I on totally the wrong track?

Thanks ;-)



Code:
vRoot = this;

vA = random(10)+80;
vB = random(21)+100;
vC = random(11)+70;
vD = 360 - (vA+vB+vC);

//start position of bottom left (vA)
vX = 100;
vY = 300;

//size of the quad base
vSize = 300;

//convert degrees to radians
function fToRad(angle){
return angle * (Math.PI/180);
}

//calculate corner co-ords
v1X = Math.cos(fToRad(vA))*vSize + vX;
v1Y = vY - Math.sin(fToRad(vA))*vSize;

v2X = Math.cos(fToRad(vB-vA))*vSize + v1X;
v2Y = v1Y + Math.sin(fToRad(vB+vA))*vSize;

v3X = Math.cos(fToRad(vC-vB-vA))*vSize + v2X;
v3Y = v1Y - Math.sin(fToRad(vC+vB+vA))*vSize;

//draw polygon
vRoot.createEmptyMovieClip("mcDraw",vRoot.getNextHighestDepth());
mcDraw.moveTo(vX,vY);
mcDraw.lineStyle(2,0xAA2222,100);
mcDraw.lineTo(v1X,v1Y);
mcDraw.lineTo(v2X,v2Y);
mcDraw.lineTo(v3X,v3Y);
mcDraw.lineTo(vX,vY);

Problem With Irregular MC Playing Speed
Hi guys,

I was wondering if any of you ever had this problem before,
I made a button out of MC and use Dynamic Text for the name (like HOME, CONTACT and so on) and inside this button MC, i place another MC which is a little arrow that suppose to blink fast whenever the mouse is over this button MC.
Everything works perfectly until i embedded the fonts, and the arrow blinks in irregular speed. Sometimes fast (as what it should be), but sometimes it blinks slowly.
Then i swapped it to Static Text, but the problem remains.
It only blinks at the correct speed if I use Dynamic Text and NOT embed the fonts.
Just wondering if anyone has any solutions or any ideas what causes this?

Cheers

Wheels Running Over An Irregular Shape.
Hi Flash Geniuses!


I wish somebody could help me with my problem regarding a Wheel MC that runs over an irregularly shaped surface. Controlling Wheel MC to run in a smooth, horizaontal surface is very easy because its surface is fixed. But how about controlling an MC to roll over an irregularly shaped MC (Example, a slope). Is there an easy method doing it? Or I must look back at my Maths and work with a very deep programming? I hope somebody out there could help me with this. Thanks!


Chris Lionheart

Collisions Hittest For Irregular Shapes?
I need one of these but for AS3:

http://www.gskinner.com/blog/archive..._code_sha.html

Problem HitTest For An Irregular Shape
hiTest in flash the bounding box is the shape for the hit test, is possible to do a hittest with an iregular shape, ive seen something about a flag, l
or does using api drawing tools does that take the exact cordinates of the shape

does the flag work

if (sprite.hitTest(isometricFloorPlan)){

Gravity And Irregular Ground Shape.
might be fairly basic, but i dont know where to begin. So i've got a ball, and its got actionscript for it to fall at a normal gravity effect, and its got bounce scripted into it as well when it reaches a y axis value of 400.

Since i've got that scripting pretty much figured out i want to go a step further and have it land on a non-level irregular shaped surface. Say, for instance, a valley shaped movieclip. I don't want it to hit the movieclip using hitTest and have it bounce straight back up from the spot it hit, but make it more realistic and have the ball bounce based on the slant and have it roll towards the middle like a ball hypothetically would.

Its one of those things where i know what i want to happen, i have an idea about how to do it, i dont know where to start. Thanks

Irregular Shaped Rollover Using Bitmap
Hi,

Hope I'm in the right forum. This should be easy but for some reason I have a brain cramp on this. I have one that works properly and one that doesn't and I can't figure out why. I'm sure there is a rule of thumb for all this but its eluding me.

Enought of my incompetent rambling ...

I want to use an irregularly shaped bitmap (PNG) from Fireworks for a button but the rollover responds to the bounding rectangle, and not the shape of the bitmap. ??

TIA,
Randy

Flash Movieclip Around Irregular Shape
Hello everyone,
I have an irregular Shape that I drew in flash. It looks like the pizza hut symbol. When I make it into a movieclip, the movieclip rectangle goes around the edges. How can I make it surround the boundaries (ex. go directly on the boundary lines of the shape)?

Thanks,
iloveisrael.

Find The Center Of An Irregular Polygon
Does any one have code that can determine the center of an irregular 3 sided polygon?
Using a bounding box does not work.
If you know how to draw one using the center point as the registration point that would be great.
Thanks,
Ethan

Random Motion With Irregular Shape...
Hello,

I'm using Flash5 and was wondering if anyone knows how to create random motion of an object within an irregular shape?

I have an ob-long rectangle which 'flares' on each end and would like to place some graphics in random motion within this irregular shape. Kirupa has a nice tutorial on random motion, which I can follow and re-produce no problem. However, with his tut, he uses

movie_height = 150;
movie_width = 300;

But I want to specify the top, bottom, left and right edges, which are irregular. Should I create a mask and use that? or can I achieve this another way using actionscript? thanks for your help!! dave.

Random Motion With Irregular Shape...
Hello,

I'm using Flash5 and was wondering if anyone knows how to create random motion of an object within an irregular shape?

I have an ob-long rectangle which 'flares' on each end and would like to place some graphics in random motion within this irregular shape. Kirupa has a nice tutorial on random motion, which I can follow and re-produce no problem. However, with his tut, he uses

movie_height = 150;
movie_width = 300;

But I want to specify the top, bottom, left and right edges, which are irregular. Should I create a mask and use that? or can I achieve this another way using actionscript? thanks for your help!! dave.

Constrain MovieClip To Irregular Area
Hello!

I am looking to constrain a draggable movieclip within a non-rectangular (pie shaped) area... using AS3. I can drag out the old trig books, but thought some Flash whiz may have a shortcut approach to get me started. Any ideas? Thanks.

Fill Irregular Shape Once Drawn
I've used the drawing API to allow the user to draw with the mouse. When they release the mouse button, the shape is automatically completed using lineTo(startX,startY) which were defined when the line was begun. Is it possible, once the shape is complete to automatically fill it, or even better, fade in a fill color from alpha 0?


Code:
package {


import coreyoneil.collision.CollisionList;

import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;



public class lasso extends Sprite{
public var _sprite:Sprite = new Sprite();
public static var animalList:CollisionList;
private var shapeStartX:Number;
private var shapeStartY:Number;
private var myHitTest:HitTest = new HitTest();
private var startX:Number;
private var startY:Number;


public function lasso(){

this.addChild(_sprite);
_sprite.addEventListener(Event.ADDED_TO_STAGE, listMaker);

_sprite.graphics.beginFill(0xFFFFFF);
_sprite.graphics.drawRect(0, 0, 800, 600);
_sprite.graphics.endFill();


_sprite.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
_sprite.addEventListener(MouseEvent.MOUSE_UP, onMouseUp);

}


//mouse functions for drawing
private function onMouseDown(event:MouseEvent):void{

for(var x:uint=0;x<level.aniArray.length;x++) {
animalList.addItem(level.aniArray[x]);

}


startX = mouseX;
startY = mouseY;
_sprite.addEventListener(Event.ENTER_FRAME,myHitTest.lassoCrash);
_sprite.graphics.lineStyle(10, 0xcccccc, 1);
_sprite.graphics.moveTo(mouseX, mouseY);
_sprite.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
trace("startX is "+startX);
trace("startY is "+startY);

}


private function onMouseUp(event:MouseEvent):void{
var endX:Number = mouseX;
var endY:Number = mouseY;
_sprite.graphics.lineTo(startX, startY);

_sprite.removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
_sprite.removeEventListener(Event.MOUSE_LEAVE,mouseExit);
_sprite.removeEventListener(Event.ENTER_FRAME,myHitTest.lassoCrash);

}


private function onMouseMove(event:MouseEvent):void{

_sprite.graphics.lineTo(mouseX, mouseY);
_sprite.addEventListener(Event.MOUSE_LEAVE,mouseExit);

}

private function listMaker(event:Event):void {
animalList=new CollisionList(_sprite);
animalList.excludeColor(0xFFFFFF);
}

private function mouseExit():void {
_sprite.graphics.lineTo(startX,startY);
}

}
}

Dynamically Draw Irregular Shapes
is there a way to dynamically draw irregular shapes and apply smoothing to them

Copyright © 2005-08 www.BigResource.com, All rights reserved