Search Results

Search found 179 results on 8 pages for 'jef ty'.

Page 6/8 | < Previous Page | 2 3 4 5 6 7 8  | Next Page >

  • Scaling along an arbitrary axis (Dealing with non-uniform scale)

    - by Jon
    I'm trying to build my own little engine to get more familiar with the concepts of 3D programming. I have a transform class that on each frame it creates a Scaling Matrix (S), a Rotation Matrix from a Quaternion (R) and concatenates them together (S*R). Once i have SR, I insert the translation values into the bottom of the three columns. So i end up with a transformation matrix that looks like: [SR SR SR 0] [SR SR SR 0] [SR SR SR 0] [tx ty tz 1] This works perfectly in all cases except when rotating an object that has a non-uniform scale. For example a unit cube with ScaleX = 4, ScaleY = 2, ScaleZ = 1 will give me a rectangular box that is 4 times as wide as the depth and twice as high as the depth. If i then translate this around, the box stays the same and looks normal. The problem happens whenever I try to rotate this scaled box. The shape itself becomes distorted and it appears as though the Scale factors are affecting the object on the World X,Y,Z axis rather than the local X,Y,Z axis of the object. I've done some pretty extensive research through a variety of textbooks (Eberly, Moller/Hoffman, Phar etc) and there isn't a ton there to go off of. Online, most of the answers say to avoid non-uniform scaling which I understand the desire to avoid it, but I'd still like to figure out how to support it. The only thing I can think off is that when constructing a Scale Matrix: [sx 0 0 0] [0 sy 0 0] [0 0 sz 0] [0 0 0 1] This is scaling along the World Axis instead of the object's local Direction, Up and Right vectors or it's local Z, Y, X axis. Does anyone have any tips or ideas on how to handle construction a transformation matrix that allows for non-uniform scaling and rotation? Thanks!

    Read the article

  • 1136: Incorrect number of arguments. Expected 0.? AS3 Flash Cs4

    - by charmaine
    Basically i am working through a book called..Foundation Actionscript 3.0 Animation, making things move. i am now on Chapter 9 - collision detection. On two lines of my code i get the 1135 error, letting me know that i have an incorrect number of arguments. Can anybody help me out on why this may be? package { import flash.display.Sprite; import flash.events.Event; public class Bubbles extends Sprite { private var balls:Array; private var numBalls:Number = 10; private var centerBall:Ball; private var bounce:Number = -1; private var spring:Number = 0.2; public function Bubbles() { init(); } private function init():void { balls = new Array(); centerBall = new Ball(100, 0xcccccc); addChild(centerBall); centerBall.x = stage.stageWidth / 2; centerBall.y = stage.stageHeight / 2; for(var i:uint = 0; i < numBalls; i++) { var ball:Ball = new Ball(Math.random() * 40 + 5, Math.random() * 0xffffff); ball.x = Math.random() * stage.stageWidth; ball.y = Math.random() * stage.stageHeight; ball.vx = Math.random() * 6 - 3; ball.vy = Math.random() * 6 - 3; addChild(ball); balls.push(ball); } addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(event:Event):void { for(var i:uint = 0; i < numBalls; i++) { var ball:Ball = balls[i]; move(ball); var dx:Number = ball.x - centerBall.x; var dy:Number = ball.y - centerBall.y; var dist:Number = Math.sqrt(dx * dx + dy * dy); var minDist:Number = ball.radius + centerBall.radius; if(dist < minDist) { var angle:Number = Math.atan2(dy, dx); var tx:Number = centerBall.x + Math.cos(angle) * minDist; var ty:Number = centerBall.y + Math.sin(angle) * minDist; ball.vx += (tx - ball.x) * spring; ball.vy += (ty - ball.y) * spring; } } } ***private function move(ball:Ball):void*** { ball.x += ball.vx; ball.y += ball.vy; if(ball.x + ball.radius > stage.stageWidth) { ball.x = stage.stageWidth - ball.radius; ball.vx *= bounce; } else if(ball.x - ball.radius < 0) { ball.x = ball.radius; ball.vx *= bounce; } ***if(ball.y + ball.radius > stage.stageHeight)*** { ball.y = stage.stageHeight - ball.radius; ball.vy *= bounce; } else if(ball.y - ball.radius < 0) { ball.y = ball.radius; ball.vy *= bounce; } } } } The bold parts are the lines im having trouble with! please help..thanks in advance!!

    Read the article

  • iPhone multi-touch scale and rotate, how to prevent scale?

    - by russhill
    I have existing code for tracking multi-touch positions and then rotating and scaling the item - in this case an image - appropriately. The code works really well and in itself is perfect, however for this particular task, I need the rotation ONLY. I have spent time trying to work out what is going on in this routine, but maths is not my strong point so wanted to see if anyone could assist? - (CGAffineTransform)incrementalTransformWithTouches:(NSSet *)touches { NSArray *sortedTouches = [[touches allObjects] sortedArrayUsingSelector:@selector(compareAddress:)]; NSInteger numTouches = [sortedTouches count]; // No touches if (numTouches == 0) { return CGAffineTransformIdentity; } // Single touch if (numTouches == 1) { UITouch *touch = [sortedTouches objectAtIndex:0]; CGPoint beginPoint = *(CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch); CGPoint currentPoint = [touch locationInView:self.superview]; return CGAffineTransformMakeTranslation(currentPoint.x - beginPoint.x, currentPoint.y - beginPoint.y); } // If two or more touches, go with the first two (sorted by address) UITouch *touch1 = [sortedTouches objectAtIndex:0]; UITouch *touch2 = [sortedTouches objectAtIndex:1]; CGPoint beginPoint1 = *(CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch1); CGPoint currentPoint1 = [touch1 locationInView:self.superview]; CGPoint beginPoint2 = *(CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch2); CGPoint currentPoint2 = [touch2 locationInView:self.superview]; double layerX = self.center.x; double layerY = self.center.y; double x1 = beginPoint1.x - layerX; double y1 = beginPoint1.y - layerY; double x2 = beginPoint2.x - layerX; double y2 = beginPoint2.y - layerY; double x3 = currentPoint1.x - layerX; double y3 = currentPoint1.y - layerY; double x4 = currentPoint2.x - layerX; double y4 = currentPoint2.y - layerY; // Solve the system: // [a b t1, -b a t2, 0 0 1] * [x1, y1, 1] = [x3, y3, 1] // [a b t1, -b a t2, 0 0 1] * [x2, y2, 1] = [x4, y4, 1] double D = (y1-y2)*(y1-y2) + (x1-x2)*(x1-x2); if (D < 0.1) { return CGAffineTransformMakeTranslation(x3-x1, y3-y1); } double a = (y1-y2)*(y3-y4) + (x1-x2)*(x3-x4); double b = (y1-y2)*(x3-x4) - (x1-x2)*(y3-y4); double tx = (y1*x2 - x1*y2)*(y4-y3) - (x1*x2 + y1*y2)*(x3+x4) + x3*(y2*y2 + x2*x2) + x4*(y1*y1 + x1*x1); double ty = (x1*x2 + y1*y2)*(-y4-y3) + (y1*x2 - x1*y2)*(x3-x4) + y3*(y2*y2 + x2*x2) + y4*(y1*y1 + x1*x1); return CGAffineTransformMake(a/D, -b/D, b/D, a/D, tx/D, ty/D); } I have tried to read up on the way matrix's work, but cannot figure it out entirely. More likely to be the issue is the calculations, which as I mention is not my strong point. What I need from this routine is a transform that performs my rotation but ignores scale - so the distance between the 2 finger touch points is ignored and scale is not affected. I have looked at other routines on the internet to handle multi-touch rotation but all the ones I tried had issues in some way or other, whereas the above code is spot on for scale and rotate actions. Any help appreciated!

    Read the article

  • iPhone multi-touch move, scale and rotate, how to prevent scale?

    - by russhill
    I have existing code for tracking multi-touch positions and then moving, rotating and scaling the item - in this case an image - appropriately. The code works really well and in itself is perfect, however for this particular task, I need the movement and rotation ONLY. I have spent time trying to work out what is going on in this routine, but maths is not my strong point so wanted to see if anyone could assist? - (CGAffineTransform)incrementalTransformWithTouches:(NSSet *)touches { NSArray *sortedTouches = [[touches allObjects] sortedArrayUsingSelector:@selector(compareAddress:)]; NSInteger numTouches = [sortedTouches count]; // No touches if (numTouches == 0) { return CGAffineTransformIdentity; } // Single touch if (numTouches == 1) { UITouch *touch = [sortedTouches objectAtIndex:0]; CGPoint beginPoint = *(CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch); CGPoint currentPoint = [touch locationInView:self.superview]; return CGAffineTransformMakeTranslation(currentPoint.x - beginPoint.x, currentPoint.y - beginPoint.y); } // If two or more touches, go with the first two (sorted by address) UITouch *touch1 = [sortedTouches objectAtIndex:0]; UITouch *touch2 = [sortedTouches objectAtIndex:1]; CGPoint beginPoint1 = *(CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch1); CGPoint currentPoint1 = [touch1 locationInView:self.superview]; CGPoint beginPoint2 = *(CGPoint *)CFDictionaryGetValue(touchBeginPoints, touch2); CGPoint currentPoint2 = [touch2 locationInView:self.superview]; double layerX = self.center.x; double layerY = self.center.y; double x1 = beginPoint1.x - layerX; double y1 = beginPoint1.y - layerY; double x2 = beginPoint2.x - layerX; double y2 = beginPoint2.y - layerY; double x3 = currentPoint1.x - layerX; double y3 = currentPoint1.y - layerY; double x4 = currentPoint2.x - layerX; double y4 = currentPoint2.y - layerY; // Solve the system: // [a b t1, -b a t2, 0 0 1] * [x1, y1, 1] = [x3, y3, 1] // [a b t1, -b a t2, 0 0 1] * [x2, y2, 1] = [x4, y4, 1] double D = (y1-y2)*(y1-y2) + (x1-x2)*(x1-x2); if (D < 0.1) { return CGAffineTransformMakeTranslation(x3-x1, y3-y1); } double a = (y1-y2)*(y3-y4) + (x1-x2)*(x3-x4); double b = (y1-y2)*(x3-x4) - (x1-x2)*(y3-y4); double tx = (y1*x2 - x1*y2)*(y4-y3) - (x1*x2 + y1*y2)*(x3+x4) + x3*(y2*y2 + x2*x2) + x4*(y1*y1 + x1*x1); double ty = (x1*x2 + y1*y2)*(-y4-y3) + (y1*x2 - x1*y2)*(x3-x4) + y3*(y2*y2 + x2*x2) + y4*(y1*y1 + x1*x1); return CGAffineTransformMake(a/D, -b/D, b/D, a/D, tx/D, ty/D); } I have tried to read up on the way matrix's work, but cannot figure it out entirely. More likely to be the issue is the calculations, which as I mention is not my strong point. What I need from this routine is a transform that performs my movement and rotation but ignores scale - so the distance between the 2 finger touch points is ignored and scale is not affected. I have looked at other routines on the internet to handle multi-touch rotation but all the ones I tried had issues in some way or other (smoothness, jumping when lifting fingers etc), whereas the above code is spot on for move, scale and rotate actions. Any help appreciated!

    Read the article

  • learning OO with PHP

    - by dole doug
    Hi there I've started to learn OO programming, but using the PHP language with the help of the "PHP 5 Objects, Patterns, and Practice" book. The thing is that I wish to learn to use into same time the CakePHP framework which make use a lot of the MVC pattern. Because I don't know much about OO and less about MVC I wish to understand the later one but assumptions I make with my OO knowledges might have bad impact on long term. Does anyone know a good tutorial about what means MVC (more than cakephp manual says about it, but more easy to read/understand than wikipedia)? TY

    Read the article

  • Syntax Error with MySql Workbench and IF Statement

    - by Hugo S.
    Hey guys, Im migrating from T-SQL to MySql syntax and don't know how to get over this syntax error given by Workbench 5.1.18: -- -------------------------------------------------------------------------------- -- Routine DDL -- -------------------------------------------------------------------------------- DELIMITER // CREATE PROCEDURE `SysTicket`.`GetProductionLines` (aId INT, aActive INT, aResponsible VARCHAR(8000)) BEGIN IF(aId > 0) THEN SELECT * FROM ProductionLine WHERE Id = @Id; ELSE IF( aActive <> -1 AND aResponsible = '|$EMPTYARG$|') THEN SELECT * FROM ProductionLine; ELSE IF(aResponsible = '|$EMPTYARG&|') THEN SELECT * FROM ProductionLine WHERE Active = aActive; ELSE SELECT * FROM ProductionLine WHERE Active = aActive AND Responsible LIKE CONCAT('%', aResponsible, '%'); END IF; END// It says Syntax error near END (last line) ty in advance.

    Read the article

  • SCSI Windows Setup on Dell Precision 670 Workstation...please help.

    - by sweetcoder
    Error Windows Setup: "setup did not find any hard disk drives installed in your computer" This is not exactly a programming question but I thought you guys might be able to help. I just received a Dell Precision 670 workstation. Windows is not recognizing the hard drive and I have experienced this before with other computers. I usually would just go in the bios and set the configuration to compatibility mode. I have no idea how to do this on this machine. There is this Adaptec SCSI HostRaid BIOS v4.30.4S5 screen on startup. It says to press CTRL A for SCSI select utility. It shows a Maxtor ATLAS10K5_73WLS for the drive. I was wondering if anyone out there knew how to configure this thing so that windows setup will recognize the hard drive? Any advice is very much appreciated and if you have to know further information please let me know. Raid was turned off in the BIOS for this device. TY

    Read the article

  • Twisted Python getPage

    - by David Dixon II
    I tried to get support on this but I am TOTALLY confused. Here's my code: from twisted.internet import reactor from twisted.web.client import getPage from twisted.web.error import Error from twisted.internet.defer import DeferredList from sys import argv class GrabPage: def __init__(self, page): self.page = page def start(self, *args): if args == (): # We apparently don't need authentication for this d1 = getPage(self.page) else: if len(args) == 2: # We have our login information d1 = getPage(self.page, headers={"Authorization": " ".join(args)}) else: raise Exception('Missing parameters') d1.addCallback(self.pageCallback) dl = DeferredList([d1]) d1.addErrback(self.errorHandler) dl.addCallback(self.listCallback) def errorHandler(self,result): # Bad thingy! pass def pageCallback(self, result): return result def listCallback(self, result): print result a = GrabPage('http://www.google.com') data = a.start() # Not the HTML I wish to get the HTML out which is given to pageCallback when start() is called. This has been a pita for me. Ty! And sorry for my sucky coding.

    Read the article

  • tips for learning from opensource

    - by dole doug
    Hi there, Besides practice(practice and more practice) reading books and forums, analyzing others people code is a must in order to have a career in this field. The problem is that I'm a student(feels like always on learning stage) but sometimes i can't solve the problems by my own. I was thinking that on public open source repositories might be the answer I'm looking for. My question is how can i find the answer to some of my problems in open source projects/community? Do you have any tips to share for me? ty

    Read the article

  • Honor Whitespace padding to display columns in fixed width <select>

    - by Laramie
    I am trying to create the effect of columns in a dropdown by padding text with whitespace as in this example: <select style="font-family: courier;"> <option value="1">[Aux1+1] [*] [Aux1+1] [@Tn=PP] </option> <option value="2">[Main] [*] [Main Apples Oranges] [@Fu=$p] </option> <option value="3">[Main] [*] [Next NP] [@Fu=n] </option> <option value="4">[Main] [Dr] [Main] [@Ty=$p] </option> </select> According to this blog, it's possible. The problem is the whitespace is contracted so that the columsn don't line up. SAme results in FF, IE6 and Chrome. What am I missing?

    Read the article

  • C++ destructor seems to be called 'early'

    - by suicideducky
    Please see the "edit" section for the updated information. Sorry for yet another C++ dtor question... However I can't seem to find one exactly like mine as all the others are assigning to STL containers (that will delete objects itself) whereas mine is to an array of pointers. So I have the following code fragment #include<iostream> class Block{ public: int x, y, z; int type; Block(){ x=1; y=2; z=3; type=-1; } }; template <class T> class Octree{ T* children[8]; public: ~Octree(){ for( int i=0; i<8; i++){ std::cout << "del:" << i << std::endl; delete children[i]; } } Octree(){ for( int i=0; i<8; i++ ) children[i] = new T; } // place newchild in array at [i] void set_child(int i, T* newchild){ children[i] = newchild; } // return child at [i] T* get_child(int i){ return children[i]; } // place newchild at [i] and return the old [i] T* swap_child(int i, T* newchild){ T* p = children[i]; children[i] = newchild; return p; } }; int main(){ Octree< Octree<Block> > here; std::cout << "nothing seems to have broken" << std::endl; } Looking through the output I notice that the destructor is being called many times before I think it should (as Octree is still in scope), the end of the output also shows: del:0 del:0 del:1 del:2 del:3 Process returned -1073741819 (0xC0000005) execution time : 1.685 s Press any key to continue. For some reason the destructor is going through the same point in the loop twice (0) and then dying. All of this occures before the "nothing seems to have gone wrong" line which I expected before any dtor was called. Thanks in advance :) EDIT The code I posted has some things removed that I thought were unnecessary but after copying and compiling the code I pasted I no longer get the error. What I removed was other integer attributes of the code. Here is the origional: #include<iostream> class Block{ public: int x, y, z; int type; Block(){ x=1; y=2; z=3; type=-1; } Block(int xx, int yy, int zz, int ty){ x=xx; y=yy; z=zz; type=ty; } Block(int xx, int yy, int zz){ x=xx; y=yy; z=zz; type=0; } }; template <class T> class Octree{ int x, y, z; int size; T* children[8]; public: ~Octree(){ for( int i=0; i<8; i++){ std::cout << "del:" << i << std::endl; delete children[i]; } } Octree(int xx, int yy, int zz, int size){ x=xx; y=yy; z=zz; size=size; for( int i=0; i<8; i++ ) children[i] = new T; } Octree(){ Octree(0, 0, 0, 10); } // place newchild in array at [i] void set_child(int i, T* newchild){ children[i] = newchild; } // return child at [i] T* get_child(int i){ return children[i]; } // place newchild at [i] and return the old [i] T* swap_child(int i, T* newchild){ T* p = children[i]; children[i] = newchild; return p; } }; int main(){ Octree< Octree<Block> > here; std::cout << "nothing seems to have broken" << std::endl; } Also, as for the problems with set_child, get_child and swap_child leading to possible memory leaks this will be solved as a wrapper class will either use get before set or use swap to get the old child and write this out to disk before freeing the memory itself. I am glad that it is not my memory management failing but rather another error. I have not made a copy and/or assignment operator yet as I was just testing the block tree out, I will almost certainly make them all private very soon. This version spits out -1073741819. Thank you all for your suggestions and I apologise for highjacking my own thread :$

    Read the article

  • Idiomatic usage of filter, map, build-list and local functions in Racket/Scheme?

    - by Greenhorn
    I'm working through Exercise 21.2.3 of HtDP on my own and was wondering if this is idiomatic usage of the various functions. This is what I have so far: (define-struct ir (name price)) (define list-of-toys (list (make-ir 'doll 10) (make-ir 'robot 15) (make-ir 'ty 21) (make-ir 'cube 9))) ;; helper function (define (price< p toy) (cond [(< (ir-price toy) p) toy] [else empty])) (define (eliminate-exp ua lot) (cond [(empty? lot) empty] [else (filter ir? (map price< (build-list (length lot) (local ((define (f x) ua)) f)) lot))])) To my novice eyes, that seems pretty ugly because I have to define a local function to get build-list to work, since map requires two lists of equal length. Can this be improved for readability? Thank you.

    Read the article

  • Interface function C#

    - by user181421
    Hello, I have a function which implement an interface. something like this: string IMyInterface.MyFunction() { do something; } This function is available outside of my class. All working perfect. Now I also need to call this function from another LOCAL non public function. like this: void Func2() { string s; s = MyFunction(); } The problem is I get this error: "the name MyFunction does not exist in the current context local" Any help will be appreciated. TY.

    Read the article

  • Cache Wrapper with expressions

    - by Fujiy
    I dont know if is possible. I want a class to encapsulate all Cache of my site. I thinking about the best way to do this to avoid conflict with keys. My first idea is something like this: public static TResult Cachear<TResult>(this Cache cache, Expression<Func<TResult>> funcao) { string chave = funcao.ToString(); if (!(cache[chave] is TResult)) { cache[chave] = funcao.Compile()(); } return (TResult)cache[chave]; } Is the best way? Ty

    Read the article

  • Pixel plot method errors out without error message.

    - by sonny5
    // The following method blows up (big red x on screen) without generating error info. Any // ideas why? // MyPlot.PlotPixel(x, y, Color.BlueViolet, Grf); // runs if commented out // My goal is to draw a pixel on a form. Is there a way to increase the pixel size also? using System; using System.Drawing; using System.Drawing.Drawing2D; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; public class Plot : System.Windows.Forms.Form { private Size _ClientArea; //keeps the pixels info private double _Xspan; private double _Yspan; public Plot() { InitializeComponent(); } public Size ClientArea { set { _ClientArea = value; } } private void InitializeComponent() { this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(400, 300); this.Text="World Plot (world_plot.cs)"; this.Resize += new System.EventHandler(this.Form1_Resize); this.Paint += new System.Windows.Forms.PaintEventHandler(this.doLine); this.Paint += new System.Windows.Forms.PaintEventHandler(this.TransformPoints); // new this.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawRectangleFloat); this.Paint += new System.Windows.Forms.PaintEventHandler(this.DrawWindow_Paint); } private void DrawWindow_Paint(object sender, PaintEventArgs e) { Graphics Grf = e.Graphics; pixPlot(Grf); } static void Main() { Application.Run(new Plot()); } private void doLine(object sender, System.Windows.Forms.PaintEventArgs e) { // no transforms done yet!!! Graphics g = e.Graphics; g.FillRectangle(Brushes.White, this.ClientRectangle); Pen p = new Pen(Color.Black); g.DrawLine(p, 0, 0, 100, 100); // draw DOWN in y, which is positive since no matrix called p.Dispose(); } public void PlotPixel(double X, double Y, Color C, Graphics G) { Bitmap bm = new Bitmap(1, 1); bm.SetPixel(0, 0, C); G.DrawImageUnscaled(bm, TX(X), TY(Y)); } private int TX(double X) //transform real coordinates to pixels for the X-axis { double w; w = _ClientArea.Width / _Xspan * X + _ClientArea.Width / 2; return Convert.ToInt32(w); } private int TY(double Y) //transform real coordinates to pixels for the Y-axis { double w; w = _ClientArea.Height / _Yspan * Y + _ClientArea.Height / 2; return Convert.ToInt32(w); } private void pixPlot(Graphics Grf) { Plot MyPlot = new Plot(); double x = 12.0; double y = 10.0; MyPlot.ClientArea = this.ClientSize; Console.WriteLine("x = {0}", x); Console.WriteLine("y = {0}", y); //MyPlot.PlotPixel(x, y, Color.BlueViolet, Grf); // blows up } private void DrawRectangleFloat(object sender, PaintEventArgs e) { // Create pen. Pen penBlu = new Pen(Color.Blue, 2); // Create location and size of rectangle. float x = 0.0F; float y = 0.0F; float width = 200.0F; float height = 200.0F; // translate DOWN by 200 pixels // Draw rectangle to screen. e.Graphics.DrawRectangle(penBlu, x, y, width, height); } private void TransformPoints(object sender, System.Windows.Forms.PaintEventArgs e) { // after transforms Graphics g = this.CreateGraphics(); Pen penGrn = new Pen(Color.Green, 3); Matrix myMatrix2 = new Matrix(1, 0, 0, -1, 0, 0); // flip Y axis with -1 g.Transform = myMatrix2; g.TranslateTransform(0, 200, MatrixOrder.Append); // translate DOWN the same distance as the rectangle... // ...so this will put it at lower left corner g.DrawLine(penGrn, 0, 0, 100, 90); // notice that y 90 is going UP } private void Form1_Resize(object sender, System.EventArgs e) { Invalidate(); } }

    Read the article

  • min.js to clear source

    - by dole
    Hi there As far i know until now, the min version of a .js(javascript) file is obtaining by removing the unncessary blank spaces and comments, in order to reduce the file size. My questions are: How can I convert a min.js file into a clear, easy readable .js file Besides, size(&and speed) are there any other advtages of the min.js file. the js files can be encripted? can js be infected. I think the answer is yes, so the question is how to protect the .js files from infections? Only the first question is most important and I'm looking for help on it. TY

    Read the article

  • 1136: Incorrect number of arguments. Expected 0.? AS3 Flash Cs4 (Round 2)

    - by charmaine
    (I have asked this before but I dont think I was direct enough with my question and therefore it did not get resolved so here goes again!) I am working through a book called Foundation Actionscript 3.0 Animation, making things move. I am now on Chapter 9 - Collision Detection. On two lines of my code I get the 1135 error, letting me know that I have an incorrect number of arguments. I have highlighted the two areas in which this occurs with asterisks: package { import flash.display.Sprite; import flash.events.Event; public class Bubbles extends Sprite { private var balls:Array; private var numBalls:Number = 10; private var centerBall:Ball; private var bounce:Number = -1; private var spring:Number = 0.2; public function Bubbles() { init(); } private function init():void { balls = new Array(); ***centerBall = new Ball(100, 0xcccccc);*** addChild(centerBall); centerBall.x = stage.stageWidth / 2; centerBall.y = stage.stageHeight / 2; for(var i:uint = 0; i < numBalls; i++) { ***var ball:Ball = new Ball(Math.random() * 40 + 5, Math.random() * 0xffffff);*** ball.x = Math.random() * stage.stageWidth; ball.y = Math.random() * stage.stageHeight; ball.vx = Math.random() * 6 - 3; ball.vy = Math.random() * 6 - 3; addChild(ball); balls.push(ball); } addEventListener(Event.ENTER_FRAME, onEnterFrame); } private function onEnterFrame(event:Event):void { for(var i:uint = 0; i < numBalls; i++) { var ball:Ball = balls[i]; move(ball); var dx:Number = ball.x - centerBall.x; var dy:Number = ball.y - centerBall.y; var dist:Number = Math.sqrt(dx * dx + dy * dy); var minDist:Number = ball.radius + centerBall.radius; if(dist < minDist) { var angle:Number = Math.atan2(dy, dx); var tx:Number = centerBall.x + Math.cos(angle) * minDist; var ty:Number = centerBall.y + Math.sin(angle) * minDist; ball.vx += (tx - ball.x) * spring; ball.vy += (ty - ball.y) * spring; } } } private function move(ball:Ball):void { ball.x += ball.vx; ball.y += ball.vy; if(ball.x + ball.radius > stage.stageWidth) { ball.x = stage.stageWidth - ball.radius; ball.vx *= bounce; } else if(ball.x - ball.radius < 0) { ball.x = ball.radius; ball.vx *= bounce; } if(ball.y + ball.radius > stage.stageHeight) { ball.y = stage.stageHeight - ball.radius; ball.vy *= bounce; } else if(ball.y - ball.radius < 0) { ball.y = ball.radius; ball.vy *= bounce; } } } } I think this is due to the non-existance of a Ball.as, when reading the tutorial I assumed it meant that I had to create a movie clip of a ball on stage and then export it for actionscript with the class name being Ball, however when flicking back through the book I saw that a Ball.as already existed, stating that I may need to use this again later on in the book, this read: package { import flash.display.Sprite; public class Ball extends Sprite { private var radius:Number; private var color:uint; public var vx:Number=0; public var vy:Number=0; public function Ball(radius:Number=40, color:uint=0xff0000) { this.radius=radius; this.color=color; init(); } public function init():void { graphics.beginFill(color); graphics.drawCircle(0, 0, radius); graphics.endFill(); } } } This managed to stop all the errors appearing however, it did not transmit any of the effects from Bubbles.as it just braught a Red Ball on the center of the stage. How would I alter this code in order to work in favour of Bubbles.as? Please Help! Thanks!

    Read the article

  • Change the output of the Html.menu() asp control .

    - by user327893
    Im creating a asp mvc application and im using a sitemap to create my menu. Is it possible to change the output of the Html.menu() asp control? normal output: <ul> <li><a href="#">Item 1</li> <li><a href="#">Item 2</li> </ul> needed output: <ul> <li><a href="#"><span>Item 1</span></li> <li><a href="#"><span>Item 2</span></li> </ul> Or should i filter true the nodes of the sitemap to get the format i want?? TY in advance:)

    Read the article

  • Tkinter change all color when variable change

    - by Morten Larsen
    hi i have a simpel tkinter window. consists of a small window, a timer, and a button for set timer. dont want to go in details with the code... Now all the widgets in my windows eg. button, Label Ect. will have to change color. EG. i Have a global variabel wich i will set as color "red" fx... All the widgets BACKGROUND option is associated with the global variabel. Now on button press i will change the global variable to "green" so that the background of all widgets ect. will change color, but they DONT. i thought the .mainloop() sort of UPDATED the window. how can i have the widgets to change background color when my variable change WITHOUT restarting my application??? ty Xanthar

    Read the article

  • ASP MVC: Keeping track of logged in users.

    - by user323395
    I'm creating a ASP MVC application. And because of the complex authorization i'm trying to build my own login system. (So i'm not using asp membership providers, and related classes). Now i'm able to create new accounts in the database with hashed passwords. But how do i keep track that a user is logged in. Is generating a long random number and putting this with the userID in the database and cookie enough? Sorry for my rather bad english! Ty in advance :)

    Read the article

  • Two foreach loops, ideea for my code please

    - by webmasters
    Please give me an ideea for my code, its a simple links script. TY I need two foreach loops, one which loops my sites and one which loops my anchors. So i'll have <li>link to site1 and anchor to site1</li> <li>link to site2 and anchor to site2</li> <li>link to site3 and anchor to site3</li> $currentsite = ''.bloginfo('wpurl').''; $mysites = array('http://site1.com', 'http://site2.com', 'http://site3.com'); $myanchors = array('anchor1','anchor2','anchor3'); foreach($mysites as $mysite) ****** i need a foreach loop for the anchors array ******* { if ( $mysite !== $currentsite ){echo '<li><a href="'.$mysite.'" title="'.$myanchor.'">'.$myanchor.'</a></li>';} }

    Read the article

  • Use applescript to write iCal data to file

    - by Guy
    I am trying to get applescript to read todays ical events and write them to a file. The code is as follows: set out to "" tell application "iCal" set todaysDate to current date set time of todaysDate to 0 set tomorrowsDate to todaysDate + (1 * days) repeat with c in (every calendar) set theEvents to (every event of c whose start date = todaysDate and start date < tomorrowsDate) repeat with current_event in theEvents set out to out & summary of current_event & " " end repeat end repeat end tell set the_file to (((path to documents folder) as string) & "DesktopImage:ical.txt") try open for access the_file with write permission set eof of the_file to 0 write out to the_file close access the_file on error try close access the_file end try end try return out The ical items are getting returned correctly and the file ical.txt is created correctly in the folder Documents/DesktopImage, but the file is blank. Even if I substitute write out to the_file with write "Test string" to the_file it still comes up blank any ideas? Ty

    Read the article

  • Exporting ActiveRecord objects into POROs

    - by Lucas d. Prim
    Hello, I'm developing a "script generator" to automatize some processes at work. It has a Rails application running on a server that stores all data needed to make the script and generates the script itself at the end of the process. The problem I am having is how to export the data from the ActiveRecord format to Plain Old Ruby Objects (POROs) so I can deal with them in my script with no database support and a pure-ruby implementation. I tought about YAML, CSV or something like this to export the data but it would be a painful process to update these structures if the process changes. Is there a simpler way? Ty!

    Read the article

  • server side of adsense

    - by dole
    Hi there Google ask you to add a javascript code to your page and it will generate the links. The script has some id which are sent to the server, but I don't know how. <script type="text/javascript"><!-- google_ad_client = "ca-pub-1234567890123456"; /* snipet_name */ google_ad_slot = "123456789"; google_ad_width = 728; google_ad_height = 90; //--></script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script> I'm curious to know how the client and slot ids are send to the server. Javascript is client side and I wish to know how those parameters are sent to the server in order to query a db and to return the links. A link, sample, explanation related to PHP will work great for me. TY

    Read the article

  • STL: how to overload operator= for <vector> ?

    - by MBes
    There's simple example: #include <vector> int main() { vector<int> veci; vector<double> vecd; for(int i = 0;i<10;++i){ veci.push_back(i); vecd.push_back(i); } vecd = veci; // <- THE PROBLEM } The thing I need to know is how to overload operator = so that I could make assignment like this: vector<double> = vector<int>; I've just tried a lot of ways, but always compiler has been returning errors... Is there any option to make this code work without changing it? I can write some additional lines, but can't edit or delete the existing ones. Ty.

    Read the article

< Previous Page | 2 3 4 5 6 7 8  | Next Page >