createEmptyMovieClip & onclick

This is a discussion on "createEmptyMovieClip & onclick" within the Flash & Multimedia Forum section. This forum, and the thread "createEmptyMovieClip & onclick are both part of the Design Your Website category.



Go Back   Webforumz.com > Main Forums > Design Your Website > Flash & Multimedia Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Sep 6th, 2007, 21:16
New Member
Join Date: Sep 2007
Location: here
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
createEmptyMovieClip & onclick

Hello,
I am a beginner in Flash and I'm trying to make a slidebar which loads images from xml data,
this works. However, I want to put an onclick event on it
(in javascript i would make something like this:

_root.bar['diagram'+p].onClick = displaydata(desciption[p]);

function displaydata(content){
textbox1.text = content;
}
)

This is my actionscript code:

<code>
function firstImage() {
for (p=0; p<(total); p++){
var newx = p * 106;
_root.bar.createEmptyMovieClip('diagram'+p,p);
_root.bar['diagram'+p].loadMovie(image[p], 1);
_root.bar['diagram'+p]._x = newx;
_root.bar['diagram'+p]._xscale = 50;
_root.bar['diagram'+p]._yscale = 50;
_root.bar['diagram'+p].onPress = function() {
trace("You pressed me!");
}
}}
</code>
Why does this part _root.bar['diagram'+p].onPress = function() {
trace("You pressed me!");
} not work? and how can I get this to work?


(Flash 8)

Thank you!
Richard

Last edited by R Verbrugge; Sep 6th, 2007 at 21:22. Reason: Rude question to start of with ;)
Reply With Quote

  #2 (permalink)  
Old Sep 7th, 2007, 20:46
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: createEmptyMovieClip & onclick

Well it works like this:
Code: Select all
bar.onPress = function() {
trace("You pressed me!");
}
So it is something to do with the ['diagram'+p] can you tell me what you are wanting this peice of code to do or why it is there?
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #3 (permalink)  
Old Sep 10th, 2007, 17:24
New Member
Join Date: Sep 2007
Location: here
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: createEmptyMovieClip & onclick

I looked around on other pages and I noticed that for loadMovie() you cannot use a 'on (..)' command. instead the suggestion was to duplicate a mc and use the loadMovie() in that dupped movie.
this is what I made and works very nicely!

Code: Select all
function firstImage() { 
_global.fwt = (total * 95) -95;
trace("total pic count ="+total+" total width = "+fwt+"")
for (p=0; p<(total); p++){
_root.bar.redbox.duplicateMovieClip("redbox"+p, p, {_x:(95*p), _y:_root.bar.redbox._y}); 
var datat = (eval("_root.bar.redbox"+p+".duptext"));
var urlinf = (eval("_root.bar.redbox"+p+".url"));
var imgholder = (eval("_root.bar.redbox"+p+".img"));
imgholder.createEmptyMovieClip('diagram'+p,p);
imgholder['diagram'+p].loadMovie(image[p], 1);  
urlinf.text = image[p];
datat.text = description[p];
}
_root.bar._x = 185;
}
Now I wish to add a pre-loader (a little loader bar to show something is being loaded).
How is this done?
Reply With Quote
  #4 (permalink)  
Old Sep 10th, 2007, 18:42
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: createEmptyMovieClip & onclick

There are a few other recent posts about this, but here is a good source for information....

http://www.senocular.com/flash/tutorials/preloading/
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #5 (permalink)  
Old Sep 12th, 2007, 21:22
New Member
Join Date: Sep 2007
Location: here
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
preload..

Keep on hitting problems!

Main movie (one frame):
Code: Select all
stop();
function loadXML(loaded) { 
if (loaded) { 
xmlNode = this.firstChild; 
image = []; 
labelt = []; 
total = xmlNode.childNodes.length; 
for (i=0; i<total; i++) { 
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue; 
labelt[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue; 
} 
fillbar(); 
}  
} 
xmlData = new XML(); 
xmlData.ignoreWhite = true; 
xmlData.onLoad = loadXML; 
xmlData.load("images.xml"); 
function fillbar() { 
_global.fwt = (total * 95) -95;
trace("total pic count ="+total+" total width = "+fwt+"")
for (p=0; p<(total); p++){
_root.bar.redbox.duplicateMovieClip("redbox"+p, p, {_x:(95*p), _y:_root.bar.redbox._y}); 
var datat = (eval("_root.bar.redbox"+p+".duptext"));
var urlinf = (eval("_root.bar.redbox"+p+".url"));
var imgholder = (eval("_root.bar.redbox"+p+".img"));
imgholder.createEmptyMovieClip("picture",p);
imgholder.picture.loadMovie(image[p], 1, {_height:100,_width:100});  
urlinf.text = image[p];
datat.text = labelt[p];
}
_root.bar._x = 185;
}
redbox code:
Code: Select all
on (release){
 _root.title.text = this.duptext.text;
 _root.display.loadMovie(this.url.text);
}
How do I build a preloader in this? I have looked various places and honestly it is utterly confusing! Why can you not simple use:
image[p].getBytesLoaded() ?!!?

Last edited by R Verbrugge; Sep 13th, 2007 at 14:26.
Reply With Quote
  #6 (permalink)  
Old Sep 13th, 2007, 14:26
New Member
Join Date: Sep 2007
Location: here
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: createEmptyMovieClip & onclick

Tried this:
if (imgholder.picture.onLoad = false){
trace('?');
_root.output.text = _root.output.text+"Loading.."+imgholder.picture;
fillbar;
}
else if(imgholder.picture.onLoad = true){
imgholder.picture.loadMovie(image[p], 1, {_height:100,_width:100});
_root.output.text = _root.output.text+" Completed:"+imgholder.picture;
}

no dice.
Reply With Quote
  #7 (permalink)  
Old Sep 13th, 2007, 15:23
Multimedia Specialist
Join Date: Apr 2007
Location: Arizona
Age: 25
Posts: 666
Blog Entries: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Sgaspar11
Re: createEmptyMovieClip & onclick

Did you look at the link to the tutorial I sent you? Or are you wanting to build a preloader for each individual image as it is loaded.
Last Blog Entry: Yay!? (Oct 8th, 2007)
Reply With Quote
  #8 (permalink)  
Old Sep 13th, 2007, 15:34
New Member
Join Date: Sep 2007
Location: here
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Re: createEmptyMovieClip & onclick

Quote:
Originally Posted by Sgaspar11 View Post
Did you look at the link to the tutorial I sent you? Or are you wanting to build a preloader for each individual image as it is loaded.
I did look at the link you sent me, I must admit I am quite new to flash although the fillbar() function above I figured out myself, using knowledge I have knowledge of javascript this mixed with looking on the adobe/macromedia AS 2 library produced that code (I dont know how effecient it is) and thats the way it allowed me to actually put an 'on(press)' handler on the dupped mc.

Code: Select all
function fillbar() { 
_global.fwt = (total * 95) -95;
trace("total pic count ="+total+" total width = "+fwt+"")
for (p=0; p<(total); p++){
_root.bar.redbox.duplicateMovieClip("redbox"+p, p, {_x:(95*p), _y:_root.bar.redbox._y}); 
var datat = (eval("_root.bar.redbox"+p+".duptext"));
var urlinf = (eval("_root.bar.redbox"+p+".url"));
var imgholder = (eval("_root.bar.redbox"+p+".img"));
imgholder.createEmptyMovieClip("picture",p);
// Is it here you would preload the image before it goes in the loadMovie() process? or where, how and when?! this is what confuses me!
imgholder.picture.loadMovie(image[p], 1, {_height:100,_width:100});  
urlinf.text = image[p];
datat.text = labelt[p];
}
_root.bar._x = 185;
}
And yes I do wonder if I can show individual image loaded and perhaps total progress.
Reply With Quote
Reply

Tags
createemptymovieclip

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
OnClick Behaviour Monie JavaScript Forum 3 Oct 23rd, 2007 02:13
referencing createEmptyMovieClip with dynamic names acidgreen Flash & Multimedia Forum 2 Jun 5th, 2007 15:02
OnClick to new URL and Submit together plooner JavaScript Forum 2 Feb 13th, 2007 11:48
Need help on an onclick function DaveKenroy JavaScript Forum 3 Jan 28th, 2007 11:31
onclick function tomd1985 JavaScript Forum 0 Mar 13th, 2006 18:20


All times are GMT. The time now is 12:22.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43