Beginer Faces Actionscript, Help
Hii m a beginer in actionscript, just struggling what's the effective way for me to start learning/practising actionscript to become advanced user.*I've learnt some programming stuff before: C programing, VB, database, a bit of ASP & PHP & javascrit, BUT just dont know how to get started to make use of the actionscript to enrich my flash stuff..*The actionscript tutorial in this site divided into different section that seems not Im looking for in this stage, im looking for some tutorials teaching you from the very beginning (more guidence instead of learn a piece of script here & jump to learn a piece there) ThAnks..Tom
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 06-24-2004, 09:23 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Beginer Faces Actionscript, Help
Hi
i m a beginer in actionscript, just struggling what's the effective way for me to start learning/practising actionscript to become advanced user.
*I've learnt some programming stuff before: C programing, VB, database, a bit of ASP & PHP & javascrit, BUT just dont know how to get started to make use of the actionscript to enrich my flash stuff..
*The actionscript tutorial in this site divided into different section that seems not Im looking for in this stage, im looking for some tutorials teaching you from the very beginning (more guidence instead of learn a piece of script here & jump to learn a piece there)
ThAnks..
Tom
Actionscript Beginer
hi, could someone please post a link to beginer actionscript tutorials.
i tried in tutorials, but couldn't find a beginer one.
there was a few links in a "games" thread, but cant find the thread.
much appriciated.
Beginer With Actionscript
hi im fairly new to flash and will appreciate any and all help given.
my aim is to get the movie clip (bar shapes) to move up and down randomly over time.
this is the actionscript ive done so far.
by the way im using flash 8 so i beleive that its actionscript 2.
on enterFrame
{
var someValue:Number = Math.random()*100;
}
for (var k : Number = 0; k++; k<10)
{
"bar" + k + "_mc"._yscale = someValue;
};
_root["bar" + k + "_mc"]._yscale = 50;
Beginer With Actionscript
hi im fairly new to flash and will appreciate any and all help given.
my aim is to get the movie clip (bar shapes) to move up and down randomly over time.
this is the actionscript ive done so far.
by the way im using flash 8 so i beleive that its actionscript 2.
on enterFrame
{
var someValue:Number = Math.random()*100;
}
for (var k : Number = 0; k++; k<10)
{
"bar" + k + "_mc"._yscale = someValue;
};
_root["bar" + k + "_mc"]._yscale = 50;
Beginer Help
Im just starting with Flash, and I cant figure out how to get a layer to stay visible after the end of an effect.
Im trying to make a flash that is like someone is drawing lines in a picture. So i need the previous lines to stay visible, when the next line is drawn.
Any suggestions?
There is probably a simple answer that im overlooking, but its usually better just to ask, instead of spending hours searching and trying things.
Thanks guys!
~M
Total Beginer
I have the template below how would i change the number plate and logo?
Beginer Help (probably A Silly ?)
Im just starting with Flash, and I cant figure out how to get a layer to stay visible after the end of an effect.
Im trying to make a flash that is like someone is drawing lines in a picture. So i need the previous lines to stay visible, when the next line is drawn.
Any suggestions?
There is probably a simple answer that im overlooking, but its usually better just to ask, instead of spending hours searching and trying things.
Thanks guys!
~M
Beginer Flash Help
New to the forum and learning about Flash.
I use NVU to create my basic web pages but am trying to add a video spokesperson to my site. Do I need Flash for this? Are there any good tutorials out there on how to do this?
Thanks for any help guys!!
Beginer For Look For Action Script Help......
Hi,
I have never learn any programming before.I am actually look for a simple script which is like motion tween move the ball/graphic from the left to right or any angle position (example A point to B point), I found some on the website but all of them have to attach to a button command which what I am trying to do is no button but the motion tween will stop at certain position and fade out….
Is that any simple script for a beginner???
Thx.
Regards
csi
Beginer For Look For Action Script Help......
Hi,
I have never learn any programming before.I am actually look for a simple script which is like motion tween move the ball/graphic from the left to right or any angle position (example A point to B point), I found some on the website but all of them have to attach to a button command which what I am trying to do is no button but the motion tween will stop at certain position and fade out….
Is that any simple script for a beginner???
Thx.
Regards
csi
Beginer Class Problem
Runtime error at the line : var mcp: MovieClipPlus = MovieClipPlus(mc);
It doesnt work.. how can I let mcp inherit the mc?
Attach Code
////////////////////////////////////////////////////
import MovieClipPlus.as
var mc: MovieClip = new MovieClip();
var mcp: MovieClipPlus = MovieClipPlus(mc);
//--- MovieClipPlus.as
package {
import flash.display.*;
public class MovieClipPlus extends MovieClip {
public var var1: int;
public var var2: int;
public function MovieClipPlus():void {
var1 = 0;
var1 = 0;
}
}
}
Total Beginer 3d Photographs
Hi can anyone help I am a total newcomer to flash.
I have a series of 24 photographs of a shoe, I have put them into flash and they continually run in a cycle.
This is what I want as it looks like the shoe is rotating but I want the code so that the shoe is still until it is dragged across by the mouse left and right
Like the examples on this link
http://www.photo-mojo.co.uk/Templates/DCe_Default.asp?modeID=Content&uID=91&DoLogin=
Can anyone help please?
Also can I use the same code next time i want to do this type of thing?
Thanks sdo1http://www.photo-mojo.co.uk/Templates/DCe_Default.asp?modeID=Content&uI
Papervision Beginer Questions
Hey gang,
Following Lee's super tuts on Papervision I wanted to continue my learning, but frankly I'm not finding a lot of great documentation. Thus I have some very basic questions I was hoping you can answer with at least a yes or no.
1.) Is it possible to establish a pivot point for an object in Papervision. A point from which it can rotate even if that is not the center of the object or the stage? Imagine a door in the center of the screen. If it were to open it would be from the hinge on the edge, not the center. Is this possible?
2.) Is it possible to position materials on a privative? I'm attempting to apply a movie material that involves a mask with animated elements moving beyond the edge of the mask at times. I find this is a problem for papervision as it seems to try to register a movie material based on the top left element in the movie. Since in my case that elements are moving, my material is constantly jumping around as well. How could I establish a fixed position for the material?
Thanks you in advance!
Ecksley
Learn To A Beginer To Make A Pre-loader
Hi. I'm so new at this forum but i love flash.
i just finished my last work in flash but don't know how to put a pre-loader at the first of the movie.what about actions???? for the god's sake help me cuz i really need it.
TKS.<
Absolute Beginer Question About Buttons
Hello all,
I'm trying to make buttons. The animation works when I "enable simple buttons" inside of Flash.
Problem: When I publish to HTML the button doesn't work. The mouse over doesn't work and the actions don't work either. It just acts like text. Sitting there frustrating me.
Can you help?
Thanks
Sound On/off Button Beginer Question
I have a simple audio on / off button in a movie clip. By default the sound is playing and when the button is pressed the play head jumps to the off state. On my first frame in my actions layer I have a stop action to prevent the play head going to the off state on its own.
This all works fine until I have an instance of this button in my main time line animation. I'm find that if I turn off the audio it turns its self back on again when the play head loops i.e. goes back to the first frame.
How do I stop this. I need the main play head to not trip the audio back on.
Any help will be greatly appreciated.
Thanks
Ricky55
Switching Faces
Ok heres the situation, I have a osama bin laden flash game, where you have to shoot him when his head pops up. I was wondering if there was a program that would allow me to just simply switch the face of Osama to a pic of a friend of mine. I just learning Macromedia right now and I know very little. I thought a fun project would enlighten me a bit
Please help, any info you could spare would be much appreciated
thanx in advance
How Do I Do The 'faces' Game?
does any one remember the game "faces" where you can mix 'n match faces can any one give me a suggestion of how i can do this?: i've made a start using masking but i don't know if that was such a good idea. would i have to do each component of the faces individually and use actions? there has to be an eaier way surely
Tweeninig Faces...
HI.
I am tring to tween one face into another, I start with a bmp, trace it, then shape tween it, one comes in from the corner, and goes out as the other is coming in. Is there a way to tween from one shape to another?
tnks
Animating Faces..
Hey,
Quick question, I have just done a drawing of scooby doo and shaggy, and I want to be able to animate shaggy's mouth. He is smiling, but I want to make it so he smiles, then it moves into a shocked looked. I have been trying to do this for past hour now lol, and have had no success, anyone got any ideas?
Thanks,
Paul
Moving Faces
We are tring to produce moving charachters as in
http://www.oddcast.com/home/sitepal and various others. We have the lypsync
okay but how do we create the face to move following the mouse and turning
as if it is 3D.
Any help appreciated
SteveW
Faces And Depths
Um, i am not really asking for help on faces and depths, but there is a tutorial on kirupa.com thats called "Faces and Depths" its by Senocular, i was wondering if i could find the final .fla of that tutorial and if it is possible to use that cube as a navigation button.
Faces On Hillmancurtis
I realyl wonder if those faces appear on hillmancurtis' site are video files ?
If so how did they play so slowmotion like that? How its done ?
Faces And Depths
Um, i am not really asking for help on faces and depths, but there is a tutorial on kirupa.com thats called "Faces and Depths" its by Senocular, i was wondering if i could find the final .fla of that tutorial and if it is possible to use that cube as a navigation button.
Faces On Hillmancurtis
I realyl wonder if those faces appear on hillmancurtis' site are video files ?
If so how did they play so slowmotion like that? How its done ?
Lets Try This Agian, Simple Question From A Beginer
in this script a button plays from frame 28 and stops at 47. im trying to make the movie not play if the current frame is 47, but play at any other frame number.... help me out.
on (rollOver) {
gotoAndPlay(2);
}
on (rollOut) {
gotoAndPlay(8);
}
on (release) {
if (_root._currentframe == 47) {
_root.stop();
}
}
on (release) {
tellTarget ("../") {
gotoAndPlay("scene1", 29);
}
}
Beginer Question - Stop Sound From Another Button.
I used the Flash MP3 player tutorial to add music to my site, but I have a small problem, that I am sure is an easy fix.
My site also has a video clip with sound on one of the pages. I want the music from the mp3 player to stop when the clip plays.
I was trying to use the stopAllSound command, and I tried to use the same PaseIt script - but I think my problem is with my action script. If a movie clip (acting as a button) is inside another movie clip how do I access that from the action script.
does it need the _parent?
Again, in my timeline I have a "navigation" movie with a "b7" movie. And that's the one I want to stop the mp3 player.
Thanks,
Rick
Assigning Font Faces
How do you assign a font face to text field variable using actionscript.
Anyone?
Moving Faces And Eyes
I have a face I want to move with the mouse. I want it to move certain facial positions per mouse position. I got the eyes to do that, but I had to set them to conform to a rectangle. I made it so the face moves to buttons outside of the face but it wont work on one side, because of the rectangle constraints. If anyone knows WHAT to do or how to make it, please help me. There are examples just like what i want on oddcast.com I'd be VERY appreciative if someone would just send me an example file for me to work from. Mine is just a little cartoony figure that I need to use, but I seriously need help. Thanks!
Morphing Faces--tweening Help
Was trying to morph a face on one frame with a different face on a later frame...so that there would be a morph effect...if this is possible, can someone help me out on how to do it? (If the faces need to be symbols-graphic, what tween, etc.) THANKS!
Exotic Font Faces...
Hi there,
I have a quite exotic question I'd like to ask:
If I have to put some Thai-Font into a Flash-Application - what problems do occur, beginning with installing the font on my OS and using this font within TextFields?
My current task is THAI-Font.
I fond a short thread about this, but it didn't really help me.
Does anyone have some advice on this topic?
Cheers,
3D Cube With Moviclip Faces
Has anyone seen an interactive 3D object with each face being a movieclip?
Similar to FLAs > Experimental Actionscript > Basic 3D
but with movieclips on each face.
Or is this impossible??
Multiple Type Faces In Same Text Box?
I wish to to type two different languages in one text box and switch between them.
Currently I'm adding a variable using html without problems as screen captured here:
http://www.serinya.com/font.jpg
However, it would be cool to have a formatting toolbar above the text box (ex: like MS word)for the user to choose the fonts, bold, italic, etc)while typing along.
Anyone?
Kim
3D Cube Spinning With Text On The Faces
Hi Everyone
I was wondering if there is anyone out there that could really help me. I am trying to do a 3D cube in Flash with text on the faces. I have Swift3D if that is a help.
Now what I would like to do with the cube is put text on the faces. And have the user spin the cube with a mouse postion action. I hope somebody understands me here.
It would be much apriciated if someone could help me. Thanks.
Yours faithfully
Leonardo
Smiley Faces In Text Boxes
For a utility I'm involved in making I need to be able to allow the user to be able to insert picture/imagery like smiley faces and the like into a text feild. Is there a way to do this? It needs to look like the smiley face or whatever else, and it needs to flow with the text as text is added or changed before and after it, etc.
Too, the string needs to be able to be extracted and saved out for display in html/asp etc. so I guess the smiley face would need some way of being extracted as the characters that make up that graphic, like the standard "" I guess.
Is this possible or too difficult?
How Many Type Faces Can Flash Handle?
I have a client who wants to use loads of font faces maybe even up to 700 different ones.
I have never seen this many fonts in a Flash movie, but then again I have not heard anything about any limits to how many fonts a flash movie can have.
Does anybody have any experiences with huge amounts of fonts in flash movies??
thanks in advance
Depth Sorting Cube Faces.
Hi,
Im coding a 3d rotating cube. it works fine, however, id like to sort the depths of the faces correctly. i.e. the closest one to you has the highest depth.
in my program, the further away something is, the higher its Z value.
What ive been doing is for each face, i make a total of the Z values for the four corners.
I draw that face with depth (1000 - totalZ).
it works ok sometimes, but other times the wrong faces show on top.
is there another way to sort the faces?
Multiple Type Faces In One Field
What I would like to accomplish is the following:
HTML text field with loaded xml text in HTML format and an attached style sheet. The style sheet has styles that specify fonts that are embedded in the fla's library and the HTML text styles the text accordingly resulting in more that one type face in a dynamic text field. Is this possible?
I know how to do all the above except get more than one font in a field. I can style the text in other ways (size, tracking, color, etc) but not font-family, or whatever the css would be. Perhaps this is not posssible, or can be achieved in another way.
Any help appreciated.
Applying Actions To Faces Of 3d Cube
im throwing together a quick portfolio and i want each face on a 3d cube to go to a different scene in the file on certain clicks on the faces
for instance face1 ("f1.jpg" in the folder that this script is loading the images from) links to "Scene2"
instead of setting the action to apply to the jpg (which i have no clue how to do) i was wondering if there was a way i could define faces of the cube and set actions to it......i am pretty amateur when it comes to actionscript but heres the source code
function rotateByMouse() {
var dx = _xmouse-this._x;
var dy = _ymouse-this._y;
var vAxis = {x:-dy, y:dx, z:0};
var amp = Math.sqrt(dx*dx+dy*dy);
this.rotateCube(vAxis,amp/500);
}
function faceOnAnimation() {
var fo = this.faceOrientation;
this.count++;
this.rotateCube(fo.axis,fo.faceRotate/10);
this.rotateCube(this.getFaceCenter(fo.face), fo.cornerRotate/10);
if (this.count>=10) {
this.onEnterFrame = null;
}
}
//----------------------------
setupFaceAction = function (cube) {
for (var i = 0; i<cube.faceArray.length; i++) {
var face = cube.faceArray[i];
face.onPress = function() {
if (!cube.fading) {
cube.faceOrientation = cube.getFaceOrientation(this);
cube.count = 0;
cube.onEnterFrame = faceOnAnimation;
cube.fading = true;
} else {
cube.fading = false;
cube.onEnterFrame = rotateByMouse;
}
};
}
};
//================================================== ==
for (var i = 0; i<numCube.holderArray.length; i++) {
var holder = numCube.holderArray[i];
var c = holder.attachMovie("charSymbol", "charSymbol", 2);
c.txt.text = holder._parent.id;
}
for (var i = 0; i<picCube.holderArray.length; i++) {
var holder = picCube.holderArray[i];
var c = holder.createEmptyMovieClip("loader", 2);
c.loadMovie("f"+(i+1)+".jpg");
}
setupFaceAction(numCube);
setupFaceAction(picCube);
numCube.onEnterFrame = rotateByMouse;
picCube.onEnterFrame = rotateByMouse;
picCube._xscale = picCube._yscale=150;
Changeing Faces : Panning And Buttons
Confussed Is exactly where I am right now. I'm begging, any one who can help. please save me.
Delima:
I have very little experience with panning and making move controled by the mouse position. I working on redoing my website www.cssolutions.itgo.com before I actually register a domain name and put it out there futher. Im trying to flash it. Here's a breakdonw of what I am trying to do.
1) Im trying to take my logo ball and make it rotate according to where mouse ponter is on it to reveal a link.
2) when the link is clicked the ball rolls (as it would seem ) into the upper right hand corner of the stage and gets small to give the effect that it is rolling into the background and shows a list of links below it
see csball
OOOO
O O
O O
OOOO
|_link1
|_link2
|_link3
3) I have already created the window transitions that will display the contents of each link. and I would like to keep everything as streamline as posible.
Primarily I need help in making the ball rotate and displaying the links
Help me please.
Problem With Tutorial Help 3d Faces And Depth
Hi all, been working thru the tutorials and ive been pretty successful with most of them up until now, when trying the tute from this url
http://www.kirupa.com/developer/acti...ces_depths.htm
Nothing appears when i goto test the movie, any ideas? heres the actionscript code im working with - is this right? is this what is meant to be in place? some of it is included from previous tutorials in the chapter
this.createEmptyMovieClip("theScene", 1);
theScene._x = 150;
theScene._y = 150;
focalLength = 300;
make3DPoint = function(x,y,z){
var point = new Object();
point.x = x;
point.y = y;
point.z = z;
return point;
};
make2DPoint = function(x,y, depth, scaleFactor){
var point = new Object();
point.x = x;
point.y = y;
point.depth = depth;
point.scaleFactor = scaleFactor;
return point;
};
Transform3DPointsTo2DPoints = function(points, axisRotations){
var TransformedPointsArray = [];
var sx = Math.sin(axisRotations.x);
var cx = Math.cos(axisRotations.x);
var sy = Math.sin(axisRotations.y);
var cy = Math.cos(axisRotations.y);
var sz = Math.sin(axisRotations.z);
var cz = Math.cos(axisRotations.z);
var x,y,z, xy,xz, yx,yz, zx,zy, scaleFactor;
var i = points.length;
while (i--){
x = points[i].x;
y = points[i].y;
z = points[i].z;
// rotation around x
xy = cx*y - sx*z;
xz = sx*y + cx*z;
// rotation around y
yz = cy*xz - sy*x;
yx = sy*xz + cy*x;
// rotation around z
zx = cz*yx - sz*xy;
zy = sz*yx + cz*xy;
scaleFactor = focalLength/(focalLength + yz);
x = zx*scaleFactor;
y = zy*scaleFactor;
z = yz;
TransformedPointsArray[i] = make2DPoint(x, y, -z, scaleFactor);
}
return TransformedPointsArray;
};
pointsArray = [
make3DPoint(-50,-50,-50),
make3DPoint(50,-50,-50),
make3DPoint(50,-50,50),
make3DPoint(-50,-50,50),
make3DPoint(-50,50,-50),
make3DPoint(50,50,-50),
make3DPoint(50,50,50),
make3DPoint(-50,50,50)
];
for (i=0; i < pointsArray.length; i++){
attachedObj = theScene.attachMovie("redballoon", "redballoon"+i, i);
}
cubeAxisRotations = make3DPoint(0,0,0);
rotateCube = function(){
cubeAxisRotations.y -= this._xmouse/3000;
cubeAxisRotations.x += this._ymouse/3000;
var screenPoints = Transform3DPointsTo2DPoints(pointsArray, cubeAxisRotations);
for (i=0; i < pointsArray.length; i++){
currBalloon = this["balloon"+i];
currBalloon._x = screenPoints[i].x;
currBalloon._y = screenPoints[i].y;
currBalloon._xscale = currBalloon._yscale = 100 * screenPoints[i].scaleRatio;
currBalloon.swapDepths(screenPoints[i].depth);
}
};
theScene.onEnterFrame = rotateCube;
Papervision Cube With Transparent Faces
I'm trying to make a papervision cube with transparent faces. Imaging a glass cube with words printed on each face, that is what i want to accomplish. The problem is, when i set the faces to be transparent, they don't show up that way. They show up with what seems like a black background behind them. Is that a default?
Help Needed: Applying Images/links To Multiple Faces On A 3D Cube
I posted a fortnight ago, but it didn't seem to gain any attention, so I was hoping someone who missed it last time may be able to help me.
I've used two differing 3D Cube ActionScripts, each generates a different type of 3D Cube - one has colored faces and individual links for each side and the other has individual images/movie-clips per face but only one link for the whole cube.
What I want to achieve is a cube with 6 different imaged faces and 6 independent links, can anyone suggest how I could achieve this.
Thanks again
AS3 - Bitmap Geometry And Faces Data Persisting In The Flash Player
I am using cs4 up-to-date pv3d classes. Flex Gumbo 4.0 sdk. FP10.
..The problem i have is that bitmap, geometry and faces data persist in
the flash player after using unloadAndStop() to unload the pv3d swf
from the main app. I realise this is a poor way to do this but coming
from a basic knowledge of flash and having used earlier versions of
the api, before as3, i did not know any better.
I'm under tremendous time pressure. I need to know how i can
dispose of these elements the proper way. (1)How do i
reference them so i can dispose them, (2) How do i dispose of them correctly.
(3) How would i remove an event listener?
I've seen this (below) but some high level opinion/solution would be greatly appreciated.
Code:
var li:LoaderInfo = loader.contentLoaderInfo;
if(li.childAllowsParent && li.content is Bitmap){
(li.content as Bitmap).bitmapData.dispose(); // remove bitmap from memory
}
Could you pls help me. Christmas is coming soon and i'm feeling generous.
Saul.
Main App (Interface) Code portion:
<mx:State name="Car3DScene"
enterState="initSWF(event);"
exitState="unloadSWFHandler(event);">
<mx:AddChild relativeTo="{panel1}" position="lastChild">
<mx:Canvas width="100%" height="100%"
minHeight="340" minWidth="920"
borderColor="#1d1d1d" borderThickness="1" borderStyle="solid"
backgroundAlpha="1" backgroundColor="#000000">
<mx:Image x="0" y="0" width="295" height="250"
id="myLogo" source="@Embed('assets/images/scene3dMainImage.png')"
autoLoad="true" maintainAspectRatio="false"/>
<mx:Script>
<![CDATA[
import flash.events.*;
import flash.net.URLRequest;
import mx.controls.SWFLoader;
import mx.events.FlexEvent;
import flash.display.Loader;
public var swfContent:MovieClip;
public function initSWF(e:Event):void
{
myLoader.addEventListener(Event.INIT,loadHandler,f alse, 0, true);
myLoader.addEventListener(Event.UNLOAD,unloadSWFHa ndler,false, 0, true);
myLoader.load("assets/swfs/PV3DCanvasSWFFVPortWR.swf");
}
private function loadHandler(e:Event):void
{
swfContent = e.target.content;
}
private function unloadSWFHandler(e:Event):void
{
swfContent.loaderInfo.loader.unloadAndStop(true);
//myLoader.unloadAndStop(true);
}
]]>
</mx:Script>
<mx:SWFLoader x="295" y="0"
width="625" height="250"
minWidth="625" minHeight="250"
maintainAspectRatio="false"
scaleContent="true" blendMode="normal"
id="myLoader" alpha="1"/>
.................................................. .....
.................................................. .....
Here is the code of the incoming SWF:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
preloader="com.usppro.BasicCustomPreloader"
layout="absolute"
applicationComplete="init3D();">
<mx:Script>
<![CDATA[
import mx.controls.*;
import flash.display.*;
import objects.*;//The as3 geom (3d model) classes
import org.papervision3d.cameras.*;
import org.papervision3d.materials.*;
import org.papervision3d.materials.special.*;
import org.papervision3d.objects.*;
import org.papervision3d.objects.special.*;
import org.papervision3d.render.*;
import org.papervision3d.scenes.*;
import org.papervision3d.view.*;
import org.papervision3d.objects.primitives.*;
import org.papervision3d.materials.*;
import org.papervision3d.view.*;
import org.papervision3d.core.utils.*;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.core.geom.renderables.*;
private var camera :Camera3D;
private var renderer :BasicRenderEngine;
private var scene :Scene3D;
private var viewport :Viewport3D;
private var universe isplayObject3D;
private var c:CarFinal;//The car 3d model class
[Embed(source="/assets/Car_Black.jpg")]
private var CarTexture:Class;
private function init3D():void
{
Application.application.stage.align = StageAlign.TOP_LEFT;
Application.application.stage.scaleMode = StageScaleMode.NO_SCALE;
Application.application.stage.quality = StageQuality.LOW;
Application.application.stage.frameRate = 30;
viewport = new Viewport3D(625,250,false,false,true,true);
pv3dCanvas.rawChildren.addChild(viewport);
pv3dCanvas.rawChildren.addChild(new Stats());
renderer = new BasicRenderEngine();
scene = new Scene3D();
camera = new Camera3D(universe,18,200);
camera.x = 0;
camera.y = 0;
camera.z = -200;
createObjects();
addEventListeners();
}
private function createObjects():void
{
c = new CarFinal();
c.material = new BitmapMaterial(new CarTexture().bitmapData);
c.x = 0;
c.y = 0;
c.z = 0;
universe = new DisplayObject3D();
universe.addChild(c);
scene.addChild(universe);
universe.x = 200000;
universe.y = -200000;
universe.rotationY = -90;
camera.target = universe;
}
private function addEventListeners():void
{
addEventListener(Event.ENTER_FRAME, loop3D,false,0,true);
}
public function loop3D(e:Event):void
{
camera.target.x -= (((mouseX - (pv3dCanvas.width * 0.5)) * 12) + camera.target.x) / 24;
camera.target.y -= (((mouseY - (pv3dCanvas.height * 0.5)) * 12) + camera.target.y) / 24;
universe.yaw(-0.6);
renderer.renderScene(scene, camera, viewport);
}
]]>
</mx:Script>
<mx:Canvas width="625" height="250"
x="0" y="0"
blendMode="normal"
id="pv3dCanvas"
backgroundColor="#000000" backgroundAlpha="1">
</mx:Canvas>
</mx:Application>
..............................................
..............................................
Here is a code portion of the 3d car model class
package objects
{
import org.papervision3d.core.*;
import org.papervision3d.core.geom.*;
import org.papervision3d.core.geom.renderables.Triangle3D ;
import org.papervision3d.core.geom.renderables.Vertex3D;
import org.papervision3d.core.math.NumberUV;
import org.papervision3d.core.proto.*;
public class CarFinal extends TriangleMesh3D
{
public var verts :Array;
public var faceAr:Array;
public var uvs :Array;
private function v(x:Number,y:Number,z:Number):void
{
verts.push(new Vertex3D(x,y,z));
}
private function uv(u:Number,v:Number):void
{
uvs.push(new NumberUV(u,v));
}
private function f(vn0:int, vn1:int, vn2:int, uvn0:int, uvn1:int,uvn2:int):void
{
faceAr.push( new Triangle3D( this, [verts[vn0],verts[vn1],verts[vn2] ], null,
[uvs[uvn0],uvs[uvn1],uvs[uvn2]] ) );
}
public function cobraCarFinal( material:MaterialObject3D=null, initObject:Object=null )
{
super( material, new Array(), new Array(), null );
verts = this.geometry.vertices;
faceAr= this.geometry.faces;
uvs =new Array();
v(108.544,-31.9748,-101.242);
...........................
f(1248,5195,5196,1248,5195,5196);
this.geometry.ready = true;
}
}
}
|