SwishTalk.com
 

Go Back   SwishTalk.com > .:: THE HELP DESK ::. > » Actionscript Help

Reply
 
Thread Tools Display Modes
#1   Help required converting ActionScript to Swish MAX Script  

Name: 
nish
Status: Offline
Rank: Registered User
Posts: 4
Old 01-16-2010, 01:33 PM Reply With Quote


I am trying to convert the following script. Any help would be gratefully received.

Code:
hsize = 400;
vsize = 400;
rotate1 = true;
rotate2 = false;
rotate3 = false;
flip = true;
slices = 12;
nudge = 9.03;
rotspeed1 = 4.03;
sclfact = 0;
rot = 0;
r = 0;
r2 = 0;
sh1 = 0;
sh2 = 0;
scl = 1;

function onEnterFrame()
{
    r = r + rotspeed1;
    for (var _loc1 = 0; _loc1 < slices; ++_loc1)
    {
        m.identity();
        m.b = m.b + sh1;
        m.c = m.c + sh2;
        m.rotate(r2);
        m.translate(2 * _xmouse / scl, 2 * _ymouse / scl + _loc1 * sclfact * 10);
        m.rotate(r);
        m.scale(scl, scl);
        slice.clear();
        slice.lineStyle();
        slice.moveTo(0, 0);
        slice.beginBitmapFill(stampImage, m);
        slice.lineTo(Math.cos(angle + nudge - 1.570796) * diag, Math.sin(angle + nudge - 1.570796) * diag);
        slice.lineTo(Math.cos(-(angle + nudge) - 1.570796) * diag, Math.sin(-(angle + nudge) - 1.570796) * diag);
        slice.lineTo(0, 0);
        slice.endFill();
        m.identity();
        if (flip && _loc1 &#37; 2 == 1)
        {
            m.scale(-1, 1);
        }
        m.rotate(rot + _loc1 * angle * 2);
        m.translate(hsize * 5.01, vsize * 5.01);
        map.draw(slice, m, null, "normal", null, true);
    } 
}

var angle = 3.141593 / slices;
var slice = createEmptyMovieClip("slice", 0);
slice._visible = false;
var diag = Math.sqrt(2 * hsize * hsize) * 6.21;
var map = new flash.display.BitmapData(hsize, vsize, true, 0);
var mapHolder = createEmptyMovieClip("mapHolder", 1);
mapHolder.attachBitmap(map, 0);
var image = flash.display.BitmapData.loadBitmap("image");
var stampImage = new flash.display.BitmapData(image.width, image.height, false);
stampImage.draw(image, new flash.geom.Matrix(5.01, 0, 0, 5.01, 0, 0), null, "normal", null, true);
stampImage.draw(image, new flash.geom.Matrix(-5.01, 0, 0, 5.01, image.width, 0), null, "normal", null, true);
stampImage.draw(image, new flash.geom.Matrix(5.01, 0, 0, -5.01, 0, image.height), null, "normal", null, true);
stampImage.draw(image, new flash.geom.Matrix(-5.01, 0, 0, -5.01, image.width, image.height), null, "normal", null, true);
image.dispose();
var m = new flash.geom.Matrix();

Key.addListener(this);
               

Last edited by nish; 01-20-2010 at 05:00 PM..
 
View Public Profile Send a private message to nish Find all posts by nish Add nish to Your Contacts
#2    
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Bradly, IL, USA
Posts: 943
Mood: MEAN
Old 01-19-2010, 06:41 AM Reply With Quote


nish:

Do you have a link to be viewed as to what this AS1 / AS2 script does?
It would help to see what is going on.

Wayne
               
__________________
The Hairy One
As Homer would say beer beer beer beer aaaaaahhhhhh beer.
Cycle's Roost
Action in Action
 
View Public Profile Send a private message to cycle1500 Visit cycle1500's homepage! Find all posts by cycle1500 Add cycle1500 to Your Contacts
#3    

Name: 
nish
Status: Offline
Rank: Registered User
Posts: 4
Old 01-20-2010, 11:49 AM Reply With Quote


Hi Wayne

Thanks for responding.

Here is a link to what it does. Judging by the swish scripts you have shared on this forum I think you are going to like it.

http://megaswf.com/view/820808d2b754...d09bc20e8.html

Big thanks to you for sharing your great swish scripts on here.
               
 
View Public Profile Send a private message to nish Find all posts by nish Add nish to Your Contacts
#4   kaleidoscope  
 
cycle1500's Avatar

Name: 
cycle1500
Status: Offline
Rank: Bradly, IL, USA
Posts: 943
Mood: MEAN
Old 02-03-2010, 01:02 PM Reply With Quote


I have tried to set up this the way it is scripted, but to no avail. The way swish compiles the finished product the scripting does not work as written.
I like the effect and as I get more time to play with it I will see what I can do to make a Swish file of this.
In the mean time give this a try:
Code:
  function onEnterFrame()
{
    var img = new flash.display.BitmapData(400, 400, true, 16777215);
    img.draw(this);
    this.attachBitmap(img, 3, 0, true);
    this.filters = [new flash.filters.BlurFilter(3, 3, 2)];
    p = Math.min(Math.abs(_xmouse - 200), 200) / 200;
    drawShape(this.shape, 200, 200, 200, 50, 3 + Math.min(Math.floor(p * 7), 7), t++);
}
function drawShape(mc, cx, cy, rmax, rmin, corners, rotation)
{
    mc.clear();
    mc.lineStyle(3, newRgb(t), 100, 0, 0, 0, 0, 0);
    mc.moveTo(cx + rmax * Math.abs(Math.sin(t / 20)) * Math.cos(Math.sin(t / 10)), cy + rmax * Math.sin(Math.sin(t / 10)) * Math.abs(Math.sin(t / 20)));
    for (var _loc1 = 0; _loc1 <= 6.283185E+000; _loc1 = _loc1 + 6.283185E+000 / corners)
    {
        mc.lineTo(cx + rmax * Math.abs(Math.sin(t / 20)) * Math.cos(_loc1 + Math.sin(t / 10)), cy + rmax * Math.sin(_loc1 + Math.sin(t / 10)) * Math.abs(Math.sin(t / 20)));
        mc.lineTo(cx + rmin * Math.abs(Math.sin(t / 50)) * Math.cos(_loc1 + 6.283185E+000 / corners / 2), cy + rmin * Math.sin(_loc1 + 6.283185E+000 / corners / 2) * Math.abs(Math.sin(t / 50)));
    } 
    mc.filters = [new flash.filters.GlowFilter(newRgb(t + 300), 100, 5, 5, 100)];
}
function newRgb(t)
{
    return (Math.floor(256 * Math.abs(Math.sin(t / 30)) << 16) + Math.floor(256 * Math.abs(Math.sin(t / 25)) << 8) + Math.floor(256 * Math.abs(Math.sin(t / 20))));
} 
onFrame (1) {
Stage.scaleMode = "noScale";
this.createEmptyMovieClip("shape", 10);
t = 1;
this.createEmptyMovieClip("shape", 10);
t = Math.floor(Math.random() * 100000);
}
a short but nice scripted kaleidoscope effect.

Wayne
               
__________________
The Hairy One
As Homer would say beer beer beer beer aaaaaahhhhhh beer.
Cycle's Roost
Action in Action
 
View Public Profile Send a private message to cycle1500 Visit cycle1500's homepage! Find all posts by cycle1500 Add cycle1500 to Your Contacts
#5    

Name: 
ross3201
Status: Offline
Rank: Registered User
Posts: 1
Old 02-03-2010, 04:39 PM Reply With Quote


I got a new knowledge here,thanks kaleidoscope
               
__________________
Very good reference about :
Step by step how to stop panic attacks naturally
Get all about the best of woodworking plan
 
View Public Profile Send a private message to ross3201 Visit ross3201's homepage! Find all posts by ross3201 Add ross3201 to Your Contacts
#6    

Name: 
nish
Status: Offline
Rank: Registered User
Posts: 4
Old 02-06-2010, 01:39 PM Reply With Quote


Hey Wayne, that's another good interact effect you've made there. I really like it!
Many thanks for having a go at converting that actionscript. Much appreciated
               
 
View Public Profile Send a private message to nish Find all posts by nish Add nish to Your Contacts
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump