ActionScript 3.0 :: Move Code From One Class To Other?
Mar 2, 2010There i have some keyframes with labels.On .fla file in property in Class field i adde MyMatching class.
Also i have main code:
package
{
[code]......
There i have some keyframes with labels.On .fla file in property in Class field i adde MyMatching class.
Also i have main code:
package
{
[code]......
my problem is I want to move all the instances of the attacker class, without using code inside the movieclips timeline.
like:
ActionScript Code:
CLASS:
speed = 5
oneverysingleframe(
allofmahchildren.y - = speed
)
Got to the point where the hole in my AS3 knowledge is getting large!Realising I have confusion about the relationship of:Body of code on first frame of AS3 file.(Which I have so far used to create instances of library objects using addchild and make calls to class code).Is this code called the document code? What do people call it?Numerous classes linked together by extending each other etc.Library objects (usually graphical objects)Should it be done differently? have the following problems due to lack of understanding:Addchild complicated from a class but straight forward in main body code.Cant call functions on the main body code from classes, because class code does not know the main body code exists?
View 1 RepliesI had a 2 frame setup with some actionscript for each frame. Tried to move it all into one class file and a
1. frame .fla. ; Hiding and showing the resp. moviclips when i virtually move from frame 1 to frame
2. Now I get these ...Error #1069: Property edit_panel_mc not found on flash.display and there is no default value. errors or..
when i thought beeing clever adding the stage. prefix ReferenceError: Error #1069: Property edit_panel_mc not found on flash.display.Stage and there is no default value. The mc's are on the stage... i have a single .as classfile. Why cant I reference them? or how should i do it/ what should i do to change it from beeing .fla script to class script.
I see a lot of tutorials about coding actionscript 3 when they use all the code in a Class.I keep thinking every time why they use it in a class, instead of using actionscript on the stage.why it is more functional to code a class instead of putting code in the stage actionscript?
View 3 RepliesI'm testing flash and decided to make an asteroids clone. It works well but all the code is loaded in the first, and only, frame.Now I want to add a preloader but I cant find the way to move the code to the second frame. I don't want to create a swf and embed it. Also there are no assets created in flash, it has been coded exclusively in flashdevelop (I find it easier to use).
View 4 Replies_xmouse and _ymouse are read only. How do I move the courser from AS code?
View 9 RepliesSay you were importing flash.events.KeyboardEvent and you wanted it to extend the MovieClip class, is this possible? Where you dont have access to the class to just type "extends XXX"
View 14 RepliesI have 3 main movieclips with roughly 100 other related movieclips that I need to move together frame per frame. For example main movieclip1 has about 100 frames. If main movieclip 1 is on frame 3, I want movieclips 4, 5, and 10 to also be on frame 100 I think the code may involve an array with forEach function.
View 1 RepliesJust a single button that will call an action script. That action script will call
private var m_MicCnx:NetConnection; //connection over the server
private var m_MicStream:NetStream; //Audio Output
private var m_Microphone:Microphone; //micro, attach with m_MicStream's audio content
[code]....
I think this is the most simple setup I can get that will publish a microphone to a RTMP stream. This is an attempt to shave down a larger product. This demo will help a third party create a RTMP Stream Reader for mp3.How do I move from this snippet of code to a flash application? Most tutorials I've found so far were either about using menus or creating very complex animations. I just need a single button that will call this, or maybe an auto-load.
I have zoom code here
Code:
onClipEvent(load){
scrollMin = _root.range._x+_root.range._width // minimum _x value possiible for scrollbar
scrollMax = _root.range._x // maximum _x value possiible for scrollbar
[code]....
Do I have to copy and paste all of the slider code into the frame where my btns are? _root.srchMC.dataMC.site1_btn.onPress...
My film works ok. But if you move between the color buttons, the first time they react ok, just like i want, but the second time they get a life o they're own, driving me crazy... what am i doing worng? why doesn't the code do what it should?
View 3 RepliesHere is code for drag. i want to change as3 class to normal code as3
View 6 RepliesI have an xml snippet that contains an object hierarchy:
doc = """
<RootObj val1="ValueOne" stat1="Stat1" stat2="Stat2">
<internalarray type="array">
<InternalObject val1="12" val2="12" />
<InternalObject val1="13" val2="13" />
[Code]...
basically this is the code i got from a kirupa tutorial and i just want the graphic to be moved on the x axis
onClipEvent (enterFrame) {
getlimits = _root.normalpic.getBounds(_root);
//get the limits of the normal pic movie
[code].....
how to move the stage within the actual .fla file by modifying this.x and this.y variables in the layer 1 actionscript.
But within the document class- public class Starlight extends MovieClip, it does not seem to work no matter what i try and my research lead me to this use code instead:
for( i = 0; i < stage.numChildren; i ++){
stage.getChildAt(i).x -= player.speedx * player.bounceSpeed;
stage.getChildAt(i).y -= player.speedy * player.bounceSpeed;
}
I do realize that its hacky and slower as compared to actually moving the stage itself. And i'm not sure what's going to happen if another object that moves comes into the stage because technically this code is unnaturally altering the x,y of everything in the stage.
[Code]....
I know how to move the stage within the actual .fla file by modifying this.x and this.y variables in the layer 1 actionscript.But within the document class- public class Starlight extends MovieClip, it does not seem to work no matter what i try and my research lead me to this use code instead:
ActionScript Code:
for( i = 0; i < stage.numChildren; i ++){
stage.getChildAt(i).x -= player.speedx * player.bounceSpeed;
stage.getChildAt(i).y -= player.speedy * player.bounceSpeed;
}
I do realize that its hacky and slower as compared to actually moving the stage itself. And i'm not sure what's going to happen if another object that moves comes into the stage because technically this code is unnaturally altering the x,y of everything in the stage.
I'm just starting with as3 object oriented programming -- i've always liked the idea, but could never "see" how the whole objects/classes worked with actual game development.in my fla file i have this...
Actionscript Code:
var moveBob:MoveMan =new MoveMan()
in my MoveMan.as file...
Actionscript Code:
package { public class MoveMan { public function MoveMan() { bob.x = 5 } }}
and on the stage i have a movieclip with the name set as "bob" If i use this line in my fla file... bob.x = 100 it works.But when i try to move the movieclip inside the class i get this.1120: Access of undefined property
I have various instances of an object that I want to animate.
Code:
var obj = new obj_class();
I'm using the Tween class to move them around the screen.
Code: var tw:Tween=new Tween(obj, "y", None.easeNone, y1, y2, framerate);
tw.addEventListener(TweenEvent.MOTION_FINISH, removeObj);
addChild(obj);
I start the animation on a button press.Code: stage.addEventListener(KeyboardEvent.KEY_DOWN,key_down); When I click the button the animation of the instances seems ok, but if I click the button quickly sometime the animation doesn't end, the object seems freezed in the middle of the screen and also the MOTION_FINISH isn't called.
in Flex if i have a loader class (i.e., XMLLoader) and a document class (document.as) and in document.as I'm instantiating XMLLoadervar ldr:XMLLoader = new XMLLoader(url);... and on the document.as class I have a text box, which I would like updated with the progress from that XMLLoader is making by using URLLoaders progress event, continously. Meaning, the box would show the load in bytes that it is recievingI'm not sure how to constantly push data out of an event and add it to another class. For example:
myLstnr.addEventListener(ProgressEvent.PROGRESS, getProgress);
private function getProgress():void
{
[code].....
i need a class that lets modify or move any movieclip.so far in my class i have
ActionScript Code:
package com.bullets {
import flash.display.MovieClip;
public class MoveBullet extends MovieClip {
[code]....
i have a movieclip on the stage on frame 1 called "testbullet". how do i make the MoveBullet class run through testbullet?
how to write a actionscript code for a button when the button is clicked it should move to the nextframe.
// About and smile1 button scripts
stop();
_root.smile1.onPress = function() {
if (mouse_over_smile1) {
[code]....
i have given 3 functions as onEnterFrame,onPress,onRelease. i tried all these but didnt get the result.smile1,smile2,smile3 are button instances which are declared on the monie clip.my main thing is i hav a button, when i click on that button it should go the next frame which i have declared in "gotoAndPlay(6)" method.
I'm trying to achieve a simplified version of the move to screen area and zoom nav similar to: [URL]. I've read and completed the macromedia tweening tutorials [URL] and gained overview of tween class etc., So, I created an example (credit :sophistikat) using the macromedia tween class:
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
myBtn.onRelease = function () {
//first move to center in one second witih no delay
main_mc.tween("_x", 50, 1, "easeinoutElastic");
main_mc.tween("_y", 50, 1, "easeinoutElastic");
// and in 2 seconds scale closer
main_mc.tween("_xscale", 150, 1, "easeinoutElastic", 2, true);
main_mc.tween("_yscale", 150, 1, "easeinoutElastic", 2, true);
}
The script in layer 1, the bt in layer 2 and the main_mc in layer 3 - all correctly 'instanced'. But not working - the main_mc isn't moving and then zooming in when btn is clicked.
I built my first simple class which just makes a movieclip move around randomly on the stage. I wanted to know if the "class" experts can take a look at my code and let me know how I can improve. I want it so that it is the most efficient code and can be applied to any movieclip that I want as easy as possible.
[Code]....
I have the following code to create a Sprite with a rectangle in it:
container = new Sprite();
container.graphics.beginFill(0x00CCFF, .5);
container.graphics.lineStyle(1, 0x00CCFF);[code].......
The only thing is, I'd like the registration point to be in the middle (not the top left corner). Is there a way to set up the registration point in the middle of the rectangle, but still have the position of the rectangle be correct?
i.e. not moved over so that the top left corner of the rectangle is in the "middle" of where I want the rectangle to be...
I added a font Arial to the library. In properties for the font the Class box is greyed out. Do I need to add the font class in the code?Also I have a dynamic text box on the stage. Which anti-alias setting do I use and can / should it be selectable? I also selected character embedding and selected ALL for Arial Narrow Bold.
The text is not showing up arial narrow bold
var mainText = new TextFormat();mainText.font = "Arial Narrow"; mainText.size = 18;mainText.color = 0x333333;mainText.bold = true;
the first code (which I put into a frame) is somehow in conflict with my document class.I get these error messages:
1046: Type was not found or was not a compile-time constant: URLRequest
1180: Call to a possible undefined method URLRequest.
1180: Call to a possibly undefined method navigateToURL
But when I only use that code and unlink the document class it works. So there must be somehow a conflict between the two, but I have no idea how to integrate this code into my document class -I already tried it but the error messages keep coming, probably I didn't do it right.
code in frame:
Actionscript Code:
btn_contact.addEventListener(MouseEvent.CLICK, contactClickHandler);function contactClickHandler(event:MouseEvent):void { var url:URLRequest = new URLRequest("../Subpages/SubpageContact.html"); navigateToURL(url, "_top");}
[CODE]....
This is the file before the move [URL]... when you click the contact us button it should dissolve now I get:
ArgumentError: Error #2005: Parameter 0 is of the incorrect type. Should be type IBitmapDrawable. at flash.display::BitmapData/draw()at WebSite/$construct/gotoContact()[C:AS3projectsfullBrowserscaleVid WebSite.as:65]
here's the code: the offending code is in bold everything but the pixel dissolve works as before com is the instance of flvPlayback component that's on stage at author time there is nothing else on stage at author time and no action script in the flv
[Code]...
How i can use this code in mxml application,as we know we can not use public class in mx script so what are the way to do that as you can see .mx_internal,i am getting error on that saying'define object before dot' as i remove mx_internal and tried using import mx.binding.mx_internal and use namespace mx_internal application not desplaying anything
package components
{
import flash.events.*;
import flash.utils.*;[code].....
i download an external class from code.google.com. now i want to know where should i put that class so that i can import it into my actionscript code.
View 1 Replies