A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: [v7] Exit Errors in AS3 with KoolMoves

  1. #1
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267

    [v7] Exit Errors in AS3 with KoolMoves

    Look at this code AS3:
    Code:
    visible=false;
    
    var oldScaleMode:String=stage.scaleMode;
    stage.scaleMode="exactFit";
    
    var sW:Number=stage.stageWidth;
    var sH:Number=stage.stageHeight;
    
    stage.scaleMode=oldScaleMode;
    
    var bounds_obj:Object=this.getBounds(this);
    
    var camH:Number=bounds_obj.height;
    var camW:Number=bounds_obj.width;
    
    var rp:Point=new Point(x,y);
    
    addEventListener(Event.ENTER_FRAME,camControl);
    addEventListener(Event.REMOVED_FROM_STAGE,reset);
    
    
    var bmp:Bitmap;
    var myBitmapData:BitmapData=new BitmapData(sW,sH,true,0);
    bmp=new Bitmap(myBitmapData);
    
    camControl();
    
    stage.addChild(bmp);
    
    
    function camControl(...event):void {
    
    	parent.visible=true;
    
    	rp.x=x;
    	rp.y=y;
    
    	var h:Number=camH * scaleY;
    	var w:Number=camW * scaleX;
    
    	var _scaleY:Number=sH / h;
    	var _scaleX:Number=sW / w;
    
    	x2=w / 2 * _scaleX;
    	y2=h / 2 * _scaleY;
    
    	scaleX2=_scaleX;
    	scaleY2=_scaleY;
    
    	rotation2=- rotation;
    
    	myBitmapData.lock();
    	myBitmapData.fillRect(myBitmapData.rect,0x00);
    	myBitmapData.unlock();
    
    	myBitmapData.draw(stage);
    	
    	bmp.filters=this.filters;
    	bmp.transform.colorTransform=this.transform.colorTransform;
    
    	parent.visible=false;
    
    }
    
    function reset(e:Event):void {
    
    	removeEventListener(Event.ENTER_FRAME,camControl);
    	removeEventListener(Event.REMOVED_FROM_STAGE,reset);
    
    	stage.removeChild(bmp);
    	myBitmapData.dispose();
    	bmp=null;
    
    	parent.scaleX=1;
    	parent.scaleY=1;
    	parent.x=0;
    	parent.y=0;
    	parent.rotation=0;
    
    	parent.visible=true;
    
    }
    function set x2(value:Number):void {
    	var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
    	parent.x+= value - p.x;
    }
    function get x2():Number {
    	var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
    	return p.x;
    }
    function set y2(value:Number):void {
    	var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
    	parent.y+= value - p.y;
    }
    function get y2():Number {
    	var p:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
    	return p.y;
    }
    function get scaleX2():Number {
    	return parent.scaleX;
    }
    function set scaleX2(value:Number):void {
    	setProperty2("scaleX",value);
    }
    
    function get scaleY2():Number {
    	return parent.scaleY;
    }
    
    function set scaleY2(value:Number):void {
    	setProperty2("scaleY",value);
    }
    
    function get rotation2():Number {
    	return parent.rotation;
    }
    function set rotation2(value:Number):void {
    	setProperty2("rotation",value);
    }
    
    function setProperty2(prop:String,n:Number):void {
    	var a:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
    
    	parent[prop]=n;
    
    	var b:Point=parent.parent.globalToLocal(parent.localToGlobal(rp));
    
    	parent.x-= b.x - a.x;
    	parent.y-= b.y - a.y;
    }
    I proved it in Macromedia Flash CS3 and it works well, but in KollMoves notes the following errors output:
    - Line 82: function set x2 expecting a left parenthesis.
    It the show it in all functions of this type in this code.
    How resolved it ? Thanks and Cheers.

  2. #2
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    I don't understand all the parent you use.
    Is this supposed to be frame code or a separate class ?
    If I try your code in a frame in Flash CS3, it compiles but at runtime also displays error messages.

  3. #3
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Willians Sorry, I forgot to say the most important, is that this code is the first and only frame of a movie clip. Not in the principal movie.
    Last edited by byweb; 02-15-2009 at 02:54 PM.

  4. #4
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Thanks for mentioning the problem Byweb.
    Currently KM doesn't support function get and function set in frame scripts but only in external classes.

  5. #5
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Really need this or something similar code for a new AS3 project I'm working on now, I'm trying to do this with KoolMoves 7.0.1.
    http://www.electroluxappliances.com/low/node58.aspx
    If you know another way to achieve this, I would thanks. Or should I convert this code in a class ? Thanks.

  6. #6
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    What are you trying to do with this code ?

  7. #7
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Quote Originally Posted by byweb
    I'm trying to do this with KoolMoves 7.0.1.
    http://www.electroluxappliances.com/low/node58.aspx
    If you know another way to achieve this, I would thanks. Or should I convert this code in a class ? Thanks.
    Those are external FLV files (movies exported from 3DSMax, Maya, etc).
    It has nothing to do with "camera" and 3D in flash.

    cheers

  8. #8
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Quote Originally Posted by w.brants
    What are you trying to do with this code ?
    Willians, with this code I want to do is create a camera, I think the first step is to create the skybox as Necromanthu's example , for it, I create the 3D environment of the kitchen. Then with this camera zoomed to give this effect on the skyboxKitchen ( I do not know if you can combine the two effects.)
    I can see this code and examples of Vcam HERE
    Quote Originally Posted by necromanthus
    Those are external FLV files (movies exported from 3DSMax, Maya, etc).
    It has nothing to do with "camera" and 3D in flash.
    cheers
    Necro, I think that it's , just combine your skybox for example, with a zoom effect in a given area of the stage.

  9. #9
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    If you want real 3D, you should use Remus' Necro3D engine.

    If it's just the zooming and scaling that Vcam class does, I suggest programming things yourself or use TweenMax. To me it seems TweenMax is a lot more flexible compared to that Vcam class and Chris has confirmed it works with KM 7.

  10. #10
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Quote Originally Posted by byweb
    I think the first step is to create the skybox as Necromanthu's example , for it, I create the 3D environment of the kitchen. Then with this camera zoomed to give this effect on the skyboxKitchen
    http://necromanthus.com/KoolMoves/AS3/Skybox.html
    Just use the Cursor Up & Down keys for Zoom In & Out.
    note: you need a high quality image for best results.

  11. #11
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    From the way it looks to me, the basic kitchen pic has a series of invisable hot spots, which then load further swf which are the individual appliancies zoom in. I did notice that once you have zoomed in to 1, nothing else is clickable, till you hit back, which appears to reverse the zoom swf, and on end reloads the start pic again.
    The frre app that you linked to looks as if it allows you to pre-programme a zoom sequence, and then export the result as a swf, if thats the case, you could use it to make your component swfs, and then build the result in KM.
    From what I have seen of Necros class, it requires the user to zoom in and out and look around, which is just great, but not exactly what you need here.

  12. #12
    That web bloke Stoke Laurie's Avatar
    Join Date
    Jan 2006
    Location
    England
    Posts
    869
    Ive tried the free app, and it allows for a pre-programmed sweep over a picture, using zoom, and rotate and blur. The resultant swf is then exported.
    You will need cs4 to use this tool, however the resultant swf an easily be imported into km as I suggested.

  13. #13
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Quote Originally Posted by necromanthus
    http://necromanthus.com/KoolMoves/AS3/Skybox.html
    Just use the Cursor Up & Down keys for Zoom In & Out.
    note: you need a high quality image for best results.
    Thanks, Necro I study your example.
    Thanks Stoke but, I think obout that it's CS3 and AS3.

  14. #14
    undead creature necromanthus's Avatar
    Join Date
    Feb 2002
    Location
    ROM
    Posts
    1,890
    Quote Originally Posted by byweb
    Thanks, Necro I study your example.
    I've replaced the texture and now the result is MUCH better.

    In any case, if you want to replace those FLVs with some real 3D,
    is not such a big deal to create a few camera predefined paths (and predefined zoom values) instead of mouse click & drag.
    All you have to do is to define two arrays (the 1st for camera rotation and the 2nd for zoom) and a sequencer to read the array cells at runtime.
    But for a "3d kitchen" with 360 degrees view you don't need all this extra stuff.

  15. #15
    Senior Member byweb's Avatar
    Join Date
    Apr 2007
    Location
    Andalucia (spain)
    Posts
    267
    Necro Thanks for your help and understanding, yes really I know that there must be a way to make this easier, but I do not know, I not learned all the AS1 and now trying to do something with AS3, so always ask for you help . But considering your example is that with some time with this. Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center