Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Set Object Alpha On Button Click



Hey all.
Sorry if this seems like a newbie question, but I only have done flash in school, and this problem is really bugging me, and no one can seem to figure it out.

I'm trying to set the alpha of a button, after I press THAT button.

I have tried a lot of things, even with script assist I can't figure it out.

How would I go about doing this?

I have tried:

Code:
on (release) {
set(objectName._alpha, 0)
}

Code:
on (release) {
objectname._alpha = 0
}
Neither seem to work



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 01-10-2007, 01:39 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Button Click Behind Video W/ Alpha
I have a rather large video (flv) with alpha of someone walking around, however under the video are buttons thats cannot be clicked because the video is on top. I can't really but hidden buttons on top to trigger the buttons below, as the rollovers etc. won't fire.
Any thoughts on how to access the buttons?

Thanks,

Button Alpha Fade And On Click Load Centered Popupwindow
Ok guys I got a lot of help originally from L0stinbeta on the code for this particular section. He helped me create these buttons to load an exterior .swf file when clicked. All I want to do is change it to load a centered popup window instead, and be able to specify the dimensions of the window. Unfortunately I have exhausted my action script talent, and I am totally lost. Basically
I am trying to combine the two codes below. Please help! thx
onClipEvent (load) {
this._alpha = 30;
// set original alpha
}
onClipEvent (enterFrame) {
function fadeOut() {
if (this._alpha>30) {
this._alpha -= 10;
} else {
null;
}
}
// this function increases the _alpha of the object calling it
// when it reaches 100, it deletes its enterFrame
function fadeIn() {
if (this._alpha<100) {
this._alpha += 10;
} else {
null;
}
}
this.onRollOver = function() {
// when you roll over the button, you define its enterFrame as the
// function you have just declared. You could hard code it, but it is
// clearer that way and more reusable
this.onEnterFrame = fadeIn;
};
this.onRollOut = function() {
this.onEnterFrame = fadeOut;
};
this.onRelease = function() {
_root.loadfrom.loadMovie("flowertruck.swf");
};
}




and this one
on (release) {
//customize the window that gets opened
// 0 equals NO.
// 1 equals YES.
address = "http://www.kirupa.com/modular/pop-up.htm";
target_winName = "kirupa";
width = 400;
height = 300;
toolbar = 0;
location = 0;
directories = 0;
status = 0;
menubar = 0;
scrollbars = 1;
resizable = 0;
//sends data back to the function
openWinCentre(address, target_winName, width, height, toolbar, location, directories, status, menubar, scrollbars, resizable);
}

Button Click=> Down/up Object
Hello!!!
I am looking for some help about making that 2 buttons.
The first one move an object up on "Y" the second one move the object down on "Y" . there is any movement on X.

The point is that I don´t know the actions to do that movements...
can anybody help my?

thank soooooooooooo much !!!

Button Click Object Appear On Stage
how can i able to click on the button and the object will appear onto the stage? Can anyone show me or direct me to any tutorial which can guide me?

thanks!

Click A Button And The Object Pans Left Or Right...
I need to create a movie where you have a series of buttons in a row. Above the buttons is a long series of pictures, each one corresponding to a button. This series of pictures (PixMC) will be scrolling back and forth. When you click on a button of choice, PixMC will quickly pan left or right to land on the picture that corresponds with the button.

A good example of this function can be seen at:http://www.templatemonster.com/flash...ates/7276.html


Can anyone point me to a tutorial that will show me how to do this?

I've created scrolling nav bars and scrolling pictures but I've never done this particular thing.

Any suggestions?
Thanks!
Furpants

Chaning The Color Of An Object With The Click Of A Button
Hi guys, im back -havent done any web projects in a while... just got the new flash 8 pro so i decided to redo my portfolio and website... one thing i wanted to do was to have several Mcs change color with the click of the button.... so far im at a loss im not sure where to begin -can one of u gurus point me in the right direction? -please please please?

Using Button To Rotate Object Given Amount Per Click
sorry, I'm really new to flash, I hack my way through it by building things up on the timeline and spending way too much time probably.

Anyway, I want to know if there is a relatively easy way to assign like a rotation amount to a button so that each time you click the button it rotates a given object by a certain amount. like, if i can somehow link a circle to the button so eack time the button is pressed it spins the circle by like 15 degrees...is that possible?

thanks in advance

I Click On A Button , A Line Pops Up Under The Button I Click On A Different Button..
anyone know how to make this work?

this is what i want , when i click on a button a want a line to pop up under the button then when i click on another botton , i want that same line to move under the new button . if some1 could do a very basic one and put the .fla file that would be perfect. thanx

On Click Move And Alpha A Movie Clip
would like to know the AS code for getting a movieclip object to move to a specific x,y position on stage and change its alpha at the same time... would be nice if the movement was done with a nice tweening also.

using FlashMX .

Thanks

Click Button Once - WORKS FINE- Click It Again - RESTARTS MOVIE?
Don't know if I can attach it.. Here is a link..

http://www.yourmomrocks.net/ma/tca.fla

When I set actions to a button the action works fine. However, if the button is hit a second time, the whole movie restarts. I can't figure out why? I have attached the file. Please some one help if you can..
Thanks
WORKS FINE CLICK TWICE RESTARTS MOVIE?

How Can I Make A Button Go From Alpha 0 To Alpha 100
i wanna create a rollover button

i made the before and after pngs in PS
and i want to put the image that will appear over the original image with an alpha of 0 and when i roll over it the alpha to turn to 100 so it looks like the fade in


how do i change a graphic alpha ?

how can i do this please help

Single Click Button Requires Double Click
I noticed that some buttons in all of my .swf's were taking
two clicks to get them to work. After you double click them
once they work fine. I made a very simple movie to demonstrate
my problem. Please tell me if this problem is occuring for you also.

Thanks,
Anavrin

My .SWF file My .FLA file

Button Taking A Double Click Instead Of A Single Click
I have an on(release) button on a friends web site but it seems to be taking a double click to get through to the next page and also on that next page too clicking on the images takes a double click. Below is the AS I have on the button, similar on all other buttons too!

on(release){
getURL("http://www.brayglassworks.com/gallery1.htm", "_self");
}

http://www.brayglassworks.com

Thanks for any advice

Adding EventListener MouseEvent Click To Existing Mc Which Aleady Has Alpha Motion...
hi, my name's jude and i'm an author designing a site for my new publishing company. i want to use a flash button on the site and am having problems finding the right actionscript. i'm a total nOOb in actionscript but i promise i've done lots of research into this - however the only tutes i can find are for starting from scratch making movie clip buttons.

all i want to do is add the actionscript for a mouse click which takes you to the desired URL, to this existing code controlling the motion of the movie clip.

onClipEvent(load)
{
dir = 0;
speed = 6;
original._alpha = 0
this.onRollOver = function()
{
dir = 1;
}

this.onRollOut = function()
{
dir = -1;
}
useHandCursor = true;
}
onClipEvent(enterFrame)
{
temp = original._alpha + speed*dir;
original._alpha = Math.min(100,Math.max(temp,0));
}

you can see the completed .swf (before i changed the HandCursor to true) here.

and here are screenshots of the relevant pages in flash

http://i250.photobucket.com/albums/g...reenshot-1.jpg

http://i250.photobucket.com/albums/g...reenshot-2.jpg

http://i250.photobucket.com/albums/g...in/scene-1.jpg


- i would be so grateful for any help from you guys (and, i presume, girls!) - many thanks in advance.

Setting Alpha For One Object
Hey,

I have this code:
on (rollOver) {
tellTarget (square) {
_alpha = 0;
}
}


I'm trying to get the alpha level on JUST my square to go to 0, but it's changing the alpha of the whole movie. This gets to be a bit of a problem.

Can someone give me the code to do this?

Thanks,
Brian

Changing Alpha On An Object
Haven't posted here in like 2 years...thanks for being here

I have a problem displaying multiple objects. I have mutiple objects stacked over one another all with their alpha=0. My intention is when one selects a checkbox, one of these objects becomes visible by changing the alpha from alpha=0 to alpha=70 (see code below). Two things: in some cases, on an LCD screen (laptop) one can still see the objects where alpha=0. The second thing is that I get interference from all the stacked objects when one is selected. I am thinking that I want to use something where the objects are in a state of "off" rather than alpha=0? Any thoughts?

Here is a msword document illustrating the above points:
http://www.netwiz.net/~cheez/alpha_issue.doc

Here is the native FLA:
http://www.netwiz.net/~cheez/demo_spectra.zip

Here is the prototype website:
http://www.netwiz.net/~cheez/demo_spectra.html

Here is the code in question:


ActionScript Code:
if (checkbox.getValue() == true) {
        _root[spectraGraphic+"em"]._alpha = 70;
        _root[spectraGraphic+"ex"]._alpha = 80;
        getData(x, spectraGraphic);
        dimSpectra();
        order++;
        orderArray[order] = spectraGraphic;
    }
    if (checkbox.getValue() == false) {
        _root[spectraGraphic+"em"]._alpha = 0;
        _root[spectraGraphic+"ex"]._alpha = 0;
}
Any suggestions or comments would be greatly appreciated.

Thanks,
Cheez

How To Make A Button That Responds To Right Click, So That When You Right Click This
Hey, im Danief, im new to the forums.

I need to know how to make a button that responds to right click, so that when you right click this button, a goto action starts.

Ive been searching google for a freakin long time now... pleease if you know anything about it tell me.

Oh, and i also need to know how to make a timer that will start by the press of a button and stop with the press of a button.

Thanks for reading.

-Danief

Button Click LoadMovA..click Again LoadB?
I saw this code on the tutorials but it was in relation to Random backgrounds. Woud anyone know if I could use this to do the following....

First time a button is clicked, I want it load and play Movie A, if the button is clicked again, load and play Movie B.

Can I control where it loads? Meaning to a movieclip holder or something?

on (release) {
choice = Math.round(Math.random()*2);
switch (choice) {
case 0 :
location.loadMovie("image0.swf");
break;
case 1 :
location.loadMovie("image1.swf");
break;
}
}

Thanks

-M

Fading Alpha On A Video Object Question
Hello all,

I am attempting to use a timer in conjunction with a sprite's alpha levels to create a programmatic fade in/out for a video object. I have the fade out working wonderfully. For some reason I cannot seem to get the fade in to work properly. I am calling to a timer function that runs after the video is loaded. Once the timer finishes, I play the video. The video loads fine, but doesn't fade in, only pops to opaque when it starts to play (the holding clip, the video's parent, takes the transition fine, showing a nice fade in).

Can the video object not accept alpha values until after it is fully loaded, or does this sound like something else. I created a shape behind the video to test, and the transition is working properly, just the video alpha wont take.

Here is the class code. It is still working code, so please dont yell at me about improper coding form :P


Code:
package {


import flash.display.*;
import flash.events.*;
import flash.media.*;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.TimerEvent;
import flash.utils.Timer;

public class MainVideo extends Sprite {
private var client:Object;
private var nc:NetConnection;
private var ns:NetStream;
private var currentFile:String;
private var uldr:URLLoader;
private var vid:Video;
private var volumeTransform:SoundTransform;
private var currentTime:Number;
private var vidAlpha:Number;
private var holderVideoClip:Sprite = new Sprite();


public function MainVideo(file:String) {
currentFile = file;
volumeTransform = new SoundTransform();
client = new Object();
client.onMetaData = metadataHandler;

nc = new NetConnection();
nc.connect(null);
// Initialize the NetSteam object, add a listener for the netStatus
// event, and set the client for the NetStream.
ns = new NetStream(nc);
ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
ns.client = client;

volumeTransform.volume = 0;
ns.soundTransform = volumeTransform;

// draw test shape to see if fade is working
var testShape:Shape = new Shape();
testShape.graphics.beginFill(0xff0000);
testShape.graphics.drawRect(-5, -5,231,411);
testShape.graphics.endFill();
holderVideoClip.addChild(testShape);


// Initialize the Video object, attach the NetStram, and add the Video
// object to the display list.
vid = new Video();
vid.width = 385;
vid.height = 183;
vid.attachNetStream(ns);
vid.alpha = 1;
holderVideoClip.alpha = 0;
holderVideoClip.addChild(vid);
addChild(holderVideoClip);


// Fade in the video.
fadeVideoIn();

}

private function netStatusHandler(event:NetStatusEvent) {
try {
switch (event.info.code) {
case "NetStream.Play.Start" :
trace("we have lift off");
break;
case "NetStream.Play.StreamNotFound" :
trace("oops not found");
//closeVideo();
break;
case "NetStream.Play.Stop" :
trace("stream stopped");
closeVideo();
break;
}
} catch (error:TypeError) {
//error catching routines go here
}
}

private function fadeVideoIn(){
trace("startFade");
vid.alpha = 1;
var fadeInTimer:Timer = new Timer(50, 20);
fadeInTimer.addEventListener(TimerEvent.TIMER, onInTick);
fadeInTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerInComplete);
fadeInTimer.start();

function onInTick(event:TimerEvent):void {
trace((event.target.currentCount/2)*.10)
// displays the tick count so far
// The target of this event is the Timer instance itself.
currentTime = event.target.currentCount*.10
currentTime = currentTime/2;
vidAlpha = currentTime;
holderVideoClip.alpha = vidAlpha;
}

function onTimerInComplete(event:TimerEvent):void {
trace("Time's Up!");
fadeInTimer.removeEventListener(TimerEvent.TIMER, onInTick);
fadeInTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerInComplete);
fadeInTimer = null;
ns.play(currentFile);
}
}
private function fadeVideoOut(){
var fadeOutTimer:Timer = new Timer(50, 20);
fadeOutTimer.addEventListener(TimerEvent.TIMER, onOutTick);
fadeOutTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerOutComplete);
fadeOutTimer.start();

function onOutTick(event:TimerEvent):void {
trace((event.target.currentCount/2)*.10)
currentTime = event.target.currentCount*.10
currentTime = currentTime/2;
vidAlpha = 1-currentTime;
holderVideoClip.alpha = vidAlpha;
}

function onTimerOutComplete(event:TimerEvent):void {
fadeOutTimer.removeEventListener(TimerEvent.TIMER, onOutTick);
fadeOutTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerOutComplete);
fadeOutTimer = null;
removeVideo();
}
}
public function closeVideo(){
fadeVideoOut();
}
private function removeVideo(){
trace("video closed");
ns.close();
if(this.numChildren >= 1){
removeChild(holderVideoClip);
holderVideoClip.removeChild(vid);
}
vid = null;
}

}
}
Thanks ahead of time for all your help,
Jason @ MontyDigital.com

Can I Change The Alpha Color Of An Object By Actions?
Hi there, please I need some help, It does exist a simple way to make motion tweens by actions? I mean can in change the alpha color of an object from 0 to 100% by actions and not for frames? or move and object from left to right without apply motion tweens frame by frame?. Thanks for the collaboration.

Lt.

Alpha Tweening. Object Flashing At End Of Tween.
Hi guys
Been bashing my head against a brick wall for ages and have given in.
I have a problem with one of my animation that for the life of me I do not know why.

The flash I’m building has a series of maps that’s zoom in and zoom out of each other. It's for a very high res animation and has detailed maps.

For the zooming originally I was using tween via actionscript but this caused soo many unexplainable problems I had to try something else. Things like items not animating to their correct points or being half transparent for some reason. Some times they would work and sometimes not.

So wrote my own animation class which has a frame listener and adds or minus values for zoom as it sees fit. This has never failed and is solid.

I also use alpha tween on the map for a fade in/out effect. This is what causing the issues. The zoom uses my class for calculation but a tween on the object (movieclip) for the alpha animation. When zooming out the alpha is faded to 0, then in the next frame the object used for the animation is removed from the stage.

However at the end of the zoomout animation just before it is removed from the stage the object will blink. IE have it's alpha set to 1 then disappear. The zoom is supposed to zoom out and fade the object to nothing, however I get this blink at the end which looks quite poor. Even if I remove the code that removes the object from stage (IE just keep it on stage with the alpha set to 0) it will still blink.

Having said this it does not happen on all zoomout animations. I have used the same code for all my map zoom animations, much, if not all of the code in my system is standardized. Hence I would expect all my zoomout transition to be similar. Some will blink slightly, other are really predominate and some work perfectly.

I have tried running the alpha via tween and also tried adding functionality to my zoom class to handle alpha changes. Both still result in the blink. I have added a listener for the end of the animation that sets the object alpha values explicitly to 0. Also optimized the way in which the objects are removed. Nothing helps.

Can anyone help? Has anyone ever experienced these blinks I'm talking about? Any hacks I can try?

Alpha Fades On Multi-object Movie Clips
Ok... I have a movie clip which I have imported from illustrator and it has different elements. I have put an alpha fade on the movie clip but the ojects inside are seperatly showing transperancy so they see through eachother. I want them to fade in one block. Is there any way I can do this without completely breaking up the object?
Thanks!

Mouse Click And Object Goes There
I have been trying to make an object to go to a certain place on the stage where I have click there. I was succusful making the the object come towards the object. Heres the action code. Is there code for click mouse: I have attached the file. Thanks for the help.
speed = 1;
function moveCircle() {
if (circle._x<_root._xmouse-speed)
circle._x += speed;
else if (circle._x>_root._xmouse+speed)
circle._x -= speed;

if (circle._y<_root._ymouse-speed)
circle._y += speed;
else if (circle._y>_root._ymouse+speed)
circle._y -= speed;

On Alt+Click Rotate Object... Help?
Hi there,

I'm wondering how I would have an object rotate 45 degrees everytime a user alt+clicks on the object.

I'm attempting to create a floorplan in flash and I have furniture that the user can drag and drop onto the floorplan, now I'm just wondering if it's possible to have them be able to rotate the furniture by performing a keyboard command (alt+click on object). Any help is appreciated.

Using Flash 8.

Cant Click Object In Papervision
I am trying to make an object clickable in pv3d and its just not working out for me. This is what I have. A basic plane that I want to click on:

ActionScript Code:
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;

import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.materials.BitmapAssetMaterial;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.render.BasicRenderEngine;
import org.papervision3d.scenes.Scene3D;
import org.papervision3d.view.Viewport3D;

var camera:Camera3D;
var scene:Scene3D;
var viewport:Viewport3D;
var renderer:BasicRenderEngine;
var wall:Plane;


init();
function init()
{
    viewport = new Viewport3D(0, 0, true, true, false);
    addChild(viewport);
   
    renderer = new BasicRenderEngine();
   
    scene = new Scene3D();
   
    camera = new Camera3D();
   
    var wallMaterial:BitmapAssetMaterial = new BitmapAssetMaterial("Wall");
    wall = new Plane(wallMaterial,200,200,3,3);
    wall.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, shakeMe);
    scene.addChild(wall);
    addEventListener(Event.ENTER_FRAME, drawScene);
}

function shakeMe(e:InteractiveScene3DEvent):void
{
    trace("clicked");
}

function drawScene(e:Event):void
{
    renderer.renderScene(scene, camera, viewport);
}

On Alt+click Rotate Object...
Hi there,

I'm looking for some info on how to rotate and object in Flash 8 using a keyboard command.

I have a floorplan which users can drag furniture on to, and I would like it so that if they were to hold down alt and click on the peice of furniture, it would rotate 45 degrees.

What script (if any?) would help rotate 45 degrees everytime they alt + click?

Essentially I would like it to rotate 45 degrees more, everytime they click, so they have an option of rotating it to a full 360 degrees.

Does anyone have any tips on how to achieve this?

Thanks.

Can A Flash Object Be Click Through?
I've created a flash object that overlays my HTML webpage, but to use it I need to be able to click through this object so whatever links/etc are under it can still be accessed. Is there any way to do this?

Any help would be greatly appreciated.

Slide An Object Upon Click
I have the below function that is called when a button is clicked, however nothing happens. For testing purposes, I disabled all of the code within the function and get put in: iObject._y = EndPos; and that worked so I know the object is being passed correctly.


Code:
function SlideObjectDown(iObject,EndPos) {
_root.onEnterFrame = function() {
yMC = getProperty(iObject, _y);
moveMC = EndPos + yMC;
setProperty(iObject, _y, yMC + (moveMC/10));
if (getProperty(iObject, _y)>=EndPos) {
delete this.onEnterFrame;
}
};
}

Thanks for your help.

Animating Object On Click Event
How do you tween an object when a button is clicked? For example, I have Three buttons and a rectangle. When button one is clicked the x position of the object should scroll from the current location (0) to x=20. When button 2 is clicked the rectangle should scroll to x=100. If button one is pressed again, the object should move back to x=20. I can make the rectangle "jump" to the location but cannot find a way to make it tween.

Move Object Towards Mouse Click
Hello everyone!
I am in a study group at Aalborg University in Denmark, where we are currently working on a small Flash Computergame, nothing big, nothing fancy, just part of a small project.

I am currently working on putting together a small game map, a map where a character can walk around and talk to NPC's and such. We've just started to I am pretty much just working with the basics here. Just started learning AS3 too. I have created an Object, in this case a circle that gets drawn when I run my AS code, the circle is drawn in the midde of my stage. What I want, since the game is Isometric and moves in those isometric lines rather than straight up, down, left, right, I want to make a funktion where, if the mouse is clicked at a location where both the X and Y coordinate is less than where the object is, then the object moves to that place.

I hope you can follow me on this, otherwise, please do tell.
The code I have, is as follows at the moment:



Code:
var xNewPos:int;
var yNewPos:int;
var inTransit:Boolean = false;
var cirkel:circle = new circle();

cirkel.x = 400
cirkel.y = 300
addChild(cirkel);

function mouseClick(evt:MouseEvent):void {
xNewPos = evt.target.mouseX;
yNewPos = evt.target.mouseY;
inTransit = true;
//trace(xNewPos);
//trace(yNewPos);

function circleMove(evt:MouseEvent):void {
if(inTransit = true){
if(xNewPos < cirkel.x && yNewPos < cirkel.y){
cirkel.x = cirkel.x -=5;
cirkel.y = cirkel.y -=2.5;
}
}
}

Object Movement With Mouse Click AS3
I'm using Flash CS4.

And I am a newbie- I have no idea what I'm doing.

Okay, so I have an AS2 code that I want to "convert" it into an AS3 code. All the code does is make the obejct in the screen (a circle->movieclip) move to wherever it is clicked. It can go in any direction. I've attached it on here.

So, my question is, if you could help me change that into an AS3 code, and please, explain and be simple. I really a, new to this. I know almost nothing.

Here's the code I used:


Code:
onClipEvent (load) {
rad = 0.0174532925199433;
speed = 5;
moving = false;
}
onClipEvent (mouseDown) {
moving = true;
m = {x:_parent._xmouse, y:_parent._ymouse};
}
onClipEvent (enterFrame) {
if (moving) {
mcx = _x-m.x;
mcy = _y-m.y;
_rotation = -Math.atan2(mcx, mcy)/rad;
mr = _rotation*rad;
if (Math.sqrt((mcx*mcx)+((mcy)*(mcy)))>speed) {
_y -= speed*Math.cos(mr);
_x -= -(speed*Math.sin(mr));
} else {
_x = m.x;
_y = m.y;
moving = false;
}
}
}

On Click> Object Falls Inwards.
Ok i was wondering what script and how i would be able to do the following...

I want to make a website, and when you enter the site theres a welcome page with "Enter Here" text, when you click on the text the whole 650x500 page falls inwards and buttons to other pages come and start spining around this page which turned into a button when it landed on the home page....do you understand what i mean?

Move Object To Mouse Click
Hello everyone!
I am in a study group at Aalborg University in Denmark, where we are currently working on a small Flash Computergame, nothing big, nothing fancy, just part of a small project.

I am currently working on putting together a small game map, a map where a character can walk around and talk to NPC's and such. We've just started to I am pretty much just working with the basics here. Just started learning AS3 too. I have created an Object, in this case a circle that gets drawn when I run my AS code, the circle is drawn in the midde of my stage. What I want, since the game is Isometric and moves in those isometric lines rather than straight up, down, left, right, I want to make a funktion where, if the mouse is clicked at a location where both the X and Y coordinate is less than where the object is, then the object moves to that place.

I hope you can follow me on this, otherwise, please do tell.
The code I have, is as follows at the moment:



ActionScript Code:
var xNewPos:int;
var yNewPos:int;
var inTransit:Boolean = false;
var cirkel:circle = new circle();

cirkel.x = 400
cirkel.y = 300
addChild(cirkel);

function mouseClick(evt:MouseEvent):void {
    xNewPos = evt.target.mouseX;
    yNewPos = evt.target.mouseY;
    inTransit = true;
    //trace(xNewPos);
    //trace(yNewPos);

function circleMove(evt:MouseEvent):void {
        if(inTransit = true){
        if(xNewPos < cirkel.x && yNewPos < cirkel.y){
            cirkel.x = cirkel.x -=5;
            cirkel.y = cirkel.y -=2.5;
            }
        }
}

Move Object Towards Mouse Click
Hello everyone!
I am in a study group at Aalborg University in Denmark, where we are currently working on a small Flash Computergame, nothing big, nothing fancy, just part of a small project.

I am currently working on putting together a small game map, a map where a character can walk around and talk to NPC's and such. We've just started to I am pretty much just working with the basics here. Just started learning AS3 too. I have created an Object, in this case a circle that gets drawn when I run my AS code, the circle is drawn in the midde of my stage. What I want, since the game is Isometric and moves in those isometric lines rather than straight up, down, left, right, I want to make a funktion where, if the mouse is clicked at a location where both the X and Y coordinate is less than where the object is, then the object moves to that place.

I hope you can follow me on this, otherwise, please do tell.
The code I have, is as follows at the moment:









Attach Code

var xNewPos:int;
var yNewPos:int;
var inTransit:Boolean = false;
var cirkel:circle = new circle();

cirkel.x = 400
cirkel.y = 300
addChild(cirkel);

function mouseClick(evt:MouseEvent):void {
xNewPos = evt.target.mouseX;
yNewPos = evt.target.mouseY;
inTransit = true;
//trace(xNewPos);
//trace(yNewPos);

function circleMove(evt:MouseEvent):void {
if(inTransit = true){
if(xNewPos < cirkel.x && yNewPos < cirkel.y){
cirkel.x = cirkel.x -=5;
cirkel.y = cirkel.y -=2.5;
}
}
}

Rotating An Object Automatically On Click
Hi all

Given up on the other thread, others tell me its gonna be quite a bit of hassle!

What I want to do is as follows; I want a vinyl record on the stage to begin slowly rotating, until it hits full speed, on a mouse click.

All automatic.

I imagine this will involve adding a speed number to a basic rotation script. When it hits a certain speed, I want an event to be triggered.

Anyone have an idea on how I might go about this?

Cheers!

Transitioning Object To Mouse On Click?
How would I slide an object to the mouse, using onMouseDown?

I should be searching, but I couldnt think of a keyword. I've tried a whole bunch of math detecting distance & direction but of course some of them go negative (lol) & I got stuck, but I have tried!

No easing please, thanks!

MouseEvent CLICK And DOUBLE_CLICK On Same Object
Do you folks have any suggestions on how to listen on a SINGLE CLICK as well as DOUBLE CLICK for an object?

Meaning, one behaviour if the object is single clicked and another behaviour if it is double clicked.

Simply adding two event listeners (CLICK and DOUBLE_CLICK) leads to CLICK handler getting called always.

I understand one could start a timer upon the CLICK and if another CLICK doesn't arrive within 'x' milliseconds generate a SINGLE_CLICK event, else generate a DOUBLE_CLICK event. It seems like a hack and dependant on CPU load.

Is there a standard better way of doing this?

Thanks in advance,
-jlogan

Click A Display Object To Remove It
Hey all,

I would like to add some sort of event listener to an object upon its addition to the display list, such that clicking on the object removes it. How do I do that?

It would look something like this, although this doesn't work...


PHP Code:



var foo = new CustomObject();addChild(foo);foo.addEventListener(MouseEvent.CLICK, removeFoo); function removeFoo(event:MouseEvent):void {     removeChild(event.target);} 




The part that wouldn't work of course is "removeChild(event.target)". I guess I could do something like this:


PHP Code:



function removeFoo(event:MouseEvent):void {     if (foo) {          if (foo.parent != null) {               removeChild(foo);          }     }{ 




...but I'm hoping for something a bit more modular than that.

Any help?

Thanks,

Rotating An Object Automatically On Click
Hi all

Given up on the other thread, others tell me its gonna be quite a bit of hassle!

What I want to do is as follows; I want a vinyl record on the stage to begin slowly rotating, until it hits full speed, on a mouse click.

All automatic.

I imagine this will involve adding a speed number to a basic rotation script. When it hits a certain speed, I want an event to be triggered.

Anyone have an idea on how I might go about this?

Cheers!

Rotate Object With Click And Drag
Hi,

I'm making a site with a guitar theme,

what I want to do is to rotate the vibrato arm on the guitar with click
and drag.

another way to put it is like grabbing the hourhand on a clock an move it from 12 o'clock to 6 o'clock.

anyone know of a good tutorial that does something similar?

thanks

Chris

Having To Click On Embbeded Object Removal
Simple question hopefully.

I have noticed that I have to click on my flash object when embedded in html.

However I was on a site that had flash and I did not have to click on theres to operate it.

How is this done?

I have searched everywhere for a solution

Thanks in advance

jmcall10

Flash Object: Disable Right Click On It
I have a page where there is an embeded flash object.
If a visitor of the page do a right click in this flash object, instantly will see all the appropriate options of the flash (zoom,play etc).

I want to find a way in order to prevent the visitors 'see' if the object that runs on my page is a flash or something else.
They should not be able to do right click in flash object.

I must also say that this flash is not produced from macromedia flash application but it is actually a converter that outputs to the flash format.
So, it seems that any possible solution should be outside the flash format and flash file.

I thought a lot of possible ways but finally I have not found something that seems to work (layers, javascript, etc).

Is there any way to overcome this problem?


Thanks in advance

Spinning An Object In Flash With Click And Drag
Hi all,

I have a client who needs something rather odd. Basically what I have is a series of images of an object rotating, rendered in max. It's a diamond so I have to render it out of max to get all the reflections and refractions of the light playing in the diamond and on the surface it sits on.

This diamond has links on it, and the end users need to be able to spin it to get to each of the links.

Easy enough at first as I just put a button in there that they could click to rotate the diamond to the next face, revealing the next link.

It just got more complicated however as the client now wants to be able to click onthe diamond and drag left or right, to rotate it left or right. Sort of a free wheeling rotation, spun interactively as the user drags and rotates this diamond to get to the links.

I'm rather stumped as to how to do this with a sequence of images like this. I'm looking for any suggestions as to how I might tackle this.

Thanks in advance,
David

Click To Activate Flash Object In WinXP
Hi All:

Where ever flash object is present in a browser first user has to click to activate it and then the flash interactivity will work. Is there any solution to get rid of this through coding?

Can anyone help me?

Thanks in advance.

Regards
Razzak

Object Bigger On Click - Quick Answer Would Be Fantastic
1 MOVIECLIP
2 BUTTON

I require a movieclip to increase/decrease in size when a button is clicked.

To stop at the smallest size I set. And stop at the biggest size I set.

(Not -next -previous commands in a button to select a different frame.)




Is there any such actionscripting to solve my problem?

Thanks in advance

Click (and Drag) Bring-up-object In Depth Function?
I'd like to make an instance click-and-draggable (I know how to do that to an instance (startDrag("movie"), etc., but that's it). I'd like to create a global function for each object (say 3-5), so when a user clicks, it brings it to the very front and very draggable). For obvious reasons, it's a global function to call from each instance, rather than attaching nearly-duplicate on press and on release local functions to each and every instance. Well, sorta saves on efficiency, right?

Other things I'd like to see would be to have yet-more-embedded-functionality (buttons show up that are there, but disappear when you click on another instance, but that can come later. A bounding area would be nice too.

Any takers?



thanks.

Name Property Of Loader Object Lost In CLICK Event.
PHP Code:



private function loadIcons():void{
            count = 0;
            iconArray = new Array();
            for(var i:uint = 0; i < menuArray.length; i++){
                loader = new Loader();
                loader.contentLoaderInfo.addEventListener(Event.INIT, placeIcons);
                loader.load(new URLRequest("assets/icons/" + menuArray[i] + "_icon.swf"));
            }
        }
        
        private function placeIcons(event:Event):void{
            iconArray[count] = (loader.content as MovieClip);
            var loadedContent:MovieClip = (loader.content as MovieClip);
            //loadedContent.play(); needed for later to play ani.
            iconArray[count] = loadedContent;
            iconArray[count].addEventListener(MouseEvent.MOUSE_DOWN, menuSelected);
            addChild(iconArray[count]);
            count++;
        }
        
        private function menuSelected(event:Event):void{
            //addChild(loader);
            trace(event.target.name);  //PROBLEM GETTING THE INSTANCE NAME OF THE BUTTON PRESSED!!!! Look into
        }




Well, hard title.. sorry.

the object is to load a couple of swf's which serves as icons in a menu. I place these in an array so I can reference them later, then when clicked I need to know the id, name or anything about that swf to load the appropriate page which goes with the icon swf.

The problem is that even after I make the coercion to MovieClip on the "loadedContent" I am not allowed to set the "loadedContent.name = "instance name"" and no matter what I try all I get in the menuSelected function is "instance27" or what ever the player calls it at runtime..

I am quite sure I did this a thousand times, but now it does not work?

Thanks for any help given

[AS3] Gridded MC Buttons With Click Actions From Object And Array
How to make MC buttons with click actions from an Object Array and organize them into a grid.
I couldn't find a simple example of how to do this with AS3 so I made one to share. Please let me know if there is a better way to do this.

Paste This Into A Flash Frame


ActionScript Code:
var tX:Number = 0;var tY:Number = 0;var tWidth:Number = 100;var tHeight:Number = 100;var tSpacing:Number = 5;var tAmountThumbsWide:Number = 3;var _items:Array = new Array();_items.push ({thumb:"3d_game_.jpg", full:"3d_game.jpg"});_items.push ({thumb:"bottega_contact_.jpg", full:"bottega_contact.jpg"});_items.push ({thumb:"bottega_events_.jpg", full:"bottega_events.jpg"});_items.push ({thumb:"bottega_winelist_.jpg", full:"bottega_winelist.jpg"});_items.push ({thumb:"circa_cocktails_.jpg", full:"circa_cocktails.jpg"});_items.push ({thumb:"3d_game_.jpg", full:"3d_game.jpg"});_items.push ({thumb:"bottega_contact_.jpg", full:"bottega_contact.jpg"});_items.push ({thumb:"bottega_events_.jpg", full:"bottega_events.jpg"});_items.push ({thumb:"bottega_winelist_.jpg", full:"bottega_winelist.jpg"});_items.push ({thumb:"circa_cocktails_.jpg", full:"circa_cocktails.jpg"});/////////////////////////////////////////////////////////////////////////////////for (var i = 0; i<_items.length; i++) {    createButton (tWidth, tHeight, "btn"+String(i), i);}function createButton (w:Number, h:Number, nam:String, i:Number):void {    //---------------------------------- create an MC    this.nam = new MovieClip();    //---------------------------------- create a thumb backing     var sh:Shape  = new Shape();    sh.graphics.beginFill (0x333333,1);    sh.graphics.drawRect (0, 0, w, h);    sh.graphics.endFill ();    //---------------------------------- stick thumb backing into the MC    this.nam.addChild (sh);    //---------------------------------- Layout this MC on a grid    if(i%tAmountThumbsWide==0 && i != 0){        tY+=(h+tSpacing);    }    this.nam.x = ((i%tAmountThumbsWide)*(w+tSpacing));    this.nam.y = tY;    //---------------------------------- Add vars to MC    this.nam.name = nam;     this.nam.thumb = _items[i].thumb;    this.nam.full = _items[i].full;    //---------------------------------- Give MC cursor    this.nam.buttonMode = true;    //---------------------------------- Add MC to whatever MC "this" is    addChildAt (this.nam, 0);    //---------------------------------- Add MC to current position    this.nam.addEventListener (MouseEvent.MOUSE_DOWN, clicked);    this.nam.addEventListener (MouseEvent.MOUSE_OVER, over);    this.nam.addEventListener (MouseEvent.MOUSE_OUT, out);}function clicked (e:MouseEvent):void {    trace (" ");    trace ("btns name: ", e.target.name);    trace ("btns parents name: ", e.target.parent.name);    trace ("thumb: ", e.target.thumb);    trace ("full: ", e.target.full);}function over (e:MouseEvent):void {    e.target.alpha=0.5;}function out (e:MouseEvent):void {    e.target.alpha=1;}

How Can I Get An Object Or Image To Return To Its Original State With A Mouse Click?
Hi all,

As you can tell I'm VERY new to action script 3.0

I am trying to get image thumbs to slide out from behind others when moused over, and when clicked the expand in size.

I can't figure out how to add it so when you click again it returns to its original position and size.

Please help, and thanks to all.

here is my code so far:

beautyshot_1.addEventListener(MouseEvent.CLICK,onC lick);
beautyshot_1.addEventListener(MouseEvent.ROLL_OVER , beauty1Over);
beautyshot_1.addEventListener(MouseEvent.ROLL_OUT, beauty1Out);

function beauty1Over(event:MouseEvent):void
{
event.target.alpha = 1;
event.target.x += 100;
}
function onClick(event:MouseEvent):void
{
event.target.scaleY += 2;
event.target.scaleX += 2;

}
function beauty1Out(event:MouseEvent):void
{
event.target.alpha = 1;
event.target.x -= 100;

}

beautyshot_1.buttonMode = true

Copyright © 2005-08 www.BigResource.com, All rights reserved