Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › ::Needs actionScript 2.0 Help::
New Posts  All Forums:Forum Nav:

::Needs actionScript 2.0 Help::

post #1 of 6
Thread Starter 
hey guys,

I'm working on a website right now, and am not very experienced using flash/actionScript beyond a fairly shallow class i took in college.

I can't seem to get onRelease (or onRollOver, or onRollOut, or anything like that) to work with a movie clip i created through the createEmptyMovieClip method... it works just fine if i put a movie clip on the stage and affect it that way.

Any suggestions? I'm sure actionScript support such functionality... it would be stupid (read:what's the point) if it didnt
Jesus PC v5.3
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-950 Gigabyte X58A-UD3R 5850 GSkill 1600 MHz 4x4GB 
Hard DriveOptical DriveOSMonitor
3x1200.12 500GB RAID 0, 2x2TB Deskstar RAID 1 Samsung Writemaster SATA Gentoo, Windows 7 x64 3x 21.5" Samsungs 
PowerCaseMouse
Thermaltake 750W RocketPwn G500 
  hide details  
Reply
Jesus PC v5.3
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-950 Gigabyte X58A-UD3R 5850 GSkill 1600 MHz 4x4GB 
Hard DriveOptical DriveOSMonitor
3x1200.12 500GB RAID 0, 2x2TB Deskstar RAID 1 Samsung Writemaster SATA Gentoo, Windows 7 x64 3x 21.5" Samsungs 
PowerCaseMouse
Thermaltake 750W RocketPwn G500 
  hide details  
Reply
post #2 of 6
post your code, i can probably help you with that
BFG-c2d
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 BFG nForce 680i BFG 8800GTS 2gb pny ddr800 
Hard DriveOptical DriveOSMonitor
3x160gb seagate sataII memorex dvdrw GNU Linux Gentoo 2.6.19 Samsung 225BW 22" LCD 
PowerCase
BFG 650W Super LanBoy 
  hide details  
Reply
BFG-c2d
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 BFG nForce 680i BFG 8800GTS 2gb pny ddr800 
Hard DriveOptical DriveOSMonitor
3x160gb seagate sataII memorex dvdrw GNU Linux Gentoo 2.6.19 Samsung 225BW 22" LCD 
PowerCase
BFG 650W Super LanBoy 
  hide details  
Reply
post #3 of 6
Thread Starter 
Quote:
Originally Posted by theRemix View Post
post your code, i can probably help you with that
thanks a bunch!
Code:
var topGrown = false;
var bottomGrown = false;
import mx.transitions.Tween;
import mx.transitions.easing.*;

this.createEmptyMovieClip("topExpander", 17);
this.createEmptyMovieClip("bottomExpander", 16);
this.createEmptyMovieClip("mainPic", 15);

with(topExpander)
{
_x = 18;
_y = 65;
_xscale = 40;
_yscale = 40;
}

topExpander.loadMovie("newimages/bhTop1.jpg", topExpander);

//new Tween (topExpander, "_xscale", None.easeIn, 40, 100, 1, true);
//new Tween (topExpander, "_yscale", None.easeIn, 40, 100, 1, true);

//476, 314

/*
function expandTop()
{

topGrown != true;
new Tween (topExpander, "_xscale", None.easeIn, 40, 100, 1, true);
new Tween (topExpander, "_yscale", None.easeIn, 40, 100, 1, true);
};
*/

topExpander.onRelease = function()
{
if (bottomGrown != false)
{
shrinkBottom();
}
if (topGrown != true)
{
//expandTop();
topGrown = true;
new Tween (topExpander, "_xscale", None.easeIn, 40, 100, 1, true);
new Tween (topExpander, "_yscale", None.easeIn, 40, 100, 1, true);
}
}
you'll see i commented out a function declaration and call just to simplify things..
Jesus PC v5.3
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-950 Gigabyte X58A-UD3R 5850 GSkill 1600 MHz 4x4GB 
Hard DriveOptical DriveOSMonitor
3x1200.12 500GB RAID 0, 2x2TB Deskstar RAID 1 Samsung Writemaster SATA Gentoo, Windows 7 x64 3x 21.5" Samsungs 
PowerCaseMouse
Thermaltake 750W RocketPwn G500 
  hide details  
Reply
Jesus PC v5.3
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-950 Gigabyte X58A-UD3R 5850 GSkill 1600 MHz 4x4GB 
Hard DriveOptical DriveOSMonitor
3x1200.12 500GB RAID 0, 2x2TB Deskstar RAID 1 Samsung Writemaster SATA Gentoo, Windows 7 x64 3x 21.5" Samsungs 
PowerCaseMouse
Thermaltake 750W RocketPwn G500 
  hide details  
Reply
post #4 of 6
ok your problem is that you cannot add listeners to topExpander right?

and you probably can set it's x and y properties, but can't set it's width and height or set events.

this is because of how loadMovie works, your image will load, but before it's done loading (however fast that may be), your script starts giving it properties and events before it even has any properties.

you have to "wait" for it to complete loading before using it. and actionscript 2.0 gave us the MovieClipLoader class for this reason.

http://livedocs.adobe.com/flash/8/ma...=00002538.html

i edited your code to use the MovieClipLoader class. you'll notice that i put the onRelease handler inside of the onLoadInit listener, this means that the code inside will run after topExpander is 'loaded' and initialized (has properties). You'll also notice that inside of the onLoadInit event handler, the target object (that we are listening to, waiting to finish loading, topExpander) is called target_mc.

Code:
var topGrown = false;
var bottomGrown = false;
var mcLoader:MovieClipLoader = new MovieClipLoader();
var mcListener:Object = new Object;

import mx.transitions.Tween;
import mx.transitions.easing.*;

this.createEmptyMovieClip("topExpander", 17);
this.createEmptyMovieClip("bottomExpander", 16);
this.createEmptyMovieClip("mainPic", 15);

with(topExpander)
{
_x = 18;
_y = 65;
_xscale = 40;
_yscale = 40;
}

mcListener.onLoadInit = function(target_mc:MovieClip):Void{
//target_mc is topExpander
target_mc.onRelease = function()
{
if (bottomGrown != false)
{
shrinkBottom();
}
if (topGrown != true)
{
//expandTop();
topGrown = true;
new Tween (this, "_xscale", None.easeIn, 40, 100, 1, true);
new Tween (this, "_yscale", None.easeIn, 40, 100, 1, true);
}
}
}

mcLoader.addListener(mcListener);
mcLoader.loadClip("newimages/bhTop1.jpg", topExpander);
untested code

now you'll also notice that the shrinkBottom() function will not run, this is because of scope. shrinkBottom() is not accessible from inside that listener.

you may be able to figure out how to refactor the code so that it does work, or change the scope of the event handler. (hint: use AS2's Delegate class - http://www.actionscript.org/resource...ass/Page1.html )

that should give you enough to read up on.

hope this helps.
BFG-c2d
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 BFG nForce 680i BFG 8800GTS 2gb pny ddr800 
Hard DriveOptical DriveOSMonitor
3x160gb seagate sataII memorex dvdrw GNU Linux Gentoo 2.6.19 Samsung 225BW 22" LCD 
PowerCase
BFG 650W Super LanBoy 
  hide details  
Reply
BFG-c2d
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 BFG nForce 680i BFG 8800GTS 2gb pny ddr800 
Hard DriveOptical DriveOSMonitor
3x160gb seagate sataII memorex dvdrw GNU Linux Gentoo 2.6.19 Samsung 225BW 22" LCD 
PowerCase
BFG 650W Super LanBoy 
  hide details  
Reply
post #5 of 6
Thread Starter 
hey thanks much Remix that surely did it! (once I was able I realized typing mcListener.addListener made no sense =P That just saved me big time..

+rep to you
congrats on your first flame!
Jesus PC v5.3
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-950 Gigabyte X58A-UD3R 5850 GSkill 1600 MHz 4x4GB 
Hard DriveOptical DriveOSMonitor
3x1200.12 500GB RAID 0, 2x2TB Deskstar RAID 1 Samsung Writemaster SATA Gentoo, Windows 7 x64 3x 21.5" Samsungs 
PowerCaseMouse
Thermaltake 750W RocketPwn G500 
  hide details  
Reply
Jesus PC v5.3
(13 items)
 
  
CPUMotherboardGraphicsRAM
i7-950 Gigabyte X58A-UD3R 5850 GSkill 1600 MHz 4x4GB 
Hard DriveOptical DriveOSMonitor
3x1200.12 500GB RAID 0, 2x2TB Deskstar RAID 1 Samsung Writemaster SATA Gentoo, Windows 7 x64 3x 21.5" Samsungs 
PowerCaseMouse
Thermaltake 750W RocketPwn G500 
  hide details  
Reply
post #6 of 6
Quote:
Originally Posted by FearMeansControl View Post
hey thanks much Remix that surely did it! (once I was able I realized typing mcListener.addListener made no sense =P That just saved me big time..

+rep to you
congrats on your first flame!
happy to help
BFG-c2d
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 BFG nForce 680i BFG 8800GTS 2gb pny ddr800 
Hard DriveOptical DriveOSMonitor
3x160gb seagate sataII memorex dvdrw GNU Linux Gentoo 2.6.19 Samsung 225BW 22" LCD 
PowerCase
BFG 650W Super LanBoy 
  hide details  
Reply
BFG-c2d
(13 items)
 
  
CPUMotherboardGraphicsRAM
E6600 BFG nForce 680i BFG 8800GTS 2gb pny ddr800 
Hard DriveOptical DriveOSMonitor
3x160gb seagate sataII memorex dvdrw GNU Linux Gentoo 2.6.19 Samsung 225BW 22" LCD 
PowerCase
BFG 650W Super LanBoy 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › ::Needs actionScript 2.0 Help::