Flash Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignFlash Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 19th, 2004, 02:44 PM
Robban Robban is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 Robban User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Setting onPress function dynamically?

Hello! I have a problem. I make some movieclips dynamically but i can't make the onPress function to work?

Any ideas whats wrong ...

loader_xml.onLoad = function(s){
var antal = loader_xml.firstChild.childNodes.length;
for(i=0;i<antal;i++){
photoslider_mc.createEmptyMovieClip("bild"+i,i+100);
photoslider_mc["bild" + i]._x = i * 200;
photoslider_mc["bild" + i].onPress = function(){
changeImage(loader_xml.firstChild.childNodes[i].attributes.largeimage);
}

loadMovie(loader_xml.firstChild.childNodes[i].firstChild.nodeValue, "photoslider_mc.bild" + i);
}
}

Last edited by Robban : February 19th, 2004 at 02:46 PM.

Reply With Quote
  #2  
Old February 19th, 2004, 06:16 PM
Tann San Tann San is offline
Gotta get to the next screen..
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2003
Location: Legion of Dynamic Discord
Posts: 4,714 Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)Tann San User rank is Colonel (50000 - 60000 Reputation Level)  Folding Points: 10093 Folding Title: Novice Folder
Time spent in forums: 3 Weeks 1 Day 11 h 1 m 3 sec
Reputation Power: 580
Facebook MySpace
Hi, what happens if you put a trace in there?:

photoslider_mc["bild" + i].onPress = function(){
trace(loader_xml.firstChild.childNodes[i].attributes.largeimage);
}

It could be because "i" doesnt exist inside the object. Try this out:

photoslider_mc["bild" + i].onPress = function(){
changeImage(loader_xml.firstChild.childNodes[this.getDepth()-100].attributes.largeimage);
}

You will know if it's a problem location i if this is undefined:

photoslider_mc["bild" + i].onPress = function(){
trace(i);
}

Does the cursor change to a hand when it's over the moviebutton?
__________________
-Tann

-Vote for your favorite ActionScript editor here.

Reply With Quote
  #3  
Old February 19th, 2004, 08:08 PM
Robban Robban is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 2 Robban User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you for helping me but i solved it after a while ...
I solved it like this if you are interested.

loader_xml.onLoad = function(s){
var antal = loader_xml.firstChild.childNodes.length;
for(i=0;i<antal;i++){
photoslider_mc.createEmptyMovieClip("bild"+i,i+100);
photoslider_mc["bild" + i].createEmptyMovieClip("bildh" + i,i+100);
photoslider_mc["bild" + i]._x = i * 185;
photoslider_mc["bild" + i].large = loader_xml.firstChild.childNodes[i].attributes.largeimage;
photoslider_mc["bild" + i].onPress = function(){
changeImage(this.large);
}
loadMovie(loader_xml.firstChild.childNodes[i].firstChild.nodeValue, "photoslider_mc.bild" + i + ".bildh" + i);
}
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignFlash Help > Setting onPress function dynamically?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT