Name = New Object(). Help?
Last edited by Kywocs : 2008-11-12 at 13:17.
---deleted--- Thanks.
Ultrashock Forums > Flash > ActionScript
Posted on: 2003-04-29
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Making An Object Dissapear Once A Moving Object Makes Contact With It
Hello there,
Im in need of some help. Basically I need a code which will make an object disappear once another moving object hits it (MovieClips controlled by AS)
For example, a bullet comes out of the gun and hits a can which makes the can disappear as soon as the bullet hits it.
Is it something to do with the "intersects" function? I've been trying to solve it all day and cant do it
Please help.
Whats It Called When You Drag An Object And Want The Object To Continue Moving
i am trying to work out how to make a draggable movie clip/button continue to move in the same direction as the drag guides it...hmmmm does this make sense???? what is this function / behaviour called.... i have looked at many many drag tutorials but at present have only managed to find drag and drop type onces with target positions.... also does any one know if it is possible assign multiple drag points.
regards....
Video Object - Call To Load And Listener Object Not Working
i've got a video object within a movieclip who's full path i put in a var called 'video'. here's my code, it appears that the video object is not loading my stream and/or i'm not getting the listener object to work properly... everything does trace out good as far as vars, rtmp address, etc... grrr!!!
Code:
//function to load the stream in the vid object
_global.loadVid=function(vidFile){
trace("this is path to vidObj: "+video);
trace("loadVid function var passed: "+vidFile);
var listenerObject:Object = new Object();
listenerObject.ready=function(eventObject:Object):Void{
//video loaded, do this
video.removeEventListener("ready", listenerObject);
_root.container.vidPanel.gotoAndPlay("tovideo");
trace("video is loaded, proceeding to video play state");
};
video.addEventListener("ready", listenerObject);
var nV:String=rtmpURL+vidFile;
video.load(nV, true);
trace("video: "+rtmpURL+vidFile+" should be loading");
}
How'd U Make An Object Snap 2 Its Original Pos On An Object Thats Moved?
I'm working on a school project using Flash mx that needs a scrolling inventory. I know how to get an object to snap back to its original position from a drag, but how would you get it to snap back to its original position on an object that has moved? ie. On a scrolling menu?
//script to have a spanner remove a head and snap back to position if it doesn’t touch the head on release:
//attach to object
onClipEvent (load) {
spanx = _root.spanner._x;
spany = _root.spanner._y;
}
//action inside clip
on (press) {
startDrag(this,true);
}
on (release, releaseOutside) {
if (this.hitTest(_root.dismantle.head) & _root.head_switch=="hollow") {
_root.spanner.gotoAndPlay(2);
_root.dismantle.head.gotoAndPlay(2);
this._y = 185;
_root.airbrush._x= _root.airbrush.airbx;
_root.airbrush._y= _root.airbrush.airby;
}
else {
_root.spanner.gotoAndStop(1);
this._x = spanx;
this._y = spany;
this.gotoAndStop(2);
}
stopDrag();
}
how would i script a scrolling inventory from which I can drag and drop objects that snap back to the same pos in the inventory even tho its moved? You can see the inventory on the right of the attached jpeg.
Papervision Acsess Individual Object Within .dae File/Object
Hello,
The following code loads a .dae file into a new DAE() Object i am trying to acsess a specific child within de Object called "Loja1" (one of many) with var storeisplayObject3D = holder.getChildByName("Loja1"); to individually rotate it etc... but with no sucsess.
Does anyone know how this is acomplished ?
Thanks in Advance.
files at : http://www.kiyoshii.com/transfer/src.zip
Code:
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
public class Pulitzer3d extends Sprite {
public var viewport:Viewport3D;
public var renderer:BasicRenderEngine;
public var scene:Scene3D;
public var camera:Camera3D;
public var dae:DAE;
public var cm:ColorMaterial;
public var holder:DisplayObject3D;
public var cameraBtn:BtnCamera;
public function Pulitzer3d() {
init();
}
private function init() {
//basic scene stuff
viewport = new Viewport3D(1024, 768, true,true);
addChild(viewport);
renderer = new BasicRenderEngine();
scene = new Scene3D();
camera = new Camera3D(holder, 15, 100);
camera.zoom = 500;
camera.z = -50;
//COLOR MATERIAL
cm = new ColorMaterial(0xFF0099, .85, true);
//DAE
dae = new DAE();
dae.load("floor_rename.dae", new MaterialsList( { all:cm } ));
holder = new DisplayObject3D();
holder.addChild(dae);
holder.rotationX = 90;
holder.rotationY = 45;
scene.addChild(holder);
var store:DisplayObject3D = holder.getChildByName("Loja1");
trace("DAE : " + store);
stage.addEventListener(Event.ENTER_FRAME, renderStuff);
}
private function renderStuff(e:Event) {
renderer.renderScene(scene,camera,viewport,true);
//camera.x += (((stage.mouseX-(stage.stageWidth * .5))*2)-camera.x )*.05;
//camera.y += (((stage.mouseY-(stage.stageHeight*.5))*2)-camera.y )*.05;
}
}
}
Web Service Param Is An Object Inside And Array Which Is An Object
Howdy. This is my first time on this forum, and I hope I get more help here than some of the other forums. I'll try to explain my dillema as simply as possible.
I have a webservice. I am calling a method 'InsertSlide'. That method requires and object as the paramater.
the object shcema looks like this:
Object
-SlideID (integer)
-Name (integer)
-SlideTypeID (integer)
-Hits (integer)
-LocationID (integer)
-SwfFileName (integer)
-SlideDataCollection (Array)
- -N (Object)
- - -Label
- - -Value
I hope that makes sense, all I'm trying to get at, is there is an object with an array as a property, that array is populated with an object and it has properties.
I recieve that same ojbect from the webservice fine, but when I send that object like that to the Webservice it does not fully populate my databases, unfortunatly I did not write the webservice.
Is it possible that the problem is the webservice? or flash?
Thanks for any help!
- Kiwi
Targeting Object Properties Inside PopUp Object
In my project I am creating a window using the PopUpManager. The symbol used to create that window has several objects.
For the sake of discussion we'll discuss the object message_txt inside myWindow.
How do I reference message_txt.text from actionscript after the object is dynamically created?
Gravity Issue? Object Slides Through Another Object Instead Of Sitting On Top Of It
Hello!
I have a file where two objects fall from the top of the stage and bounce and then eventually stop (using gravity and hit test).
You can grab the objects (a ball and a box --- each has a button symbol n the movie clip) and toss them and they bounce off each other and off the 4 sides of the stage.
The issue is when one of the objects is dropped directly on top of the other object, after it stops bouncing, it slides down until it hits the bottom of the stage (in this case, the box slides down in front of the ball, and the ball slides down in back of the box).
Is this because the gravity is pulling the object down to the bottom of the stage even though there's another object in its way?
How can I fix this so that the objects will still bounce off each other, and when dropped directly on top of each other object will stop instead of oozing through it (sorry, this is the best way I can describe it ?
I've attached 2 files (Fla 8 and Fla mx 2004).
-------- here is the gravity code on the first frame:
PHP Code:
var gravity:Number = 1.2;
var restitution:Number = 0.6;
var friction:Number = 0.9;
stop();
-------- here is the code on the ball
PHP Code:
onClipEvent(load) {
var dragging:Boolean = false;
var vel:Object = { x: 0, y: 0 };
var pos:Object = { x: _x, y: _y };
var old:Object = { x: _x, y: _y };
var radius:Number = this._width / 2;
var movie:Object = { width: 400, height: 300 };
}
onClipEvent(enterFrame){
if( !dragging ) {
vel.y += _root.gravity;
pos.x += vel.x;
pos.y += vel.y;
if( pos.y + radius > movie.height ) {
pos.y = movie.height - radius;
vel.y *= -_root.restitution;
vel.x *= _root.friction;
}
if( pos.x + radius > movie.width ) {
pos.x = movie.width - radius;
vel.x *= -_root.restitution;
}
if( pos.x < radius ) {
pos.x = radius;
vel.x *= -_root.restitution;
}
_x = pos.x;
_y = pos.y;
} else {
old.x = pos.x;
old.y = pos.y;
pos.x = _x;
pos.y = _y;
vel.x = ( pos.x - old.x ) / 2;
vel.y = ( pos.y - old.y ) / 2;
}
if(this.hitTest(_root.box)) {
trace("hit");
// ball and box are colliding, so lets reverse their movements.
vel.x *= -1;
vel.y *= -1;
_root.box.vel.x*=-1;
_root.box.vel.y*=-1;
/* these actions could be made more realistic by determining the precise
position of the ball relative to the box during the collision, for instance,
determine if the right side is colliding with the left side, so only reverse
the x velocity, instead of both. */
}
//this prevents the ball from leaving the upper extreme of the stage
if (this._y < 0) {
vel.y*=-1;
}
}
-------- here is the code on the button inside the ball (so you can drag and release the ball)
PHP Code:
on(press){
startDrag(this,false,16,16,384,284);
dragging = true;
}
on(release, releaseOutside){
stopDrag();
dragging = false;
}
-------- here is the code on the box
PHP Code:
onClipEvent(load) {
var dragging:Boolean = false;
var vel:Object = { x: 0, y: 0 };
var pos:Object = { x: _x, y: _y };
var old:Object = { x: _x, y: _y };
var radius:Number = this._width / 2;
var movie:Object = { width: 400, height: 300 };
}
onClipEvent(enterFrame){
if( !dragging ) {
vel.y += _root.gravity;
pos.x += vel.x;
pos.y += vel.y;
if( pos.y + radius > movie.height ) {
pos.y = movie.height - radius;
vel.y *= -_root.restitution;
vel.x *= _root.friction;
}
if( pos.x + radius > movie.width ) {
pos.x = movie.width - radius;
vel.x *= -_root.restitution;
}
if( pos.x < radius ) {
pos.x = radius;
vel.x *= -_root.restitution;
}
_x = pos.x;
_y = pos.y;
} else {
old.x = pos.x;
old.y = pos.y;
pos.x = _x;
pos.y = _y;
vel.x = ( pos.x - old.x ) / 2;
vel.y = ( pos.y - old.y ) / 2;
}
}
-------- here is the code on the button inside the box (so you can drag and release the box)
PHP Code:
on(press){
startDrag(this,false,16,16,384,284);
dragging = true;
}
on(release, releaseOutside){
stopDrag();
dragging = false;
}
I appreciate any help anyone can give me to fix this issue, I don't understand enough yet about how these objects are interacting to fix this --- but I hope to learn from you brilliant Kirupians!) Thanks!
Hondo311
Tween Class To Move An Object Called From Within The Object
I have a custom class that I want to move with the Tween Class
I am calling the Tween constructor from within that class but when I pass the keyword "this" as the object of that constructor , it doesnt move at all the code is as follow
PHP Code:
package{import fl.transitions.Tween;import flash.display.MovieClip;public class PortViewer extends MovieClip{var _twn:Tween;public function PortViewer(){ _twn = new Tween(this, "y", None.easeNone, 0, 100, 2, true);}}}
how do I reference the object from within itself is there another keyword?
There are no errors it just doesnt move
Thank you Kirupa forums
AS3 - Papervision Acsess Individual Object Within .dae File/Object
Hello,
The following code loads a .dae file into a new DAE() Object i am trying to acsess a specific child within de Object called "Loja1" (one of many) with var store: DisplayObject3D = holder.getChildByName("Loja1"); to individually rotate it etc... but with no sucsess.
Does anyone know how this is acomplished ?
Thanks in Advance.
files at : http://www.kiyoshii.com/transfer/src.zip
Code:
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
public class Pulitzer3d extends Sprite {
public var viewport:Viewport3D;
public var renderer:BasicRenderEngine;
public var scene:Scene3D;
public var camera:Camera3D;
public var dae:DAE;
public var cm:ColorMaterial;
public var holder:DisplayObject3D;
public var cameraBtn:BtnCamera;
public function Pulitzer3d() {
init();
}
private function init() {
//basic scene stuff
viewport = new Viewport3D(1024, 768, true,true);
addChild(viewport);
renderer = new BasicRenderEngine();
scene = new Scene3D();
camera = new Camera3D(holder, 15, 100);
camera.zoom = 500;
camera.z = -50;
//COLOR MATERIAL
cm = new ColorMaterial(0xFF0099, .85, true);
//DAE
dae = new DAE();
dae.load("floor_rename.dae", new MaterialsList( { all:cm } ));
holder = new DisplayObject3D();
holder.addChild(dae);
holder.rotationX = 90;
holder.rotationY = 45;
scene.addChild(holder);
var store:DisplayObject3D = holder.getChildByName("Loja1");
trace("DAE : " + store);
stage.addEventListener(Event.ENTER_FRAME, renderStuff);
}
private function renderStuff(e:Event) {
renderer.renderScene(scene,camera,viewport,true);
//camera.x += (((stage.mouseX-(stage.stageWidth * .5))*2)-camera.x )*.05;
//camera.y += (((stage.mouseY-(stage.stageHeight*.5))*2)-camera.y )*.05;
}
}
}
Papervision Acsess Individual Object Within .dae File/Object
Hello,
The following code loads a .dae file into a new DAE() Object i am trying to acsess a specific child within de Object called "Loja1" (one of many) with var store:DisplayObject3D = holder.getChildByName("Loja1"); to individually rotate it etc... but with no sucsess.
Does anyone know how this is acomplished ?
Thanks in Advance.
files at : http://www.kiyoshii.com/transfer/src.zip
Code:
package {
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.parsers.DAE;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;
public class Pulitzer3d extends Sprite {
public var viewport:Viewport3D;
public var renderer:BasicRenderEngine;
public var scene:Scene3D;
public var camera:Camera3D;
public var dae:DAE;
public var cm:ColorMaterial;
public var holder:DisplayObject3D;
public var cameraBtn:BtnCamera;
public function Pulitzer3d() {
init();
}
private function init() {
//basic scene stuff
viewport = new Viewport3D(1024, 768, true,true);
addChild(viewport);
renderer = new BasicRenderEngine();
scene = new Scene3D();
camera = new Camera3D(holder, 15, 100);
camera.zoom = 500;
camera.z = -50;
//COLOR MATERIAL
cm = new ColorMaterial(0xFF0099, .85, true);
//DAE
dae = new DAE();
dae.load("floor_rename.dae", new MaterialsList( { all:cm } ));
holder = new DisplayObject3D();
holder.addChild(dae);
holder.rotationX = 90;
holder.rotationY = 45;
scene.addChild(holder);
var store:DisplayObject3D = holder.getChildByName("Loja1");
trace("DAE : " + store);
stage.addEventListener(Event.ENTER_FRAME, renderStuff);
}
private function renderStuff(e:Event) {
renderer.renderScene(scene,camera,viewport,true);
//camera.x += (((stage.mouseX-(stage.stageWidth * .5))*2)-camera.x )*.05;
//camera.y += (((stage.mouseY-(stage.stageHeight*.5))*2)-camera.y )*.05;
}
}
}
Position Object By Center Of Other Object And Stage Left...?
lol! :lol:
what i mean is i have an object (mc = main_logo) that centers itself upon load:
main_logo._x = Stage.width / 2;
main_logo._y = Stage.height / 2;
and i want another object (mc = helmet) to always load up 2/3rds to the left (x axis) of main_logo's center (counting left to right, 2/3rds between main_logos center and stage left border) and 200 pixels above (y axis) main_logo's center.
i know i keep asking these things and i'm not trying to have you all do every little thing for me, i am trying to learn this! it's just that my brain operates differently and i have to assimalate information by what i'm trying to accomplish...
thanks!
How Do I Move An Object In The Opposite Direction Of Another Object?
Hello,
This seems like it should be easy but for some reason I'm having trouble making it happen... any help would be greatly appreciated.
I know how to set the Y position and get the Y position of objects, but what I'm trying to do is have one object move exactly opposite to another.
The first object is draggable. If it is dragged up 10 pixels, then I want the other object to move down 10 pixels.
Any suggestions?
Thank you!!
Janet
Uploading A Flash Object -- Speed Of Object
If I insert an object into a plain web page -- nothing else on it, in order for that flash object to function, Q: the only thing I upload to the web (besides the page of course) is just the flash object file???
When I saved the file, I see I have two: a Shockwave Flash Object, and a Swish Movie.
So I'm confused on how I saved these files and why I ended up with two?
Are there different methods of saving them? a correct way and an incorrect way?
And how do you take one of these objects/movies and condense it so it still works the same but loads quickly?
pj
Problem Controlling Object From Another Object (scroll Bar)
First time posting here so hope I don't screw up here
Hope I can exlpain my problem and make sense. What I am trying to do control an object from another object. It's a scroll bar moving a block of text. Each line is going to be a button trigering a loadmovie() in a main flash movie. I have a working version of the scroller in a different movie, but in this case the scroller is within another instance. I'm guessing that my instance references are messed up but I can't figure out which ones. I used this tutorial to create this scroller: http://www.flashcircle.com/display.php?storyid=40
Here's a link to the fla:
http://www.httpworkshop.com/navigation.fla
Any help will be greatly appreciated.
Problem Rotating An Object Relating To Another Object...
Hi everyone...
I'm pretty much a newbie, and, naturally, stumped. If anyone can help me out, i would really appreciate it...
I have a lollipop-type object; (it has line/stem that attaches to a circle, fixed to the top of one end).
I want to rotate the object 180 degrees and have it pivot on the end opposite the circle (so the end with the circle appears to swing in an arc). At all times, the circle and the stem must seem to be joined as if they were one solid object. So far, no problem.
However, durning the arc, the stem must shrink in size an x amount. The stems' rotation point must remain fixed; it can't appear to move. The circle must remain it's original size, but still be attached to the stem, thus, the circle's position should gradually be closing up the space left by the shrinking stem at the same time the circle is moving through the arc. And i cannot figure out how to make this work!
To make the rotation work so far, I set the registration pt for the stem at the base of the stem (the pivot pt for it's rotation), set the registration pt for the circle also at the base of the stem (so they would share the same pivot point) and moved the circle to where it would set in relation to the stem. Then for both, i made _rotation = x, and on the stems' enterframe, i added 1 to x for both mcs.
(Also, to complicate the issue, at the beginning of the animation, the stem needs _xscale from 0 to 100, at which point it attaches the circle to it's tip; thus, the necessity of creating two movie clips: one for the stem, one for the circle.)
Thanks again for the help...
Making One Object Move Towards Another Object In Flash 8?
Hi, I need help on making one object move towards another object at a set speed, in Flash Professional 8.
So far I can get one object to move to another one but only doing a fraction of the distance at a time, as with this code:
PHP Code:
onClipEvent (enterFrame) {
var xspd = (this._parent.redsquare._x - this._x) * .1;
var yspd = (this._parent.redsquare._y - this._y) * .1;
this._x += xspd;
this._y += yspd;
}
How can I make it so it moves with a set speed? Anyone able to help?
Convert Object To Strongly Typed Object
I have the following function which serializes my plain obj:Object to custom:SomeObject.
It works great, but if I have ArrayCollection in the Object it would not convert it to my custom object and instead it will just avoid it.
Any help is appreciated...
Here is my code:
Code:
public static function objectToInstance( object:Object, clazz:Class ):*
{
var bytes:ByteArray = new ByteArray();
bytes.objectEncoding = ObjectEncoding.AMF0;
// Find the objects and byetArray.writeObject them, adding in the
// class configuration variable name -- essentially, we're constructing
// and AMF packet here that contains the class information so that
// we can simplly byteArray.readObject the sucker for the translation
// Write out the bytes of the original object
var objBytes:ByteArray = new ByteArray();
objBytes.objectEncoding = ObjectEncoding.AMF0;
objBytes.writeObject( object );
// Register all of the classes so they can be decoded via AMF
var typeInfo:XML = describeType( clazz );
var fullyQualifiedName:String = typeInfo.@name.toString().replace( /::/, "." );
registerClassAlias( fullyQualifiedName, clazz );
// Write the new object information starting with the class information
var len:int = fullyQualifiedName.length;
bytes.writeByte( 0x10 ); // 0x10 is AMF0 for "typed object (class instance)"
bytes.writeUTF( fullyQualifiedName );
// After the class name is set up, write the rest of the object
bytes.writeBytes( objBytes, 1 );
// Read in the object with the class property added and return that
bytes.position = 0;
// This generates some ReferenceErrors of the object being passed in
// has properties that aren't in the class instance, and generates TypeErrors
// when property values cannot be converted to correct values (such as false
// being the value, when it needs to be a Date instead). However, these
// errors are not thrown at runtime (and only appear in trace ouput when
// debugging), so a try/catch block isn't necessary. I'm not sure if this
// classifies as a bug or not... but I wanted to explain why if you debug
// you might seem some TypeError or ReferenceError items appear.
var result:* = bytes.readObject();
return result;
}
Convert A Video Object To A Bitmapdata Object
package {
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.*;
import flash.media.Camera;
import flash.media.Video;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.Event;
public class CameraExample extends Sprite {
private var video:Video;
private var _bitmapData:BitmapData;
private var _bitmapDataDue:BitmapData;
private var mybitmap:BitmapData;
public function CameraExample() {
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
var camera:Camera = Camera.getCamera();
if (camera != null) {
camera.addEventListener(ActivityEvent.ACTIVITY, activityHandler);
video = new Video(camera.width * 2, camera.height * 2);
video.attachCamera(camera);
addChild(video);
_bitmapData = new BitmapData(video.width , video.height, false);
_bitmapData.draw(video);
var _bitmapDataDisplay:Bitmap = new Bitmap(_bitmapData);
_bitmapDataDisplay.x= camera.width * 2;
addChild(_bitmapDataDisplay);
}
what's wrong with this?
thank yooou
[AS3] XMLDefinition() - XML To Object (object Definitions And Hierarchies In XML)
XMLDefinition is a function that translates XML into ActionScript object definitions. It works a lot like Flex but translates definitions at runtime. As a runtime translater, its limited (no scripting etc) but still flexible in what it can be used to create.
Attached is the class and a simple Flash CS3 example. Below is some documentation. I'll try to include a page with a live demonstration when I get a chance (and if I feel confident that the kinks have been ironed out).
Doc (from the AS file):
XMLDefinition()
Code:
public function XMLDefinition(xml:XML, targetParent:Object = null):Object
Creates an object (typically a display object) based on the definition outlined by the XML. Each XML element represents the object to be made. If that object's definition is in a pacakge, that element will need to be in a namespace whose uri matches that package. The hierarchy of the object created will match the hierarchy of the XML where display objects will be added as children to the display objects. Attributes are used to define properties. If a name attribute is defined, that name will also be used as a property name in the parent to store a reference to the child. If the parent is not a display object container or the child is not a display object and a name attribute is not provided, the child element's index will be used; this is useful when defining arrays as name attributes are not needed.
There are 3 kinds of elements for special uses, each of which defined in the com.senocular.xml.XMLDefinition namespace. They are:
- property
- call
- arguments
The property element is used to access an existing property of an object. For example, you may want to reference the transform property of a MovieClip instance defined in XML rather than redefine it. In that case you would use the property element to access that property's existing value rather than provide a new value to be set for the MovieClip's transform property. This element uses one attribute, name, to determine the name of the property being accessed.
The call element is used to call methods within objects. Like the property element, it too uses the name attribute to identify the class member (in this case a method) to be accessed. This would be useful for calling drawing methods on a display object. Method arguments are handled through the arguments element.
The arguments element is used in combination with class definitions or method calls. For class definitions (elements representing class instances) the arguments element contains the arguments for that instance's constructor call. For method calls, the arguments element's children are used as arguments for that method. The definitions within an arguments block is scoped to the parent node of the arguments element so references to property in an arguments element will reference properties in the argument's parent object. One caveat concerning the arguments element is that you are limited to 10 or less arguments.
The following example creates a Sprite a line drawn in its graphics object and one Shape child object with the instance name "child":
Code:
var definition:XML =
<display:Sprite x="50" y="100"
xmlns:display="flash.display"
xmlns:def="com.senocular.xml.XMLDefinition">
<display:Shape name="child" />
<def:property name="graphics">
<def:call name="lineStyle">
<def:arguments>
<Number>1</Number>
<uint>0xFF0000</uint>
</def:arguments>
</def:call>
<def:call name="lineTo">
<def:arguments>
<Number>100</Number>
<Number>100</Number>
</def:arguments>
</def:call>
</def:property>
</display:Sprite>
var sprite:Sprite = XMLDefinition(definition);
Parameters:
xml - The xml to be parsed into an object.
targetParent - The object in which the generated object will be defined, either as a property or a child display object.
Returns:
A reference to the object created.
Get To An Object's Content From An Object's Event Handler
Hi there,
I have some code that is intended to get a list of XML file names from a PHP script and then parse the content of the XML files and stick certain data into a big array called "allData":
Code:
var allData:Array = new Array();
var remoteFileNames:GetXMLFileNames = new GetXMLFileNames("http://localhost/getVars/getfilenams.php");
remoteFileNames.addEventListener(GetXMLFileNames.GOT_NAMES, getXMLDataFiles);
function getXMLDataFiles(e:Event):void {
for each (var fileName:String in remoteFileNames.fileNames) {
var xmlLoader:XmlLoader = new XmlLoader(fileName);
xmlLoader.addEventListener(XmlLoader.DATA_PARSED, dataParsed);
}
}
function dataParsed(e:Event):void {
trace ("XML data was parsed");
allData.push(???.content); // problem here!
}
(Of course there's also some class files GetXMLFileNames.as and XmlLoader.as that do their stuff) all works well except that I need to get the references to the content property of each object. I guess I do this via the event handler but I'm not sure exactly how? Any one got any ideas?
Many thanks
Ben
So An Object Can't Call Another Object's Methods?
Say I have a conveyor belt object and a trailer truck object.
The conveyor belt adds boxes to itself.
The user clicks on a box and then clicks on 1 of three trailer trucks to put it in.
When box is placed in 1 of the 3 trucks, I'd like the trailer truck to call the conveyor belt's method to cause the conveyor belt to 'add a box' to itself.
If a box is not placed after 4 seconds, the conveyor belt is to call it's 'add a box' method to add another box to itself.
Since the trailer truck mc is also defined as a button, I check to see if it's been clicked on as a way of knowing if a box has been placed inside it and therefore another box should be added to the conveyor belt.
Is it possible to do it this way with oop? I can't seem to do it, but maybe I've got the syntax wrong. If not, how might it be set up with proper oop?
Any Way To Check What Type Of Object The Object Is?
Hey, i was wondering if there is a command to check what type object a certain object is
ex:
function circle(radius){
this.radius = radius
}
functin squre(side){
this.side = side
}
shape1 = new circle(25);
shape2 = new square(10);
//====this is just an example of what i want happen =============
type = getType(shape1)
trace(type);
this will trace "circle"
is there a command that can do is? I thought i saw it somewhere, but i cant find it
Placing Object Over Object By X-Y Coordinates.
This image should basically explain what I'm trying to accomplish right now.
I want an object to move with a moveable object by retreiving the character's X-Y coordinates and then placing the object by the X-Y coordinates of the hero until the animation is complete. How can I do this?
Thanks for your help.
Object In Object Retrieving Question
Hello,
For an assingment at college I am creating a multi-user realtime game.
Therefor I am using the Electroserver by Electrotank. Because of latency I want to create the game-engine in a server-side script.
Code:
var variables = new Object();
for(var i=1; i<=8; i++) {
variables[i] = new Object();
for(var j=1; j<=8; j++) {
ob = new Object();
ob.type = 0;
variables[i][j] = ob;
}
}
When I trace this code at the serverside like variables[2][3].type I get the number zero (which is what I want (seems quite unlogical, but in the rest of the script this ob.type is set to a random numberand that is all working as it should)). It seems that things are done in some sort of Javascript at the server (server is programmed in java, server-side scripts can be done in either java or actionscript), cause I get something like org.mozilla.javascript errors in the server outputwindow.
But when I send the object variables to the client and I trace it there the same way (variables[2][3]) I get the message undefined.
When I do the trace variables[2] I get [object Object], so there is something. And now comes the actual question.
How can I get to the properties of this object in variables[2]? Do I have to do it with some kind of dot-syntax?
I hope you can help me figure it out.
Tnx in advance,
Jorrit
Duplicate Object Adjacent To The First Object
Hi guys,
I am creating duplicate on clicking a buton but it is puting the duplicate on the same place but i wanna put duplicate object adjacent to the first object , whether it's having any angle or straight.
Actionscript:
function dupMovie(targetitem, basewidth, baseheight, baserotation, x_base, y_base) {
itemcount += 1;
duplicateMovieClip(targetitem, ("item" + itemcount), (16384 + (itemcount + 2000)));
item += itemcount;
setProperty(("item" + itemcount), _x, x_base);
setProperty(("item" + itemcount), _y, y_base);
setProperty(("item" + itemcount), _width, basewidth);
setProperty(("item" + itemcount), _height, baseheight);
setProperty(("item" + itemcount), _rotation, baserotation);
itemWidth = basewidth;
itemHeight = baseheight;
itemRotation = baserotation;
}
I am geting width and height of every object but with every dragable item i wanna attach a text box having widht.
for reference download movie.
http://www.geocities.com/rajmultimedia/movie.fla
regards
raj
A Draggable Object Within Limits Of Other Object
I am trying to create an object(circle movie clip) that is draggable but stays within the space of another object(square movie clip). i want to be able to drag this object and not be able to pull it out of the square movie clip. i am assuming hitTest will be one of the functions to use but what about knowing the space of the path object(square movie clip)?
J
Create Object Within Object, Dynamically?
Howdy,
I'm creating a firework show. The main timeline creates rocket objects nicely. When it's time for the rocket to explode, creating projectiles in the Rocket object in the same way as the main timeline, it does NOT work dynamically. I can only seem to get it to work in a static way. Here are some examples:
main timeline (works great!):
Code:
this["rocket" + rocketInt] = new Rocket();
this["rocket" + rocketInt].name = "rocket" + rocketInt;
addChild(this["rocket" + rocketInt]);
rocketInt++;
in Rocket (does not work):
Error: ReferenceError: Error #1056: Cannot create property projectile0 on xx.xx.fireworks.Rocket. This error occurs even if all but the first line is commented out.
Code:
this["projectile" + _projectileInt] = new Projectile();
this["projectile" + _projectileInt].name = "projectile" + _projectileInt;
addChild(this["projectile" + _projectileInt]);
_projectileInt++;
in Rocket statically (works, but no fun):
Code:
var projectile0:Sprite = new Projectile();
projectile0.name = "projectile0";
addChild(projectile0);
The last example does exactly what I need it to... but The number of projectiles could be anywhere from 1 to 50. I'd hate to do all that in a non-dynamic way.
Is there any hope?
Thank you much for the assist.
Aㄴsign Object To Object By Value
Hi.
I have a moviePosition:Point and a
moviePositionSNAPSHOT:Point .
If i use
moviePositionSNAPSHOT=moviePosition
i don't get what I want .
Any ideas except manually assigning x and y (that would be annoying) ?
Thanks
Cast From Object To Custom Object
I have a custom object that looks like:
Code:
public dynamic class ClientSummary
{
public var companyName:String="";
public var traderName:String="";
public var ip:String="";
public var fromDate:String;
public var toDate:String;
public var wsToGwMin:int = 0;
public var wsToGwMax:int = 0;
public var wsToGwMean:Number = 0;
public var wsToGwStd:Number = 0;
public var wsToGw1Std:Number = 0;
public var wsToGw2Std:Number = 0;
And I have generic Object that has the same exact data with the same exact fields. When I try to cast from the generic Object to my custom obj the cast fails and my custom object has null value assigned to it.
Any ideas how I can cast from generic object to custom object.
Any help will be appreciated.
here how I am trying to accomplish the cast
Code:
var resultObj:ClientSummary;
resultObj = e.result.object as ClientSummary;
It fails to cast.
Thanks in advance
Object In Movieclip Follow Object Outside
Hi
How can I make an object inside a movieclip follow an object outside of the movie clip?
I've tried the following but it doesn't work
Code:
ball.onEnterFrame = function() {
ball.x = control.x;
ball.y = control.y;
}
Mouse Interaction W/ The Object Below A Object
let me try to lay this out simply.
suppose i do this:
objectA.addEventListener( MouseEvent.MOUSE_OVER, objAfunction );
and i lay a half transparent rectangle(objectB) over objectA.
what happens now, is the mouseover listener doesn't respond, of course.
but what am i to do, if i want to have objectB over objectA, and still have objectA listen for Mouse Events?
any clues?
Get The Object Size In Bytes (every Object)
i am wonder what is the size of the object like Number or String or Object in bytes and how can one find out what is the size of it (in AS2 without byteArray)
please...
Edited: 01/24/2007 at 05:44:31 AM by boliz
Accessing A Property Of An Object Within An Object
I have modified a simple button object, which I called the OP Button in the library, and it contains two dynamic text fields. I had to add these text fields because I encountered a problem. Having the text above the button caused the button not to activate when the user went over the dynamic text field. Tried to have the text below the button, but the blue highlight with the button made the text fuzzy. I need to have the text dynamic because I need it to hold different values.
I have created the new button. In the library of Flash it is registered as OP Button ( a name I gave the button type ). I can edit the button and see the dynamic text object, which I gave the name of NormalText. I need to know how to change the .text property of the dynamic text located in the modified simple button.
The instance of the newly created button is OP4Button and the name of the dynamic text field within this button is called NormalText. How do I change the .text property from the main stage action script?
The button was created in design mode and not through action scripts. Even though I created in design mode, I need to access it through Action Script. Any help will be greatly appreciated.
Thank you
Edited: 06/16/2007 at 10:49:18 AM by David Cowdery
'global' Object Instead Of Custom Object?
Hi,
I have a custom class called testItem (external file: testItem.as) that behaves strangely. I have told it to extend MovieClip and when it is created it creates a new Shape object and adds this to its display stack using addChild. However, when this is done Flash doesn't refer to my object as 'object testItem' anymore, but 'object global' instead. Why does this happen, and how do I get it to refer to the testItem class/object instead?
testItem.as code:
Code:
package {
import flash.events.*;
import flash.display.*;
public class testItem extends MovieClip {
public function testItem() {
}
public function fSetupMe() {
trace(this); // returns '[object testItem]'
var vInfoShape:Shape = new Shape;
vInfoShape.graphics.beginFill(0xFF0000);
vInfoShape.graphics.drawRect(0, 0, 300, 300);
vInfoShape.graphics.endFill();
addChild(vInfoShape);
var fMouseOver:Function = function(arg) {
trace(this); // returns '[object global]'
MovieClip(root).vHighlight.fShowMe(this.y);
};
addEventListener(MouseEvent.MOUSE_OVER, fMouseOver);
}
}
}
The code in my mainTimeline file looks like:
Code:
var vtestItem = new testItem();
addChild(vtestItem);
vtestItem.fSetupMe();
Thanks in advance.
.c
Building An Object Object Dynamically
I'm trying to build an object object from input text. I can load the information into a variable using LoadVar with no problem but when I load that information into an object ( object {} Flash does not recognize the object as on object.
Any ideas?
Yellow jacket
Object.prototype And The Term "generic Object Instance"
Hi,
I'm quite new to actionscript programming and programming in general so I apologize if this is a basic question.
I'm studying Object and Classes from Moock's ASDG:MX and along with several great posts from Senocular, some clarification by Robert Penner and external references I've listed below.
http://www.kirupa.com/developer/oop/index.htm
http://www.debreuil.com/docs/ch01_Intro.htm
http://timotheegroleau.com/Flash/art...cope_chain.htm
From Moock's explaination, a constructor function's prototype property contains a generic object but it's not clear if the generic object is also part of the prototype chain if properties have been defined within the generic object instance without ".prototype"
Here's more of what I mean about the scope chain from the bottom up:
Object.prototype
Product.prototype
Book.prototype
asGuide
BUT where I get confused if when the term "generic object instance" of each class comes into play.
It seems more like below from my understanding but I'm not certain.
Object
Object.prototype
Product's generic object
Product.prototype
Book's generic object
Book.prototype
asGuide
Does each new subclass you declare in the prototype chain also have an instance of a generic object? If so, during the lookup by the interpreter, does the chain check the generic instance for all subclasses or just the Top Level
generic Object class?
Thanks for any help.
Save Object To String -> Load String And Convert Back To Object?
Wondering if anyone knows if this is possible. First a little explanation:
1. I have container grid where you can add and position MC's
2. The MC's x,y and other data is stored in a 3d object
3. The object is setup like this: matrix (object) -> levels (objects) -> profiles (objects). So basically a grid which mirrors what you see on screen.
This all works great; however, the application needs to have a save feature. My first thought was decode the matrix into an XML and save that.
Then I thought maybe you can just convert the matrix object to one big string and save that.
Questions: when the string is loaded back into the movie how do you (or can you even) covert it back in a object that flash can read?
Any help/input is greatly appreciated.
"In(Object){...}" Function? Data Types For Object Variables?
I can create an object and use dot syntax to create, or reference, variables inside of it.
But how can I specify the data types of these variables?
Also, is there some way I can enter the namespace of the object over a number of lines via {}s instead of using repetitive dot syntax?
Thanks in advance.
Changing An Array Result From An Array Object To A MovieClip Object
Anyone know how I can do this?
I have 3 arrays.
Quote:
//set info into arrays
wpInstName = new Array();
for(i=0; i<_global.wpCount; i++); {
wpInstName[i] = _global.newWP;
trace(wpInstName.join(" + "));
}
wpPositionX = new Array();
for (i=0;i<_global.wpCount;i++); {
wpPositionX[i] = _global.wpXpos;
trace(wpPositionX.join(" + "));
}
wpPositionY = new Array();
for (i=0;i<_global.wpCount;i++); {
wpPositionY[i] = _global.wpYpos;
trace(wpPositionY.join(" + "));
}
I need to use the current value of wpInstName[i] to change the _x and _y properties of an attached movie clip.
I have tried allsorts but it still treats the data as an Array object.
I have tried making a new Object and gave it the wpInstName[i] as a value to add properties too but im not sure if I did it right(it didnt work so I guess not ).
If anyone could help it would be greatly appreciated
Thnx
Wireframed Object To "full Colored" Object
Hello,
while sufring the internet I saw this incredible "effect" where a wireframed 3d object is filled with a color. One sample of what I'm talking about can be seen on http://www.sigmastudio.tk/ (Profile), where the outlined airplane is turned into full color airplane.
Another sample of what I'm talking about can be seen on http://www.merj.com (btw.: in my opinion another "site of the week" candidate) where 3d navigation cube is nicely filled with color.
As I was trying to achive something like that I tried with masking...but my guess is, that this is not the best nor the only way to achive this effect.
So can anyone give me a hint (or reference tutorial) on how to do smothing like this.
TNX, notpro
Getting The Object Name Inside The Object
//i have an object...
this.MyObject = function()
{
this.name;
};
//now the instance of that object...
myObj = new MyObject();
//here's the question...
//how do i get the name of the instance ("myObj") to be stored inside the object instance itself in the member varible (name)?
//i've tried making a function that runs a "for(var name in this)" but it sucked.
//once of i have that, i'll be able to list all the objects into an string array and process each one.
//or... is there an entirly different and more efficient approach all together?
//thanks in advance
Create Object In Object
Hi!
I have some problems. I want create an object with set of properties, so I can later change it. And this object will be duplicated. Quit simple. But This object must have another one inside it, that can be olso duplicated and has some properties. Now my code:
This is first part
------------------------------------
function Cathegory(name, i) {
duplicateMovieClip("_root.Cathegory", name, i);
this.name = name;
}
Cathegory.prototype.x = function(xcoord) {
setProperty(this.name, _x, xcoord);
};
Cathegory.prototype.y = function(ycoord) {
setProperty(this.name, _y, ycoord);
};
Cathegory.prototype.title = function(title) {
set(this.name+".Title", title);
};
var Cathegory1 = new Cathegory("HA!", 50);
Cathegory1.x(200);
Cathegory1.y(200);
Cathegory1.title("ok!");
------------------------------------
But how to make this inside object I don't know.
It's must be something like this may be:
------------------------------------
Cathegory.prototype.Cell = function() {
duplicateMovieClip(this.cell, name, i);
this.cell.name = name;
};
var Cathegory1.Cell1 = new Cathegory.Cell("Oho!!", 51);
Cathegory1.Cell1.x(200);
------------------------------------
Is hear somebody who understand what I say?
|