Has Anybody Found A Way To Detect And React To Scaling Problems With The Drawing API?
In the link below, I have drawn a simple arrow, then scaled it up using OEF. The scale isn't a problem, but once the width / height get bigger than somewhere areound 8000, the drawing goes pear-shaped.
http://www.gdcsoft.com/sp_t/CHECK%20...%20ISSUES.html
I have an idea for a work-around, but before I get stuck into something quite laborious and dull, I was wondering if anyone else had encountered this and found a way around it?
FlashKit > Flash Help > Flash ActionScript
Posted on: 08-04-2005, 12:33 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
MC Detect Window Size And React
Hello!
So besides having one of the coolest flash sites Ive ever seen and the best artwork, this site also does something I must learn how to do. It adjusts it's MC positions in relation to the objects around it AND the browser window size. You can see that it's size is set to 100% x100%, the background is static while the elements react. I love it.
http://www.cmart.design.ru/
Its so cool.
Anyone know how this is done and can provide some insight for me by way of tutorial or example AS?
cheers
Basic Drawing And Scaling
Ive drawn up a character in flash whom is made up of shapes and -Lines- (( Lets say for example the charater uses a size 8 line for his or her arm or some part of them )) Now when i scale the charater to make it bigger the line stays portioned to how long it needs to be but not as thick >.< How do i fix this? Should i convert all my lines to symbols?
Overall: When i scale a line it stays the corret length and placement but the line thins out, help!!
Scaling The Drawing Lineto
Hi,
I have a whole bunch of values in an array that I want to plot on a graph using the lineTo.
The values in the array are very large and the stage is not big enough for them.
Could anyone suggest a way to scale the values to the size of the stage?
ActionScript Code:
for (var p:int=0; p<l_pcm.length; p++) {
var plot=l_pcm[p]/1000;
graph.graphics.lineTo(p,l_pcm[p]);
}
addChild(graph);
EDIT
Please use [ as ] [ /as] tags for code (without spaces)
Thanks,
dub
Drawing Objects And Scaling
Hello everyone,
I have a vector drawing object inside a parent movieclip. The drawing object is acting as a semi-transparent frame for and image on another layer. the problem is when I scale the parent movieclip the thickness of the drawing object is changing. I know that you can turn off scaling for lines and rectangles, but is there a way to do the equivalent for a vector drawing object?
Thanks for any help,
Wade
Detect Drawing Line Overlap
I need to develop an application where user can draw on the screen using the mouse (this I could do). I also need to track when the lines cross each other. Any help on this please....
Drawing An Image Centrally Whilst Rotating And Scaling
Hi everyone,
This is my first post here; just trying to make the awkward transition from J2ME and C++ to AS 3.0! Things aren't going too badly so far, but I've stumbled across a problem with drawing a rotated image centrally whilst scaling it. I found that you can draw an image centrally by doing this:
target.x = -(width >> 1);
target.y = -(height >> 1);
...but if I scale and rotate the image then it doesn't get draw centred around target_x, target_y. I'm guessing this is where I'm going wrong:
target.x = target_x - (target.width >> 1);
target.y = target_y - (target.height >> 1);
I've copied and pasted the entire code below - any advice would be great, thanks for your time!
Cheers,
Mike.
/////////////////////////////////////////////////
package
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.Stage;
public class Target extends Sprite
{
private var target:Bitmap;
private var target_x:Number;
private var target_y:Number;
[ Embed ( source = "target.png" ) ] private var targetGFXClass:Class;
public function Target ( )
{
// instantiate embedded assets
target = new targetGFXClass( );
target.scaleX = 0.0;
target.scaleY = 0.0;
// attach target to display list
addChild( target );
}
// initialization, called after parent addChild
public function init ( ):void
{
target_x = Math.random() * stage.stageWidth;
target_y = Math.random() * stage.stageHeight;
// start step triggering based on enterframe event
addEventListener( Event.ENTER_FRAME , step );
}
public function step ( event:Event ):void
{
if (target.scaleX < 1)
{
target.scaleX += 0.1;
target.scaleY += 0.1;
}
else
{
target.rotation++;
}
x = target_x - (target.width >> 1);
y = target_y - (target.height >> 1);
}
}
}
React To Cursor?
I have some snowflakes falling in my main movie. what i REALLY want to do is have them SLIGHTY react to the mouse cursor. i just want them to slighty drag in it's direction. how would i do this? is there one way thats easier then another? or is there just one way it can be done?
i've look all over for tuts. but to no avail. can someone help?
On Press No React?
Here's my code:
Code:
On(press) {
_root.score += 50;
gotoAndPlay (2);
}
but everytime I test it, it doesn't add 50 to the score and doesn't play the 2nd frame.
any solution?
sorry for my bad english
thanks in advance
MC React To Distance
I've had a long look and simply couldn't find any help for what it is I'm trying to do.
I want it so that when a movie clip is dragged to a new location, the distance from the MC and another MC is calculated. And when the distance has reached a certain amount (200+ pixels for example) it will react (go to a new frame).
I've attached a partial, any help or guidance would be really appreciated.
Thanks
Only React To Low Frequencies
Code:
// SpectrumAnalyzer.as
package {
import flash.display.*;
import flash.media.*;
import flash.net.*;
import flash.utils.ByteArray;
import flash.events.*;
class SpectrumAnalyzer extends Sprite {
// Settings
private var lineThickness:Number = 2;
private var lineColor:Number = 0x993300;
private var circleSize:Number = 75;
private var scaleOnBeat:Number = 1.1; // 120%
private var reactToBeat:Number = 30;
//
private var music:Sound = new Sound;
private var ba:ByteArray = new ByteArray();
private var __width:uint;
private var __height:uint;
function SpectrumAnalyzer(mp3:String, _width:uint, _height:uint) {
__width = _width;
__height = _height;
x = __width/2;
y = __height/2
music.load(new URLRequest(mp3));
music.play(0, 999);
addEventListener(Event.ENTER_FRAME, processSound);
}
private function processSound(ev:Event):void {
SoundMixer.computeSpectrum(ba, true, 0);
graphics.clear();
graphics.moveTo(0, -circleSize);
graphics.lineStyle(lineThickness, lineColor);
var vol:Number = 0;
for (var i:uint = 0; i <512; i++) {
var lev:Number = ba.readFloat();
vol += lev;
var a:uint = i;
var j:Number = i;
if (i <256) a += 256;
if (i == 256) graphics.moveTo(0, -circleSize);
graphics.lineTo(-Math.sin(i/256*Math.PI)*circleSize*(lev+1), Math.cos(a/256*Math.PI)*circleSize*(lev+1));
}
if (vol> reactToBeat) {
scaleX = scaleY = scaleOnBeat;
}
else {
scaleX = scaleY = 1;
}
}
}
}
I am thinking that
Code:
private var reactToBeat:Number = 30;
is completely dependant on song.mp3. If the song was processed at a different volume level, then you may need to lower the value. (e.g. 30 would be lowered to 19)
I ultimately want to have this work with any song, because I will be making a playlist and have song.mp3 replaced with the var.
To start, however, I would at least like to get this spectrum to only respond to low frequencies.
I think for start, I would need to change:
Code:
SoundMixer.computeSpectrum(ba, true, 0);
to
Code:
SoundMixer.computeSpectrum(ba, false, 0);
so that it reads it as a frenquency spectrum rather than a complete wav file (according to the as3 ref doc)
With that, the first 256 values should be low freqs and 257 to 512 would be high freqs.
How can I utilize that to only scaleOnBeat to the low frequencies?
Also, I didn't know if it was best to use a select case for a certain range of values.
Thanks
React To Array Rather Than Mouse?
Hi All,
I have a question here that I just can't get my head around.
I have a file that contains code that reacts to mouse position/movement.
Is it possible to tell the lines to react to arrays from a text document instead?
Does anyone understand how this could implemented?
The arrays are generated through flashamp and this is the current lines code:
Code:
stop();
p = new Array();
count = 0;
p[count] = {x:_xmouse, y:_ymouse, w:0, col:0};
count++;
rand = Math.random;
sin = Math.sin;
r = 255; //rand() * 128 + 127;
g = 127; //rand() * 128 + 127;
b = 0; //rand() * 128 + 127;
w = 0;
ri = 0.02; //rand() * 0.05;
gi = 0.015; //rand() * 0.05;
bi = 0.025; //rand() * 0.05;
this.onEnterFrame = function() {
vx = _xmouse - oldx + rand() * 2 - 1;
vy = _ymouse - oldy + rand() * 2 - 1;
oldx = _xmouse;
oldy = _ymouse;
p[count] = { x:_xmouse, y:_ymouse, vx:vx * 0.5, vy:vy * 0.5, w:(sin(w += 0.2)*5 + 5),
col:(sin(r += ri) * 128 + 127) << 16 | (sin(g += gi) * 128 + 127) << 8 | (sin(b += bi) * 128 + 127) };
count++;
clear();
moveTo(_xmouse, _ymouse);
for (var i in p) {
lineStyle(p[i].w, p[i].col);
p[i].x += p[i].vx;
p[i].y += p[i].vy;
if (p[i].y > 380) {
p[i].y = 380;
p[i].vy *= -0.5;
p[i].vx *= .95;
}
if (i) curveTo(p[i].x, p[i].y, (Number(p[i].x) + Number(p[i-1].x))/2, (Number(p[i].y) + Number(p[i-1].y))/2);
if (p.length > 50) {
p.splice(0, 1);
count--;
}
}
};
Be grateful for any suggestions and advice or pointers please
D
[F8] Actionscript To React To Dropzones
I am trying to create a Flash game but I'm stuck. I have six movieclips in my game, each showing a image (spectacles, beard, etc). I need to have two dropzones. The user should be able to drop any of the 6 pictures into a drop zone and when one picture occupies each of the two drop zones a picture should appear in a area to the side.
For example, if the user drops 'spectacles' in dropzone 1 and 'beard' in dropzone 2 the game should then display a picture of a person with spectacles and a beard. I've calculated how many pictures I need to draw for every conceivable combination, but the actionscript for the game is beyond me. Can anyone suggest what needs to be written, or point me towards a tutorial which does something like this?
Thanks!!
Let Objects React On DragOver
Hi, I've made a little game, where people have to drop objects in specific places. To make my app a bit more user-friendly I would like a kind of alt-text to appear when users drag over a target.
I figured out how the droptarget property functions. is there something like a "dragOverTarget" property, or any other way to show a clip when the users drags an object over another?
Hope I make myself clear. Many thanks in advance to readers and repliers!
Geert
Making An MC React Like A Button
Hi everybody,
Can anybody help me out with a tiny and probably very easy piece of code?
I'd like a mc to react like a button, so that when the mouse roles out of the mc area, an event happens.
Pseudo Code:
_root.my_mc.onrollout.
_root.gotoAndPlay (start)
Can anybody tell me the code please - I'm tearing my hair out here.
Thanks alot
Deadhands
Allow Button In Flash Does Not React
Hi Everybody,
here is a problem I cannot solve right now, perhaps you can help us... on this page the "Allow" Button cannot be pressed, they don't react anyhow.
http://www.bloomstreet.net/pauke
I am glad for every idea....
Thanks & kind regards,
Henning
Making Two Different Movies React
Hello Dudes and Dudettes,
Does anyone know how to make
two different movies react on the same
HTML page?
For example... I have a movie in
the center of my html page. Once
this movie ends, I want it to start
an other movie that is in my header.
Any ideas?
Thanks! And sorry for my poor english
Neuhaus3000
..problems With A React On The Hour Script
I am creating a variation of a clock, that doesn't tell the time but reacts to the changes in hour and displays a message depending on what hour of the day it is. They only problem being that this code doesn't work and i don't see why. The text box in the movie pics up the text but it only displays the first variable for before 3 in the morning?! I really need some help with this one so if there is a supastar :guitar: out there please give it a go.
The code is below
Code:
onClipEvent (enterFrame) {
now = timedate.getHours();
if (now.getHours()<3) {
this.exp = "...so what are you doing up so late?";
} else if (now.getHours()<7) {
this.exp = "Well, well, well are we you trying to get a raise or what...!!!!";
} else if (now.getHours()<11) {
this.exp = "Welcome back to another glorious day at work!";
} else if (now.getHours()<13) {
this.exp = "I think you should run quickly to the canteen before all the good stuffs gone.";
} else if (now.getHours()<14) {
this.exp = "Most of the good food's gone I'm afraid.";
} else if (now.getHours()<16) {
this.exp = "You only have to last a few more hours!";
} else if (now.getHours()<17) {
this.exp = "It's almost home time!";
} else if (now.getHours()<19) {
this.exp = "Anyone staying past five must be truly devoted to their job.";
} else if (now.getHours()<21) {
this.exp = "I think you should all go home to your families now.";
} else {
this.exp = "Go home, get some sleep.";
}
}
Having The Main Movie React To A Swf Being Loaded...
On the main movie there is a menu that I want to trasform after the viewer selects an option. The menu should transform into a 'now loding' image and text until the other swf being loaded into an empty movieclip After the second file finishes its loading, the menu transforms from a loading screen into a new menu with text buttons only... Heh...Get the idea?
Scrollbar Doesn't React To Textbox
Hi Guys!
i have a strange problem here which drives me absolutely nuts and stalls all my work progress at the moment...
in my movie the Scrollbar component just won't react to the according textbox. it just stays there where i put it, doesn't dock in or actually scroll text.
it works fine everwhere else, just NOT in this particular movie!
i've tried everything and am getting quite desperate. did anyone encouter similar problems before? what could be the reason for this strange behaviour?
i would be glad for any kind of help! if you want so check it out, you can find my movie here:
http://www.steinmannbob.ch/GuestBook/GuestBook.fla
(it's supposed to be for this site:
http://www.steinmannbob.ch)
Can Movieclips React To Sound Files In Mx
Hi all
I was speaking to a friend today and he suggested to me that flash mx has capabilities of making movie clips react to sound files contained within them.
Kinda like when you have your media player runs and makes those colourful patterns which are influenced somewhat by the music files themselves as in the way of the musics beats and sound intensity.
Firstly is he having a lend of me and if not is there any tutorials of how to do this and what would i search under, does flash mx have any tutorials itself.
Cheers Pixelmagik
Getting A Button To React With Dynamic Text
Hi!
This has got me stumped - I bet it's easy to sort but I'm pretty new and clueless to this flash lark!
I want to press the button in my clip and the card to move up the screen and the number three to appear on it and travel with the card (bit like a rising playing card!)
The idea being to have 9 different buttons and when you press one of the buttons a different number appears on the card.......thought I'd try and do it with one number to start with BUT I CAN'T WORK IT OUT!
Help please!!
I'm using flash mx professional 2004
How To Make One MC React To Another's Change In Size?
So I have two movieclips. They are both rectangles, with one in front (smaller) and the larger in back (basically it's 6 pixels larger on all sides). I'm using some easing functions to resize the smaller rectangle MC when a button is pressed.
What I want to happen is I want the larger rectangle MC to always be 6 pixels larger on all sides (so 12px greater in height and in width) no matter what the size of the smaller rectangle MC.
How can I make this larger rectangle automatically react to changes in size of the smaller rectangle so that it always stays exactly proportional??
I thought about setting up some kind of onEnterFrame function where the larger rectangle MC is constantly monitoring the smaller rectangle's size but there has to be a better way.
Help!
Button Rollover Slow To React
I have a program made in Flash 8 that when up and running the 2 main buttons are real slow to react to a rollover. There's nothing fancy with these 2 buttons, each has three layers.
But I also have 16 other buttons that are active in another part of the screen that react to rollover just fine, they have this kind of code:
btn_c1.onRelease = function() {
if (Blank1 != 1) {
loadMovie("OrgansC1.swf", "mc_OrganMan");
loadMovie("NervesC1.swf", "mc_NerveBlank");
_level0.states.gotoAndStop(2);
loadMovie("C1.swf", "mc_Blank1");
_global.Blank1 = "1";
} else {
loadmovie("VertRolls.swf","mc_Blank1");
_global.Blank1 = "0";
}
My question is how can I get the other 2 simple buttons to react to rollover quicker?
thanks
How Do I Get A Movieclip To React To The Mouse Within A Certain Area?
Hi, I would like to have a movieclip follow the mouse, but only when the cursor comes within a certain radius of the movieclip, and when it does it will follow it, but when it leaves the radius the movieclip will bounce back to it's original position.
If anyone can help that would be great.
Fade Functions - Sometimes React Slowly
I wrote these functions to fade 3 movieClips in and out. There are three buttons- 1, 2, and 3, and each fade in and out their relative movieclip.
The problem is that when I click through the buttons, sometimes one might fade in, but one of the others doesn't fade out. Or sometimes the one that is supposed to fade out does, but it is delayed.
Here are my functions:
Code:
function fadeIn(x){
if (x._alpha < 100) {
x.onEnterFrame = function() {
x._alpha += 10;
};
} else {
delete x.onEnterFrame;
}
}
function fadeOut(z){
if (z._alpha > 50) {
z.onEnterFrame = function() {
z._alpha -= 10;
};
} else {
delete z.onEnterFrame;
}
}
Here are my button actions:
Code:
Button1:
on (release) {
_root.content.fadeIn(_root.content.content_group1);
_root.content.fadeOut(_root.content.content_group2);
_root.content.fadeOut(_root.content.content_group3);
}
Buttons 2 & 3 have similar code.
Any ideas?
Fade Functions - Sometimes React Slowly
I wrote these functions to fade 3 movieClips in and out. There are three buttons- 1, 2, and 3, and each fade in and out their relative movieclip.
The problem is that when I click through the buttons, sometimes one might fade in, but one of the others doesn't fade out. Or sometimes the one that is supposed to fade out does, but it is delayed.
Here are my functions:
Code:
function fadeIn(x){
if (x._alpha < 100) {
x.onEnterFrame = function() {
x._alpha += 10;
};
} else {
delete x.onEnterFrame;
}
}
function fadeOut(z){
if (z._alpha > 50) {
z.onEnterFrame = function() {
z._alpha -= 10;
};
} else {
delete z.onEnterFrame;
}
}
Here are my button actions:
Code:
Button1:
on (release) {
_root.content.fadeIn(_root.content.content_group1);
_root.content.fadeOut(_root.content.content_group2);
_root.content.fadeOut(_root.content.content_group3);
}
Buttons 2 & 3 have similar code.
Any ideas?
Have Only A Specific Listener React To OnMouseDown
Last edited by noonelasts : 2003-05-31 at 14:42.
How can I have only a specific listener react to an onMouseDown event? I have several listeners (MCs), and I have done this
Code:
function doSomething() {
trace(this);
};
MovieClip.prototype.stuff=function() {
this.onMouseDown=doSomething;
};
When it traces, it lists all the MCs that I have touched (given focus to?), instead of just the one. I've tried with delete this.onMouseDown (in front of and just after this.onMouseDown, and in the doSomething function), but it doesn't work.
Any help appreciated.
(Edit: I, the recipe for stupid, just discovered onPress. I'll leave this post in case someone wants to answer it for the benefit of others. I don't know whether it's a relevant question or not anymore. )
Make Flash React On Multiple Keys At Once
hi,
how can i make my flash-movie react on multiple keys pressed at the same time. like move an object up and right with the keys <up> and <right> pressed at the same time? any ideas?
bye, stevie.
Make Other Movies React To Mouse Hits
teke a look at thia
www.hellborn.com
you can slap the robor around but it doesnt seem right that the buttons around it are still so iv been trying to find ways i can make the buttons move sorta reacting in a way to the speed you hit the robot at.
this is a big ask but can anione help me please.
thanx in advanced
Loaded Movie Does Not React To Mouse Actions
I have loaded a SWF into a movie clip but I does not function (the objects inside the loaded movie does not react to mouse actions or buttons do not respond to mouse actions...anybody with comments or solutions..will be higly appreciated..THX to ALL for reading
[F8] Drag And Drop - Make Hotspots React?
I've got a drag and drop interaction where I want the target area(s) to highlight (change _alpha from 40 to 15) when the user drags the selection over it and to fade back to 15 when they drag out, but I can't get the hotspot to react to anything. I've tried putting in invisible buttons in, assigning the action to the movie clip instances and to the drag object, but no luck...
See the attached file...right now I'm forcing the target to drop into the first area on release, but I'll get to that next...
Any ideas on how I can do the highlight areas??
Here's the code, if that helps:
Code:
var droppedIn = false;
drag_mc.onRelease = function() {
trace("this._droptarget "+this._droptarget);
this._x = 106;
this._y = 200;
droppedIn = true;
this.gotoAndStop(4);
stopDrag();
};
drag_mc.onPress = function() {
startDrag(this, true);
};
drag_mc.onRollOut = function() {
chart_mc.hit1._alpha = 15;
if (droppedIn == false) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(3);
}
};
drag_mc.onRollOver = function() {
if (droppedIn == false) {
this.gotoAndStop(2);
} else {
this.gotoAndStop(4);
}
};
drag_mc.onDragOver = function(){
trace("drag_mc.onDragOver "+this._droptarget);
if (this._droptarget == " /chart_mc/hit1") {
chart_mc.hit1._alpha = 60;
}
}
drag_mc.onDragOut = function(){
trace("drag_mc.onDragOut "+this._droptarget);
chart_mc.hit1._alpha = 15;
}
stop();
Thanks!!
Making Swfs Only React To The Mouse In A Certain Area
I'm making a site which is going to have various toy type things on it such as elastic lettering, things following the mouse etc.
These toys are going to be all inside individual banners which will be loaded externally from a collection of swfs.
I would normally just do this and put together the site in dreamweaver. however the client wants to have things such as a light which when switched puts the site into darkness and turns the cursor into a torch etc.
I don't know enough about html to do this so i was wondering how to keep the individual banners from only reacting to the mouse when they're inside the banner
Button Inside Movie Won't React To RollOver
Hi there,
I am developing a sort of panorama movie where the image scrolls around. That is working but when I try to set some hotspots on it by adding buttons in the movieClip I can't get them to react to rollOver action since (onRelease and onPress) it is already used by the main movieClip.
Any idea on a work around?
I have been reading for 4 hours and can't find a good solution.
My Buttons Don't React Based On Variable Values
Can anyone help me with the following AS code? My question is toward the end of this thread.
I have a movie clip mcBox1 for which I create an instance, mc_box1, on the stage (main timeline) with a click of a button, btn_openMcBox1 using the following code:
// Main timeline.
btn_openMcBox1.onRelease = function():Void
{
myMcBox1Tween();
}
mc_box1 contains an exit button, btn_Exit1, that removes mc_box1 from the stage (main timeline) once it finishes its exit tween. I use the following code to accomplish this:
// mc_box1 timeline.
btn_Exit1.onRelease = function():Void
{
_root.myMcBox1Tween.yoyo();
}
// Main timeline.
myMcBox1Tween.onMotionFinished = function():Void
{
removeMovieClip(mc_box1);
}
mcBox2 is another movie clip for which I create an instance, mc_box2, on the stage (main timeline) with a click of another button, btn_openMcBox2, using similar code as I used above. mc_box2 also has an exit button, btn_Exit2, that removes mc_box2 from the stage (main timeline) after it finished its exit tween.
I want the exit button, btn_Exit1, in mc_box1 to be disabled when mc_box2 is on the stage because mc_box2 overlaps mc_box1 and hides its exit button, and I want this exit button to be enabled when mc_box2 is removed from the stage.
I’m using vars, box1Open and box2Open. Here’s a part of my code that checks the variables (main timeline) and based on their value either enables or disables btn_Exit1 in mc_box1.
// Main timeline.
var box1Open:Boolean = false
var box2Open:Boolean = false
enableExtBtn1 = function():Void
{
if(box1Open == true && box2Open == false)
{
mc_box1.btn_Exit1.enabled = true;
}
}
disableExtBtn1 = function():Void
{
if(box1Open == true && box2Open == true)
{
mc_box1.btn_Exit1.enabled = false;
}
}
I run the enableExtBtn1 and disableExtBtn1 functions onRelease of btn_openMcBox1 and btn_openMcBox2 (main timeline) which place mc_box1 and mc_box2 on the stage. I also run the disableExtBtn1 function from mc_box2 timeline onRelease of btn_Exit2 located in mc_box2 using the following code:
// mc_box2 timeline.
btn_Exit2.onRelease = function():Void
{
_root.disableExtBtn1();
}
I’ve created trace() functions that tell me the value of my variables when my movieclips are on/off the stage and they work properly. The code above works only the first time I click either the button that places mc_box1 on stage or the button that places mc_box2 on stage. Once I click btn_Exit2 and remove mc_box2 off the stage, btn_Exit1 in mc_box1 is still disabled, but the variable values change as they should.
What do you think? Where are my errors?
Thanks in advance for your time; I really appreciate it!!
Movie Clip States - Buttons That React
I need to make a button which turns (and stays) another color after it's been used. I've been told that this can be done with movie clip states.. but I'm somewhat confused as to how EXACTLY do it.
Individual Cells React To Mouse Events?
Hello,
I was wondering if it's at all possible to someone have the dataGrid cells individually react to a mouse event. From what it looks like, you can click on the cells and they react in some simple fashion... i want to be able to click on a cell and have it react like a button... i would appreciate anyone's help, as i always do!
Sincerely,
Devin
Dynamically Generated Clips Won't React To Mouseevents...
When dynamically generating movieclips, how can you add a
myMovieClip.onRelease = function () {
what needs to be done comes here ...
};
Here's my code
for(i=1;i<=_root.artcounter;i++){
content.duplicateMovieClip("content"+i,i*1000);
this["content"+i].id = i;
if(i == 1){
this["content"+i]._y = 22;
this["content"+i]._x = 0;
}
this["content"+i].loadMovie(i+".jpg");
this["content"+i]._height = 10;
this["content"+i]._y = this["content"+(i-1)]._y+this["content"+(i-1)]._height;
}
It generates movieclips by duplicating a clip, loads a jpg into every generated clip and then places them in an _y position. But now I need to press them like they are buttons, and that won't work...
Anyone ?
thanks
Making Movie Clips React To Collision
I am trying to get the effect of a snooker pack being broken up with a cue ball for my website, is there a way using action script i can achieve this. Also, is it possible to use a SWF as a background in Dreamweaver?
Movie Clip States - Buttons That React
I need to make a button which turns (and stays) another color after it's been used. I've been told that this can be done with movie clip states.. but I'm somewhat confused as to how EXACTLY do it.
Individual Cells React To Mouse Events?
Hello,
I was wondering if it's at all possible to someone have the dataGrid cells individually react to a mouse event. From what it looks like, you can click on the cells and they react in some simple fashion... i want to be able to click on a cell and have it react like a button... i would appreciate anyone's help, as i always do!
Sincerely,
Devin
Make My Button On My Draggable Movieclip React?
hi everybody.
i'm doing a rent-a-shop-application for at Development Company in Sweden.
but now, that i'm almost done, I've run into a problem:
check it out here:
http://www.kunde.artproduction.dk/test/TKD/TKD01.html
to understand the problem please:
1) press the button in the upper-left corner called 'Heminredning'
2) the bottom left building now gets the same color as the 'Heminredning'-button.
press this building
3) now the different shops for rent are shown for that level
press one of those, that are colored like the 'Heminredning*-button
4) a small infobox-movieclip appears. this infobox-movieclip is draggable.
on this infobox is a button 'Se kort'
this button was supposed to open a pop-up-window
but this button doesn't react!
i've placed the same button on the bottom part of the solution (on the root timeline), and here it opens up a new window easily.
how do I make the button at the draggable movieclip react?
thanks in advance
felisan
How To Modify This Menu To React To Mouse Position?
I am trying to modify a fla i got from flash den.
http://flashden.net/item/xml-driven-...oom-menu/21047
It works by clicking on menu items, and or using your mouse wheel.
I am trying to make it so that it responds to mouse movement. So if you mouse up, the menu moves up, and if you mouse down, it moves down.
The file populates the menu using xml, and below is the primary code that makes it work.
Every mouseposition functionality that I've worked on required that the content be in an MC, but this is all xml generated content, and I don't know how to target or control it.
Any help would be appreciated.
package net.flashden.lydian {
import fl.transitions.Tween;
import fl.transitions.easing.Strong;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
public class VerticalMenu extends MovieClip {
// The configuration manager which holds some constants
private var configManager:ConfigManager = new ConfigManager();
// An XMLLoader instance to load xml file to the memory
private var dataXMLLoader:XMLLoader;
// The xml data
private var xml:XML;
// An array to hold menu items
private var items:Array = new Array();
// The container for adding menu items
private var container:Sprite = new Sprite();
// The index number of the current selected item
private var selectedIndex:int = -1;
// A tween to be used to move the container.
private var moveTween:Tween;
// A mask for the entire menu
private var menuMask:Sprite = new Sprite();
// The factor to be used while zooming
private var zoomFactor:Number;
public function VerticalMenu() {
// Initialize the object
init();
}
/**
* Initializes the menu
*/
private function init():void {
// Start reading the configuration file
configManager.addEventListener(ConfigManager.CONFIG_LOADED, onConfigLoaded);
configManager.load();
}
/**
* This method is called when the configuration file is loaded.
*/
private function onConfigLoaded(evt:Event):void {
zoomFactor = ConfigManager.ZOOM_FACTOR;
// Create the menu mask if it's enabled
if (ConfigManager.ENABLE_MENU_MASK) {
menuMask.graphics.beginFill(0, 0);
menuMask.graphics.drawRect(-200, -105, 500, 410);
menuMask.graphics.endFill();
container.mask = menuMask;
addChild(menuMask);
}
if (ConfigManager.DISPLAY_ARROW) {
// Create an arrow and locate at the selected menu location
var arrow:Arrow = new Arrow();
arrow.x = ConfigManager.ARROW_SPACE;
arrow.y = ConfigManager.SELECTED_ITEM_LOCATION;
addChild(arrow);
}
// After reading the configuration file, start reading the data xml
dataXMLLoader = new XMLLoader(ConfigManager.DATA_XML_URL);
dataXMLLoader.addEventListener(XMLLoader.XML_LOADED, onDataXMLLoaded);
}
/**
* This method is called when the data.xml is loaded.
*/
private function onDataXMLLoaded(evt:Event):void {
// Get the xml data
xml = dataXMLLoader.getXML();
var index:int = 0;
// Create the menu items from the xml data
for each (var item:XML in xml.item) {
var url:String = item.url;
var title:String = item.title;
var subtitle:String = item.subtitle;
var targetFrame:String = item.target_frame;
var menuItem:MenuItem = new MenuItem(url, title, subtitle, targetFrame, index);
items.push(menuItem);
++index;
}
// Get the first menu item
menuItem = items[0];
menuItem.scaleX = zoomFactor;
menuItem.scaleY = zoomFactor;
container.addChild(menuItem);
// Add each menu item to the container
for (var i:uint = 1; i < items.length; i++) {
menuItem = items[i];
menuItem.scaleX = zoomFactor;
menuItem.scaleY = zoomFactor;
menuItem.y = items[i - 1].y + items[i - 1].normHeight + ConfigManager.MENU_SPACE;
menuItem.alpha = .4;
container.addChild(menuItem);
}
// Draw a transparent background to catch mouse events on spaces
container.graphics.beginFill(0xFFFFFF, 0);
container.graphics.drawRect(0, 0, container.width, container.height);
container.graphics.endFill();
// Create the move tween
moveTween = new Tween(container, "y", Strong.easeOut, container.x, container.x, 1, true);
moveTween.stop();
// Add event listeners
addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel, false, 0, true);
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown, false, 0, true);
addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown, false, 0, true);
// Add the container to the menu
addChild(container);
// Select the first menu item
var firstItem:MenuItem = items[0];
firstItem.scaleX = 1;
firstItem.scaleY = 1;
firstItem.x -= (ConfigManager.MENU_ITEM_WIDTH - ConfigManager.MENU_ITEM_WIDTH * zoomFactor) / 2;
firstItem.y -= (ConfigManager.MENU_ITEM_HEIGHT - ConfigManager.MENU_ITEM_HEIGHT * zoomFactor) / 2;
container.y = (ConfigManager.SELECTED_ITEM_LOCATION - firstItem.y - firstItem.normHeight / 2);
container.setChildIndex(firstItem, container.numChildren - 1);
selectedIndex = 0;
// Add glow effect to the first menu item if it's enabled
if (ConfigManager.ENABLE_GLOW) {
firstItem.filters = [firstItem.glow];
}
}
/**
* This method is called when a key is pressed.
* It calls necessary menu methods by considering the key pressed.
*/
private function onKeyDown(evt:KeyboardEvent):void {
if (evt.keyCode == Keyboard.UP) {
up();
} else if (evt.keyCode == Keyboard.DOWN) {
down();
}
}
/**
* This method is called when the mouse wheel is moved.
*/
private function onMouseWheel(evt:MouseEvent):void {
// Find the direction of the movement and select the appropriate menu item
if (evt.delta > 0) {
selectItem(selectedIndex - 1);
} else if (evt.delta < 0) {
selectItem(selectedIndex + 1);
}
}
/**
* This method is called when mouse is clicked on menu items.
*/
private function onMouseDown(evt:MouseEvent):void {
var menuItem:MenuItem = evt.target as MenuItem;
if (menuItem != null) {
selectItem(menuItem.index);
}
}
/**
* Deselects the menu item with the given index.
*/
private function deselect(index:int):void {
var item:MenuItem = items[index];
item.playScaleDown();
}
/**
* Selects the menu item with the given index.
*/
private function select(index:int):void {
var item:MenuItem = items[index];
container.setChildIndex(item, container.numChildren - 1);
item.playScaleUp();
}
/**
* Changes the position of the container to the selected menu item.
*/
private function relocate():void {
var item:MenuItem = items[selectedIndex];
var targetY:Number = (ConfigManager.SELECTED_ITEM_LOCATION - item.y - item.normHeight / 2);
moveTween.begin = container.y;
moveTween.finish = targetY;
moveTween.start();
}
/**
* Selects the menu item with the given index number.
*/
private function selectItem(index:int):void {
if (index == -1 || index >= items.length) {
return;
}
deselect(selectedIndex);
select(index);
selectedIndex = index;
relocate();
// Play the target frame
if (parent is MovieClip) {
var par:MovieClip = MovieClip(parent);
par.gotoAndPlay(items[selectedIndex].targetFrame);
}
}
/**
* Selects the previous menu item.
*/
public function up():void {
selectItem(selectedIndex - 1);
}
/**
* Selects the next menu item.
*/
public function down():void {
selectItem(selectedIndex + 1);
}
}
}
No Resize/scaling A Movie Clip On The Scaling Stage...
I know this has probably been answered here already, but I've search through all the threads with "scaling" and "resizing" and can't find the solution.
Basically I have a GUI element on a gallery that I don't want to scale, while the rest of the page is free to resize/scale.
I think I need to add a listener of some sort to the stage, but I'm not sure how to do this. If you can point me to a thread where this has already been answered, great! Otherwise I would be grateful for any help you could provide here.
|