Document Class / Action Script Help
Dear all,
From a tutorial page, i manage to built this flash page with
xml capabilities. but when i add more scene to the flash page, i
have errors like this.
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at MyContent/init()
at MyContent()
TypeError: Error #1009: Cannot access a property or method of
a null object reference.
at MyContent/onComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/onComplete()
How do i edit the "MyContent.as" file so that i can add more
scene to the flash.
I understand that, once i put the "MyContent.as" in the
document class, it will load immediately, is there any way to tell
it to load only in scene 2 (which is where the xml is needed).
Thanks. Any help will be very grateful.
Attach is the actionscript
other then defining the document class, can i "call up" the
MyContent.as (external script) when needed?
If this can be done, what must i do to add into the .fla file
and the .as file..
Sorry, i'm very new to AS3.
Thanks!!!
Similar Messages
-
Solaris packaging - "build" class action script
I tried to create a package with a build class action script but having problem with it. I am wondering if any one could give me hint on how to solve this problem? I tried to follow the example on the Solaris tutorial but it didn't work either.
In the prototype file, I have added: e build /etc/randomtable=etc/randomtable ? ? ?
In the pkginfo I have added: CLASSES=�none build�
Content of etc/randomtable in my build directory:
!install
# randomtable builder
if [ -f $PKG_INSTALL_ROOT/etc/randomtable ]; then
echo "/etc/randomtable is already in place.";
else
echo "# /etc/randomtable" > /etc/randomtable
echo "1121554 # first random number" >> /etc/randomtable
fi
!remove
# randomtable deconstructor
if [ -f $PKG_INSTALL_ROOT/etc/randomtable ]; then
# the file can be removed if it's unchanged
if [ egrep "first random number" /etc/randomtable ]; then
rm /etc/randomtable;
fi
fi
The error I got after running pkgadd on that package:
Modifying /etc/randomtable
/var/sadm/pkg/BPCttdb.2/save/build/etc/randomtable: !install: not found
/var/sadm/pkg/BPCttdb.2/save/build/etc/randomtable: !remove: not found
/var/sadm/pkg/BPCttdb.2/save/build/etc/randomtable: test: unknown operator first random number
pkgadd: ERROR: class action script did not complete successfully
Some links related to class action script for solaris build:
http://docs.sun.com/app/docs/doc/817-0406/6mg76stf7?a=view
http://dlc.sun.com/osol/docs/content/PACKINSTALL/ch5pkgcasestudies-80583.html#ch5pkgcasestudies-56
Thanks!I looked at the build script (/usr/sadm/install/scripts/i.build and r.build), and didn't see anything that parses the "!" directive. I'm not very familiar with build scripts, and the documentation is actually inherited from the original SVR4 documentation (not originating from Sun). But in looking at an example of a script that uses the build class, it expects the first argument to be either "install" or "remove" when called. So your example would look like this below. Note that my comment about the escaped comment can be ignored. It's surrounded by quotes, so is okay.
if [ $1 = install ] ; then
# randomtable builder
if [ -f $PKG_INSTALL_ROOT/etc/randomtable ]; then
echo "/etc/randomtable is already in place.";
else
echo "# /etc/randomtable" > /etc/randomtable
echo "1121554 # first random number" >> /etc/randomtable
fi
else
# randomtable deconstructor
if [ -f $PKG_INSTALL_ROOT/etc/randomtable ]; then
# the file can be removed if it's unchanged
if \[ egrep "first random number" $PKG_INSTALL_ROOT/etc/randomtable \]; then
rm /etc/randomtable;
fi
fi
So basically the SVR4 Applications Developers Guide incorrectly tries to use the "!install" and "!remove" commands.
-- Alan
Edited by: alanst on Apr 4, 2008 12:26 PM -
Action Script Help (Flash 8 ONLY)
My department currently has a host of training videos we use
for online courses. Of course, these are all being delivered as
FLVs. Through the Developer's communities, I found a script that
allowed me to add a caption file to the video (XML).
Now I'd like to take it to another level. I'd like to be able
to have my one SWF player play a series of FLVs AND include the
caption file. I began to look at using an Array, but have not been
successful in making it work. I'm not too sure, but I think the way
I coded it started to affect the video - started getting "stuck" at
times. Another attempt caused the caption file from the previous to
be seen in the current video.
I have attached my script and would appreciate any
assistance.
Finally, I need to stick to a Flash 8 and Action Script 2.0
solution. I realize that Flash 9 and Action Script 3.0 would be
helpful, but our district PCs are all imaged with a Flash 8 player.
Sorry.
Thank you for your help.
Frank Erazo ([email protected])Whatever approach you take will depend heavily on the document(s) you have for the bible element of the design. You somehow need to be able to seek within it and determine where matched elements can be found and how to extract the information you intend to present.
I don't think your issue currently lies with how to do this in Flash as much as first coming up with a gameplan that identifies the players and how you can interact with and within them. -
Flv xml Stream Playlist action script help
So if you go to this site:
click here
you will see a FLV player that has a list of videos that are
pulled from a .xml file...
The action script for this player is as such:
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);
rewindButton.onRelease = function() {
ns.seek(0);
playButton.onRelease = function() {
ns.pause();
var videoInterval = setInterval(videoStatus,100);
var amountLoaded:Number;
var duration:Number;
ns["onMetaData"] = function(obj) {
duration = obj.duration;
function videoStatus() {
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadBar._width = amountLoaded * 194.5;
loader.scrub._x = ns.time / duration * 194.5;
var vlist:XML = new XML();
vlist.ignoreWhite = true;
vlist.onLoad = function() {
var videos:Array = this.firstChild.childNodes;
for(i=0;i<videos.length;i++) {
videoList.addItem(videos
.attributes.desc,videos.attributes.url);
ns.play(videoList.getItemAt(0).data);
videoList.selectedIndex = 0;
var vidList:Object = new Object();
vidList.change = function() {
ns.play(videoList.getItemAt(videoList.selectedIndex).data);
videoList.addEventListener("change",vidList);
vlist.load("videos.xml");
I want to action script something that will make the videos
play one after the other, get rid of the list on the right and have
buttons on player that allow you to go to the next/previous video
listed in the .xml file
Its sort of like the player at
click
here
I know this is a lot to ask, but I am currently in a jam and
any help would be greatly appreciated...
Thanks
Matthelm88gotoAndLearn is a fantastic base to build off of.
but
i'm looking for the same thing... how do you get the files
to play one after another?
i've looked for everyhting ns. related and i can find any
doc's on this one.
i 've found the
function complete_listener(eventObject:VideoEvent):void {
if (my_FLVPlybk.source == "rentv1.flv") {
my_FLVPlybk.play("rentv2.flv");
else if (my_FLVPlybk.source == "rentv2.flv") {
my_FLVPlybk.play("rentv3.flv");
on the flash video live docs.. but i can't find anything on
how to tie it into the XML.
anything anyone can offer would be a huge help ... -
Im taking over a job and I was given the original flash file
that doesnt seem to be working properly.
It a thumbnail menu that loads through xml...the images work
fine but the Links & Titles do not load.
Nor does the rollover effect. Here what I have.
Action Script:
Stage.align = "TL";
Stage.scaleMode = "noscale";
preloader._visible = true;
thumbs_line._visible = false;
import mx.transitions.Tween;
import mx.transitions.easing.*;
my_xml = new XML();
my_xml.ignoreWhite = true;
if (_parent.xml_file == undefined) {
my_xml.load((String(_url.slice(0, (_url.length-3))))+"xml");
} else {
my_xml.load(_parent.xml_file);
my_xml.onLoad = function(ok) {
if (ok) {
process_xml();
} else {
trace("XML not loaded");
function process_xml() {
total_images = my_xml.childNodes[1].childNodes.length-1;
gallery_width =
Number(my_xml.childNodes[0].childNodes[0].attributes.gallery_width);
gallery_height =
Number(my_xml.childNodes[0].childNodes[0].attributes.gallery_height);
max_thumb_height =
Number(my_xml.childNodes[0].childNodes[0].attributes.max_thumb_height);
thumbs_space =
Number(my_xml.childNodes[0].childNodes[1].attributes.thumbs_space);
thumb_border =
Number(my_xml.childNodes[0].childNodes[1].attributes.thumb_border);
image_border =
Number(my_xml.childNodes[0].childNodes[1].attributes.image_border);
fade_in_seconds =
Number(my_xml.childNodes[0].childNodes[2].attributes.fade_in_seconds);
fade_out_seconds =
Number(my_xml.childNodes[0].childNodes[2].attributes.fade_out_seconds);
thumb_fade_seconds =
Number(my_xml.childNodes[0].childNodes[2].attributes.thumb_fade_seconds);
fade_in_seconds += 0.01;
fade_out_seconds += 0.01;
thumb_fade_seconds += 0.01;
thumbs_line._y =
gallery_height-max_thumb_height-(4*thumbs_space);
thumbs_line.thumbs_bg._width = gallery_width;
thumbs_line.thumbs_mask._width = gallery_width;
thumbs_line.thumbs_bg._height =
max_thumb_height+thumbs_space*2+thumb_border*2;
thumbs_line.thumbs_mask._height =
max_thumb_height+thumbs_space*2+thumb_border*2;
thumbs_line._visible = true;
load_thumb(0);
preloader._x = int((gallery_width-preloader._width)/2);
preloader._y = int(thumbs_line._y/2-preloader._height/2);
max_image_height =
gallery_height-max_thumb_height-thumbs_space*6;
load_image(0);
this["link"+t] =
my_xml.childNodes[1].childNodes[t].attributes.link;
function load_thumb(t) {
thumbs_line.thumbs.createEmptyMovieClip('thumb'+t,
thumbs_line.thumbs.getNextHighestDepth());
thumbs_line.thumbs['thumb'+t]._y =
thumbs_space+thumb_border;
thumbs_line.thumbs['thumb'+t]._x =
thumbs_space+thumb_border;
if (t>0) {
thumbs_line.thumbs['thumb'+t]._x =
thumbs_line.thumbs['thumb'+(t-1)]._x+thumbs_line.thumbs['thumb'+(t-1)]._width+thumbs_spac e;
thumbs_line.thumbs['thumb'+t].image_number = t;
thumbs_line.thumbs['thumb'+t].onRollOver =
thumbs_line.thumbs['thumb'+t].attachMovie("thumbov_mc",
"thumbov_mc", 10);
thumbs_line.thumbs['thumb'+t].onRelease = function() {
tellTarget (thumbs_line.thumbs['thumb'+t]) {
var loadListener:Object = new Object();
loadListener.onLoadInit = function(target_mc:MovieClip) {
preloader.visible = false;
thumbs_line.thumbs['thumb'+t].attachMovie("border_grey",
"border_grey", 10);
thumbs_line.thumbs['thumb'+t].border_grey._x -=
thumb_border;
thumbs_line.thumbs['thumb'+t].border_grey._y -=
thumb_border;
thumbs_line.thumbs['thumb'+t].attachMovie("border_white",
"border_white", 20);
thumbs_line.thumbs['thumb'+t].border_white._x -=
thumb_border-1;
thumbs_line.thumbs['thumb'+t].border_white._y -=
thumb_border-1;
if (target_mc._height>max_thumb_height) {
ratio = target_mc._width/target_mc._height;
target_mc._height = max_thumb_height;
target_mc._width = int(target_mc._height*ratio);
thumbs_line.thumbs['thumb'+t].border_grey._width =
target_mc._width+thumb_border*2;
thumbs_line.thumbs['thumb'+t].border_grey._height =
target_mc._height+thumb_border*2;
thumbs_line.thumbs['thumb'+t].border_white._width =
target_mc._width+thumb_border*2-2;
thumbs_line.thumbs['thumb'+t].border_white._height =
target_mc._height+thumb_border*2-2;
if (t<total_images) {
t++;
load_thumb(t);
thumbs_width = thumbs_line.thumbs._width;
thumbs_right_limit = 0;
thumbs_left_limit =
0-thumbs_width+int(gallery_width-thumbs_space-thumbs_space);
var thumb_fade_in:Tween = new Tween(target_mc, "_alpha",
none.easeIn, 0, 100, thumb_fade_seconds, true);
var thumb_loader:MovieClipLoader = new MovieClipLoader();
thumb_loader.addListener(loadListener);
createEmptyMovieClip("img", 30);
thumb_loader.loadClip(this.my_xml.childNodes[1].childNodes[t].attributes.small,
img);
thumbs_line.onMouseMove = function() {
if (_xmouse>=thumbs_line.thumbs_bg._x and
_xmouse<=thumbs_line.thumbs_bg._width and
_ymouse>=thumbs_line._y and
_ymouse<=thumbs_line._y+thumbs_line._height) {
onRollOver =
thumbs_line.thumbs['thumb'+t].attachMovie("thumbov_mc",
"thumbov_mc", 10);
onEnterFrame = function () {
if (_xmouse<(gallery_width/2)-10 and
thumbs_line.thumbs._x<thumbs_right_limit) {
thumbs_line.thumbs._x -=
int((_xmouse-thumbs_line.thumbs_bg._width/2)/(100-scroll_speed));
if (thumbs_line.thumbs._x>thumbs_right_limit) {
thumbs_line.thumbs._x = thumbs_right_limit;
if (_xmouse>gallery_width/2+10 and
thumbs_line.thumbs._x>thumbs_left_limit) {
thumbs_line.thumbs._x -=
int((_xmouse-thumbs_line.thumbs_bg._width/2)/(100-scroll_speed));
if (thumbs_line.thumbs._x<thumbs_left_limit) {
thumbs_line.thumbs._x = thumbs_left_limit;
} else {
onEnterFrame = undefined;
this["link"+t] =
my_xml.childNodes[1].childNodes[t].attributes.link;
this["the_target"+t] =
my_xml.childNodes[1].childNodes[t].attributes.target;
XML File
<?xml version="1.0" encoding= "UTF-8" ?>
<options>
<option gallery_width="730" gallery_height="450"
max_thumb_height="96"/>
<option scroll_speed="75" thumbs_space="0"
thumb_border="1" image_border="2"/>
<option fade_in_seconds="1.5"
thumb_fade_seconds="1.5"/>
</options>
<gallery>
<img small="../flash/hosts/images/pic7.jpg" title="Name
1" link="hosts.asp"/>
<img small="../flash/hosts/images/pic1.jpg" title="Name
2" link="bio1.asp"/>
<img small="../flash/hosts/images/pic2.jpg" title="Name
3" link="bio2.asp"/>
<img small="../flash/hosts/images/pic3.jpg" title="Name
4" link="bio3.asp"/>
<img small="../flash/hosts/images/pic5.jpg" title="Name
5" link="bio4.asp"/>
<img small="../flash/hosts/images/pic6.jpg" title="Name
6" link="bio5.asp"/>
<img small="../flash/hosts/images/pic8.jpg" title="Name
7" link="bio6.asp"/>
<img small="../flash/hosts/images/pic9.jpg" title="Name
8" link="bio7.asp"/>
</gallery>
Thier is a dynamic Text field in the roll over effect that
should contain the "title"
the rollover MC name is: thumbov_mc
the dynamic text field is labeled: title
And the links are not working either?
Does anyone see the problem?
Thank You So Much for you help in AdvanceIf you think you can help just let me now and ill email you
the link to where this menu is...i dont want to post it for
everyone to see..thanks -
Hey there, just putting together a website using flash.
Everythings ok except, my website is one flash file, i've
done a new document which is a page for my movie to
play in. So i have jesl homepage.swf and now charles.swf
On my homepage scene 3 theres a button you press
using loadmovie script and it goes straight to the
charles.swf
and from charles.swf theres a go back button that goes
straight back
to my jesl homepage.swf
using this from charles back to homepage
on (release) {
loadMovieNum("jesl homepage.swf", 0);
Now all i would like to do is from charles.swf
go back to my jesl homepage.swf like it does,
but go to scene 3. Maybe its simple and im stupid
but i cant figure it out. Cause scene 3 is where the
info and buttons are about my movie and it would
make sense to go back where you started from...
So yeah it goes back fine to my scene 1 homepage
but i want scene 3 guys...
Any help would be greatful
As im pulling my hair out..Hi there jestone and welcome to the on-line community
I know this forum category says "FlashHelp", but note that
both words "Flash" and "Help" are run together. This is a forum
where people using FlashHelp output from the Adobe RoboHelp product
ask questions. Most of the folks here are developers of the
Microsoft Help technology. FlashHelp is simply one possible output
from this product.
I think you are probably looking for the Flash forum, so I'll
give you a magic link to take you over there where you can post
your question and be more likely to find an answer.
Click
here to visit the Flash forum
Good luck! Rick -
Flash Professional Action Script help?
I am try to create a website where people can view an online bible and search for within it for certain passages using a search box, but I don't know how to begin to make that happen, in flash professional. Please help.
Whatever approach you take will depend heavily on the document(s) you have for the bible element of the design. You somehow need to be able to seek within it and determine where matched elements can be found and how to extract the information you intend to present.
I don't think your issue currently lies with how to do this in Flash as much as first coming up with a gameplan that identifies the players and how you can interact with and within them. -
Action script help: Quiz that uses an array needs to be changed.
Hi,
I have a quiz that was created by someone else, and now I (inexperienced with flash) need to make some edits. The quiz has 4 questions, and each answer the user clicks on will show a green ball, and then other text appears to let them know if they are right or not. Also, when they click the right answer "next" appears in the bottom right corner.
Now I need to make the wrong answers red balls, and have the green ball only for the right answer. However it seems there is only one "green ball" and the code creates an array and that's all I can understand. I will need to make this changes to about 15 quiz questions, so hopefully the solution is something I can replicate easily on my own.
Thanks!
Here is the code:
function doAnswer(n){
//d or 4 is the correct answer.
var bArray:Array = n.split("_");//split the button's name to array
var butNum = bArray[1];//retrieve the button's number from the array
//reset any answers that may have already been answered
for (i=1;i<=4;i++){
var currAns = "ans1_" + i;//current looped mc answer
var currBut = "btn_" + i;
if (this[currAns].actv == 1){
this[currAns].play();
if (this[currBut].actv == 1){
this[currBut].play();
this["ans1_" + butNum].play();
if (butNum==4){
next_mc._visible = 1;
}else{
next_mc._visible = 0;
Flash CS5.5kglad,
I'm not exactly sure what you mean. When the user clicks on the circle next to each answer, the colored ball fills the space. When they click on another answer, the ball from the previous answer disappears, so there is only one colored ball on the screen at a time. Does that help? -
XML Driven Photo Gallery (Action Script Help)
Hi,
I need to make a XML Driven Photo slide in Flash CS5.
It needs to have a Box that contains 5 Thumbnails(by XML) act as buttons.
The Box sits on top of the Main photo area and shrinks (or close out) when user click its close button. And it opens out by clicking on a open button.
I'm sure it can be done by using timeline, Tweening or you name it..But what about the Thumbnails that run from the XML file?
Can they disappear with the Box and retrieve when it opens? is it possible?
If yes, what would be the best way to do that?
Any comment would be greatly appreciated!
Here is the ActionScript.
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.Event;
import fl.controls.Button;
import flash.display.Shape;
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.text.TextField;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.display.Shader;
var hasloaded:Boolean = false;
var firstLoaded:Boolean = false;
var barWidth:int;
var barHeight:int;
var images;
var imageCount:int;
var thumbnailArray:Array = new Array();
var bigImageArray:Array = new Array();
var descriptionArray:Array = new Array();
var xmlLoader:URLLoader = new URLLoader();
var imageXML:XML = new XML();
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("slideshow.xml"));
function LoadXML(e:Event):void {
imageXML = new XML(e.target.data);
ParseImages(imageXML);
Populates the arrays with the image values
and the text for each picture.
function ParseImages(imageInput:XML):void {
var iconList:XMLList = imageInput.image.icon;
var mainImageList:XMLList = imageInput.image.mainimage;
var descriptionList:XMLList = imageInput.image.description;
for (var i:int = 0; i < iconList.length(); i++) {
var imageElement:XML = iconList[i];
//trace(imageElement);
thumbnailArray[i] = imageElement;
for (var j:int = 0; j < mainImageList.length(); j++) {
var mainimageElement:XML = mainImageList[j];
//trace(mainimageElement);
bigImageArray[j] = mainimageElement;
for (var l:int = 0; l < descriptionList.length(); l++) {
var descriptionElement:XML = descriptionList[l];
//trace(descriptionElement);
descriptionArray[l] = descriptionElement;
loadImages();
function loadImages():void{
trace("inside of loadimages function.");
trace(thumbnailArray.length);
for(var i:int=0; i < thumbnailArray.length; i++){
trace(thumbnailArray[i]);
populateContainers(thumbnailArray[i], i);
//populateContainers2();
trace("Loaded " + thumbnailArray[i]);
var loader:Loader;
var xStart = -210;
var ypos = -34;
var currentPos = xStart;
var incrementValue = 66;
This takes in the name of the image file and
displays it within the newly created movie clip
function populateContainers(file:String, pos:int):void{
//create a movie clip to hold the image
var mc:MovieClip = new MovieClip();
mc.graphics.beginFill(0xFFFFFF);
mc.graphics.drawRect(0, 0, 50, 51);
mc.graphics.endFill();
mc.buttonMode = true;
mc.x = currentPos;
mc.y = ypos;
mc.name = "thumb_" + pos;
mc.addEventListener(MouseEvent.CLICK, clickHandler);
loader = new Loader();
//loader.mask = imagemask;
var url:URLRequest = new URLRequest(file);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadInitialImage);
loader.load(url);
//add the image to the movie clip
mc.addChild(loader);
this.imageBar.addChild(mc);
//increment the currentPos
currentPos += incrementValue;
function clickHandler(e:MouseEvent):void{
var str:String = e.currentTarget.name;
var index:int = int(str.substr(6,1));
if(hasloaded) {
this.mainWindow.removeChild(loader);
loader = new Loader();
loader.load(new URLRequest(bigImageArray[index]));
this.mainWindow.addChild(loader);
TransitionManager.start(this.mainWindow,{type:Fade, direction:Transition.IN, duration:2, easing:Regular.easeOut});
//setChildIndex(loader, 0);
hasloaded = true;
loadText(index);
function loadText(index:int):void {
Object(this).imageBar.txtdescription.text = descriptionArray[index];
function loadInitialImage(event:Event):void {
if(!firstLoaded) {
loader = new Loader();
loader.load(new URLRequest(bigImageArray[0]));
this.mainWindow.addChild(loader);
TransitionManager.start(this.mainWindow,{type:Fade, direction:Transition.IN, duration:2, easing:Regular.easeIn});
//setChildIndex(loader, 0);
hasloaded = true;
loadText(0);
firstLoaded = true;
/* This section defines the buttons that control the image bar */
Object(this).imageBar.btnBarOpen.addEventListener(MouseEvent.MOUSE_UP, openImageBar);
function openImageBar(event:MouseEvent):void {
this.gotoAndPlay(1);Well Thats what i know but you might be able to use flash player 10 in your browser i think the file system works on it fine im not sure i mostly work on air glad i could help
James -
Hello List.
This is my first try at Flash.
I tried the drag and drop demo at
http://monkeyflash.com/tutorials/flash-drag-and-drop/.
It works well allowing me to drag an item and have it register when
it is dropped on the correct target.
I want to modify it so that I can drag an item to multiple
locations... not just one.
My desired application is the ability to drag pendents or
charms onto a bracelet or chain and have them "snap" to the chain.
With the above demo, I can see how 90% of it would work, but I
cannot figure out how to have multiple targets named the same. The
bulk of the code is attached.
The line I believe needs to changed is this one:
if (event.target.dropTarget != null &&
event.target.dropTarget.parent == myTarget){
I need this part :event.target.dropTarget.parent == myTarget
to read something to the affect of:
if item being dropped is over object A OR object B OR object
C OR object D than ... rest of my code
Can this be done?
Any help is greatly appreciated.if drag1MC is one of your dragable movieclips and has
acceptable drop-targets mc1, mc2,mc3:
drag1MC.droptargetA = [mc1,mc2,mc3];
function dropIt(event:MouseEvent):void {
var mc:MovieClip = MovieClip(event.currentTarget);
mc.stopDrag();
var success:Boolean = false;
for(var ind:int=0;ind<mc.droptargetA.length;ind++){
if(mc.dropTarget!=null&&mc.dropTarget==mc.dropTargetA[ind]){
success = true;
mc.x = mc.dropTargetA[ind].x;
mc.y = mc.dropTargetA[ind].y;
break;
if (success){
reply_txt.text = "Good Job!";
} else {
reply_txt.text = "Try Again!";
} -
Hi to all,
This is vertical xml gallery code, where the mouse will move
up, then the scoller will move up and vice versa. now i want the
reverse . if it move up , then the scoller come down and if it move
down , then the scoller move up.
Can anyone please help me.
Thanks
Krishna
quote:
this.onEnterFrame = function()
mask_y = _root.main.verti.mask._y;
mask_h = _root.main.verti.mask._height;
mask_middle = (mask_y + mask_h) / 2; // take middle of mask
as reference
roller_y = _root.main.verti.roller._y;
roller_h = _root.main.verti.roller._height;
ymouse = _root.main.verti.mask._ymouse;
// if mous out of range
if (ymouse < mask_y || ymouse> mask_y + mask_h)
speed = 0;
else
speed = (ymouse - mask_middle)/ 10;
// calculate speed -> the closer to middle-> slower,
closer to edges-> faster
// if roller bottom reaches mask bottom and scroll up, stop
if ((roller_y+roller_h)<(mask_y+mask_h) && speed
< 0)
speed = 0;
// if roller top reaches mask top and scroll down, stop
if (roller_y > mask_y && speed > 0)
speed = 0;
_root.main.verti.roller._y += speed;
stop();try:
-
I am trying to figure out the proper verbage for this. If I
want to have a button gotoAndPlay "home" but then immediately
after, without stopping, gotoAndPlay something else, What is the
code for that?
I.E.:
on (press) {
gotoAndPlay ("home");
[what do I put in next to make it go play something else
without pausing?]
Text
TextYou need to see that task with different eyes, as soon as the
script reaches the gotoandplay line, the playhead will jump
instantly to that location and you need to write the next jump on
that home frame.
Why don't you rather set a variable saying where it should go
after home like:
on(press){
gotoAndPlay("home");
var nextGoTo = xxx;
and on your home frame you have an case statement runnning
checking which variable you activated so it will jump directly to
it.
If you don't undestand what I mean with it, you can send me
the fla file and I will show you how to create it. -
FlashGame, "sniper"-game, Action script help!
Hello!
I was trying to create a simple shooter game in Flash.
And i want it to be very simple and not good looking if you
now what i mean.
Now to my problem.
The game is all about to aim at a target and then fire/click
and if you have hit the target, it should go to another frame. I
want it to go to frame 5 after that you have hit the target.
The sight is very simple, it´s a circle whit a cross in
it. And it have a transparent background.
The mouse is "hide" and the grafic (sight) show instead.
BUT the moues is not "hide" in the midle of the sight. I want
to decide where the mouse should be hide in the sight.
I now that it can be hard to understand what i mean,
so download the FLA file so that you have a better overview
of my problem.
http://rapidshare.com/files/90288167/SkjutTest.fla.html
Please take time and help me solve my problem.
Sorry for my eng. , i´m Swedish.
Thanks!
//SweFilleyou can't control where the hidden mouse is located. you can
control where you sight is located.
so, if you want the mouse to be at the lower left of the
sight, place the sight movieclip at the _xmouse+whateverX,
_ymouse-whateverY. though, i can't think of any reason you would
want to do that unless you just want to aggrevate your users so
they shut down your game sooner rather than later. -
Need Action Script Help PLEEAASEE
I have a project that and is a prize wheel, here is my code for starting and stopping the wheel
if (Key.isDown(Key.ENTER))
speed=speed*.99;
else if (Key.isDown(Key.RIGHT)){
speed=5;
else if (Key.isDown(Key.LEFT)){
speed=0;
this._visible=true;
The right and left key functions work perfect but the enter key needs to be "held down" until the wheel slowly stops. I want to be able to just press the "Enter" key and the wheel will slowly (randomly)come to a halt. the problem code is in bold. any help would be great.Assuming you really mean you want to press and release the Enter key, what you need to do is have something else play the role of what the "if (Key.isDown(Key.ENTER))" line does for you in terms of repeatedly changing the speed value. Something in the way of an onEnterFrame activity that gets intiated by the pressing of the Enter key, but just once... you need something to only allow it to intiate that enterFrame once...
So somewhere outside that code you want to have a Boolean variable that is used when the Enter key is pressed which conditionally calls a function that initiates the enterframe activity and then sets that value to false to keep it from being called again. That variable could be reset to true when the RIGHT key initiates a new go. So pressing the Enter key sets that variable to true. The code would follow along the lines of what I show below, but I cannot say it's polished stuff as shown... just the concept is attempted. I don't know what other code you have involved in matters.
var startSlowing = true;
if (Key.isDown(Key.ENTER))
if(startSlowing){
slowItDown();
startSlowing = false;
else if (Key.isDown(Key.RIGHT)){
speed=5;
if(!startSlowing ){ // means it was restarted in mid-spin
delete this.onEnterFrame;
startSlowing = true;
else if (Key.isDown(Key.LEFT)){
speed=0;
if(!startSlowing){
delete this.onEnterFrame;
function slowItDown(){
this.onEnterFrame = function(){
speed=speed*.99;
if(speed < someLimit){
delete this.onEnterFrame; -
Next/Back Action script help to stop and start
When I "removeEventListener" for img10, my last image going forward, Next no longer goes forward for 1-9 after going back. I've tried some conditional statements but I'm new to this and nothing is working. I also thought I could do what I did to stop the forward movement to the back movement, stopping at img1, but that didn't work. I'll leave the code that didn't work here with // before.
I'm also wondering if there's an easy way to have the transition of the photos dissolve from one to the next without setting up as parent-child. I've set it up with a UILoader.
Site is live (with these issues and others!) at : http://emilysperphoto.com/
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
//variable is a container that holds some value...
var imageNumber:uint = 1;
function checkNumber():void
//If the image number is = 10, then do something...
if (imageNumber==10)
next_btn.removeEventListener(MouseEvent.CLICK, nextImage);
//else if (imageNumber<10)
//next_btn.addEventListener(MouseEvent.CLICK, nextImage);
function nextImage(evtObj:MouseEvent): void{
//Add a number to the current value+1
imageNumber++;
largeImageLoader.source = "images/recent/rcnt0"+imageNumber+".jpg";
checkNumber();
back_btn.addEventListener(MouseEvent.CLICK, backImage);
//If the image number is = 1, then do something...
//if (imageNumber==1)
//back_btn.removeEventListener(MouseEvent.CLICK, backImage);
function backImage(evtObj:MouseEvent): void{
//Subract 1 from the current value
imageNumber--;
largeImageLoader.source = "images/recent/rcnt0"+imageNumber+".jpg";
//checkNumber();Try this code (I did not check it functionality but the idea is there):
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
//variable is a container that holds some value...
var imageNumber:uint = 1;
// parametarize number of images
var numImages:int = 10;
function addListeners():void {
next_btn.addEventListener(MouseEvent.CLICK, nextImage);
back_btn.addEventListener(MouseEvent.CLICK, nextImage);
function checkNumber():void
// if imageNumber equals number of images
// disable next click
if (imageNumber == numImages) {
next_btn.removeEventListener(MouseEvent.CLICK, nextImage);
else if (imageNumber == 1) {
// if number of images equals 1
// disable previous button
back_btn.removeEventListener(MouseEvent.CLICK, nextImage);
else {
addListeners();
function nextImage(evtObj:MouseEvent):void
imageNumber = evtObj.currentTarget == next_btn ? imageNumber + 1 : imageNumber - 1;
// first check number
checkNumber();
// now load corresponding image
largeImageLoader.source = "images/recent/rcnt0" + imageNumber + ".jpg";
Maybe you are looking for
-
Help for Report Painter!!
Dear All, When i create a report in Report Painter and execute, it requires insert report in report group, i chose once of report group --> ok, but an error occurs: "Objects with leading zero may not be changed". So, what can i do? pls help me. Thank
-
How to make a fullscreen slideshow like this?
this is an app I found that the slideshow is what I want to make,but with original slideshow I can't make it,so I really want to know the special way to do I am using the adobe content viewer on ipad to test my file, is it the reason? some functions
-
I am having problems transferring my downloaded purchased from my iPhone even after following instructions! Can someone please help!!!??
-
Using PDFs in Slideshows - plus, the DVD-RW trick
Dear Friends, As one of my menu options in a current iDVD project, I have a series of illustrated documents in TextEdit which I have converted to PDF (Problem is, I can't find the orig. TextEdit file, so must use the PDF) that the viewer can click th
-
How to change element in many pages and export to pdf?
Hi guys! I've got a lot of Pages files with some text and graphic in the footer. I'd like to change this footer in all of them instantly and then export modified files to pdfs. Is that possible?